FS#5519 - Root drive appears twice in nautilus - /dev/root symlink missing
Attached to Project:
Arch Linux
Opened by Hussam Al-Tayeb (hussam) - Wednesday, 04 October 2006, 12:27 GMT
Last edited by Aaron Griffin (phrakture) - Monday, 12 February 2007, 09:19 GMT
Opened by Hussam Al-Tayeb (hussam) - Wednesday, 04 October 2006, 12:27 GMT
Last edited by Aaron Griffin (phrakture) - Monday, 12 February 2007, 09:19 GMT
|
Details
My root disk shows twice in nautilus once as 'Filesystem'
and once as '34.1 GB Volume'.
This worked on a previous installation with gnome 2.14.3 Output of mount: /dev/hda1 on / type ext3 (rw,errors=remount-ro) none on /proc type proc (rw) none on /sys type sysfs (rw) none on /proc/bus/usb type usbfs (rw) none on /dev/pts type devpts (rw) none on /dev/shm type tmpfs (rw) /dev/hdb1 on /home type ext3 (rw,user_xattr) cat /etc/mtab /dev/hda1 / ext3 rw,errors=remount-ro 0 0 none /proc proc rw 0 0 none /sys sysfs rw 0 0 none /proc/bus/usb usbfs rw 0 0 none /dev/pts devpts rw 0 0 none /dev/shm tmpfs rw 0 0 /dev/hdb1 /home ext3 rw,user_xattr 0 0 According to this post http://bbs.archlinux.org/viewtopic.php?p=198530#198530 , Gullible Jones has the same issue so I guess it is a bug. |
This task depends upon
hal uses /proc/mounts to get the mounted partitions and compares that to the devicenames it finds.
The problem here is that /proc/mounts lists /dev/root and "rootfs" mounted on /, not /dev/hda2 on my system. Actually, there isn't anything in /proc/mounts that shows that /dev/hda2 is mounted on my system.
'ln -s /dev/hda1 /dev/root'
and '/etc/rc.d/hal restart' and the extra entry in nautilus disappeared.
'ln -s /dev/hda1 /dev/root' at bootup before hal starts?
My 2 cents.
but the bigger problem is still the /dev/root symlink not being created.
ln -s $(mount | grep "on / " | cut -d' ' -f1) /dev/root
The “places” folder shows 3 disks labelled by their size, which are my hdb2, hdb3 and hdb4. I would have expected 3 disks hda2, hdb3 and hdb4 (given the present bug, I could also have had 4 disks hda2, hdb2, hdb3 and hdb4, with hdb2 being a duplicate of the “/”).
Now if I try mounting hda2 with the right-click mount option, it is denied because the drive “is already mounted on /”. But in reality, it is hdb2 which is mounted on “/”, not hda2. Also, I am able unmount hdb2 (with a right-click), which in reality is root !
Sure another layer of confusion on this bug.
to '/etc/rc.sysinit' just before the line "# Set up non-root encrypted partition mappings"
and now the problem is gone.
Not a solution.
returns LABEL=ROOT on my laptop... so that's not ideal either
Note there was no such problem in Gnome 2.14 (with hal and udev versions at that time).
1. Adding $(mount | grep "on / " | cut -d' ' -f1) to rc.sysinit creates the symlink and this appears to be fixed but if I do 'init s' then 'init 3', the symlink disappears since udev is started again.
2. If I add /etc/udev/rules.d/x-udev.rules with:
KERNEL=="hda1" , SYMLINK:="root"
then the symlink is created at boot and survives a 'init s' then 'init 3' operation. But this isn't an answer since not everybody's root is hda1.
My question is, can the two be merged? Can $(mount | grep "on / " | cut -d' ' -f1) be integrated into the udev rule?
Something like this:
SUBSYSTEM=="ide", PROGRAM="/bin/sh -c 'mount | grep \"%k on /\" | cut -d\" \" -f1'", SYMLINK+="%c"
SUBSYSTEM=="scsi", PROGRAM="/bin/sh -c 'mount | grep \"%k on /\" | cut -d\" \" -f1'", SYMLINK+="%c"
Should generate symlinks properly, but my udev skills may be lacking... can someone test that?
However, these udev rules remove additional partitions (duplicated because already mounted in fstab) from Places menu and Desktop, but not from Nautilus (even after killing Nautilus or relogining to Gnome session again).
That's because mount does not show root partition on my system!
mount | grep "on / " | cut -d' ' -f1 shows nothing.
[root@home ~]# mount
/dev/hda3 on /media/SYSTEM type ntfs (rw,noexec,nosuid,nodev,umask=222)
none on /dev/pts type devpts (rw)
none on /dev/shm type tmpfs (rw)
/hda3 is the only Windows partition not mounted in fstab. Other partitions are mounted in fstab and displayed two times in Places menu, desktop and Nautilus.
After few /etc/start_udev runs mount output became stripped :-/
It will work if extract root partition name from /proc instead. Where should I look?
sda5
but this still doesn't work:
SUBSYSTEM=="ide", PROGRAM="cat /proc/cmdline | sed \"s/ /\\n/\" | grep root= | sed \"s/root=\\/dev\\///\"", RESULT=="%k", SYMLINK:="root"
SUBSYSTEM=="pata", PROGRAM="cat /proc/cmdline | sed \"s/ /\\n/\" | grep root= | sed \"s/root=\\/dev\\///\"", RESULT=="%k", SYMLINK:="root"
SUBSYSTEM=="sata", PROGRAM="cat /proc/cmdline | sed \"s/ /\\n/\" | grep root= | sed \"s/root=\\/dev\\///\"", RESULT=="%k", SYMLINK:="root"
SUBSYSTEM=="scsi", PROGRAM="cat /proc/cmdline | sed \"s/ /\\n/\" | grep root= | sed \"s/root=\\/dev\\///\"", RESULT=="%k", SYMLINK:="root"
Any ideas from Udev gurus?
> Ah, phrakture, your udev fix won't work because no partitions are mounted when udev is started :D
> It will work if extract root partition name from /proc instead. Where should I look?
The root filesystem IS mounted (but readonly) when the system starts to initialize (I'm not talking about the initramfs).
Unfortunetally, the /proc/mounts entry is something like "/dev/root / ext3 rw,noatime,data=journal 0 0" so that's not very usefull anyway..
But what about using fstab? fstab should have the neccesseary and correct information about the device of the root filesystem.
less /etc/rc.sysinit shows that
status "Starting UDev Daemon" /etc/start_udev init
is above
status "Mounting Root Read-only" /bin/mount -n -o remount,ro /
adding this line to rc.multi (but before daemons loading) survives init s / init 5:
ln -s `mount | grep "on / " | cut -d' ' -f1` /dev/root
(patch is below)
@ all devs:
can this be included in next initscripts?
About init s and udev:
1. Why rc.single starts udev? I'm sure there must be some reason for this, I'm just interesting.
2. When doing init s and then init 5 system does not return to previous state!
2a. Udev does not start (bacause it's started in rc.sysinit, not rc.multi)
2b. Starting Syslog-NG [FAIL]
IMHO current initscripts are buggy when dealing with init s / init 5 switch.
I think that's because they was created in such way that assume using single-user mode only for filesystem recovering, with immediate reboot after this. They works good for ordinary use, but switching init 5 -> init s -> init 5 is buggy.
This can be corrected by checking for PREVRUNLEVEL in rc.multi.
However I'm not sure that simple reloading udev after inis s -> init 5 will return system to previous state. Can someone test this?
Patches below can be applied simultaneously.
runlevel-change-fix.patch (0.8 KiB)
you need a udev rule for /dev/root to be recreated when the user runs /etc/start_udev.
The problem was in udev!
1) it doesn't allow \" in strings
2) it doesn't split "cat ... | sed ..." into two commands, it sends "... | sed ... " as input for cat.
3) there should be SUBSYSTEM=="block" instead
That's why none of udev rules worked. :)
But I've finally found THE fix:
just put SUBSYSTEM=="block", RUN+="/lib/udev/root-link.sh" anyway in any udev rules, say root-link.rules
and the following file in /lib/udev
@ hussam:
could you please test my runlevel-change-fix.patch (as you seems to use init s / init 5 often)?
this udev fix uses /proc/cmdline parsing, so it should work when fstab contains LABEL=... instead of /dev/...
It should also work with RAID and LVM2 roots and NFS root when using /dev/nfs, but not nfsroot=
However it could be modified to parse nfsroot= too.
Oh, it was broken. Try this one.
As this BR can be closed when fix will be implemented.
I would say someone put that command there to make sure / is RO when fsck runs several commands later.. In case / was originally mounted as RW originally.
Romashka, if / is not mounted how would the kernel know where /etc/rc.sysinit is?
cat /proc/cmdline | sed "s: :\n:g" | /bin/grep root= | /bin/sed "s:root=::"
note the 'g' in the sed command!
My kernel command line is pretty big, and root= is not the first parameter :
"console=tty1 quiet video=vesafb:ypan,1024x768-16@60 splash=silent,theme:darch resume2=swap:/dev/disk/by-label/SWAP root=/dev/disk/by-label/ROOT ro"
cat /proc/cmdline | sed 's:.*root=\(.*\) .*:\1:'
(additional optimisation would be: sed 's:.*root=\(.*\) .*:\1:' < /proc/cmdline )
:)
Of course / is mounted on boot (BTW, I'm curious how udev fills /dev before / is mounted RW).
Thank you for improvements. One sed command is very nice. :)
I post an updated file.
what's wrong with the earlier solution?
I'm refering to
SUBSYSTEM=="block", RUN+="/lib/udev/root-link.sh" anyway in any udev rules, say root-link.rules
and
root-link.sh
I am running this solution now and it works perfectly. Why not implement it?
But I think we need this workaround now, until mainstream devs fix it.
I tried patching hal a long while ago to use /etc/mtab, but it didn't work out, nothing was recognized anymore.
And for your information, hal is a freedesktop project, not a gnome project ;)
because this issue exists only for hal+nautilus users AFAIK. And there was no problem in gnome 2.14.3.
:/
In any case, Roman's udev solution works perfectly and seems to be very safe. It survives changing runlevels and even restarting udev.
Would you mind trying it yourslelf?
Just add this udev rule:
SUBSYSTEM=="block", RUN+="/lib/udev/root-link.sh"
and
install root-link.sh to /lib/udev/
After that either reboot or run /etc/start_udev
Then killall nautilus.