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
Task Type Bug Report
Category System
Status Closed
Assigned To Tobias Powalowski (tpowa)
Architecture not specified
Severity High
Priority Normal
Reported Version 0.7.2 Gimmick
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

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

Closed by  Roman Kyrylych (Romashka)
Tuesday, 13 February 2007, 19:50 GMT
Reason for closing:  Fixed
Comment by Hussam Al-Tayeb (hussam) - Wednesday, 04 October 2006, 12:30 GMT
this is with nautilus 2.16.1
Comment by name withheld (Gullible Jones) - Wednesday, 04 October 2006, 21:26 GMT
Can confirm. On my system, /dev/hda1 is shown both as Filesystem and as "18.7 GB Volume", which Gnome thinks is unmounted, but of course cannot be mounted because it is already mounted as /.
Comment by Jan de Groot (JGC) - Wednesday, 04 October 2006, 22:45 GMT
Yes, this is a bit weird issue here:
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.
Comment by Jan de Groot (JGC) - Thursday, 05 October 2006, 20:31 GMT
reassigning to tobias, as initcpio and/or the initscripts don't create a /dev/root symlink pointing to the root device. When this symlink exists, hal detects the rootfs mount state correctly.
Comment by Hussam Al-Tayeb (hussam) - Thursday, 05 October 2006, 20:44 GMT
Jan, /dev/root should point to /dev/hda1 in my case, right?
Comment by Hussam Al-Tayeb (hussam) - Thursday, 05 October 2006, 20:47 GMT
Yep that's it, I did:
'ln -s /dev/hda1 /dev/root'
and '/etc/rc.d/hal restart' and the extra entry in nautilus disappeared.
Comment by Aaron Griffin (phrakture) - Friday, 06 October 2006, 16:31 GMT
Looking into it.
Comment by Hussam Al-Tayeb (hussam) - Wednesday, 11 October 2006, 18:38 GMT
In the meantine untill this is fixed, is it possible to make a script that just does:
'ln -s /dev/hda1 /dev/root' at bootup before hal starts?
Comment by Aaron Griffin (phrakture) - Wednesday, 11 October 2006, 18:55 GMT
My drive is /dev/sda1... so no, that's not a fix...you can do it on a case-by-case basis though
Comment by Real Name (Michel F) - Wednesday, 11 October 2006, 21:03 GMT
If you implement what's in this wiki http://wiki.archlinux.org/index.php/HAL , then the '34.1 GB Volume' entry (or whatever it may be) disappears from Nautilus. Of course, all other non-removable disks diappear also... It's a choice.

My 2 cents.
Comment by Hussam Al-Tayeb (hussam) - Wednesday, 11 October 2006, 21:28 GMT
Michel Favreau, that is a good workaround but I would rather have unmounted CD-ROM and DVD-ROM drives appear in nautilus. Also this workaround might remove the icon for floppy drives making it harder to mount them.
but the bigger problem is still the /dev/root symlink not being created.
Comment by Hussam Al-Tayeb (hussam) - Wednesday, 11 October 2006, 21:29 GMT
Could this be a udev problem?
Comment by Aaron Griffin (phrakture) - Wednesday, 11 October 2006, 21:30 GMT
Yes. The problem is know. The fix is known... as I said, I am looking into it.
Comment by Aaron Griffin (phrakture) - Wednesday, 11 October 2006, 21:32 GMT
for a "quick and dirty" fix, add the following to /etc/rc.local:

ln -s $(mount | grep "on / " | cut -d' ' -f1) /dev/root
Comment by Hussam Al-Tayeb (hussam) - Wednesday, 11 October 2006, 21:45 GMT
/etc/rc.local is executed after hal starts so hal has to manually restarted afterwards.
Comment by Real Name (Michel F) - Tuesday, 17 October 2006, 19:36 GMT
I have 2 hard drives: hda (hda1 swap, hda2 ext3) and hdb (hdb1 swap, hdb{2,3,4} ext3). Arch with testing gnome 2.16 is installed on hdb2 and has been updated yesterday, October 16.

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.
Comment by Hussam Al-Tayeb (hussam) - Tuesday, 17 October 2006, 19:54 GMT
I added Aaron Griffin's line: ln -s $(mount | grep "on / " | cut -d' ' -f1) /dev/root
to '/etc/rc.sysinit' just before the line "# Set up non-root encrypted partition mappings"
and now the problem is gone.
Comment by Real Name (Michel F) - Wednesday, 18 October 2006, 01:04 GMT
I tried this and it removes my hda2 partition, which is not my root partion, and leaves hdb2, which is my root partition.

Not a solution.
Comment by Damjan Georgievski (damjan) - Sunday, 29 October 2006, 01:40 GMT
mount | grep "on / " | cut -d' ' -f1
returns LABEL=ROOT on my laptop... so that's not ideal either
Comment by Real Name (Michel F) - Tuesday, 31 October 2006, 20:28 GMT
My previous comments should be discarded. I made several configuration mistakes. Now, if I insert ln -s /dev/hdxx /dev/root in /etc/sysinit.rc, everything is fine.
Comment by Roman Kyrylych (Romashka) - Monday, 06 November 2006, 19:11 GMT
I had the same on vmware but not on real system :-/ Both use exactly the same packages and same versions, but slightly different partitioning (the only change is / on hda3/hda5). Weird.
Comment by Roman Kyrylych (Romashka) - Monday, 06 November 2006, 21:06 GMT
Gnome 2.16.1. Same thing now, but on real Arch box too. :(
Comment by Hussam Al-Tayeb (hussam) - Sunday, 19 November 2006, 04:45 GMT
Any progess on this one?
Comment by name withheld (Gullible Jones) - Sunday, 19 November 2006, 18:18 GMT
Nope. The only difference right now is that Nautilus doesn't try to mount it (or do anything at all) if you try to open it.
Comment by Aaron Griffin (phrakture) - Monday, 20 November 2006, 18:31 GMT
Well, I had assumed someone else would pick this one up, as the initscripts are generally not my domain. The problem here is the missing /dev/root symlink which needs to be a link to 'rootfs'. There are a few ways to handle this, but I suspect a simple grep of /etc/mtab in rc.sysinit will give us the proper device. I will add a fix in testing later today. It may not be the best fix, but it will be a fix.
Comment by Roman Kyrylych (Romashka) - Monday, 20 November 2006, 18:56 GMT
Emm..., just a guess... maybe it's fixed in nautilus 2.16.3?
Comment by Hussam Al-Tayeb (hussam) - Monday, 20 November 2006, 19:21 GMT
Aaron Griffin, after you create the /dev/root symlink, if you do init s and then init 3 again, the /dev/root symlink disappears. I just noticed this today.
Comment by Hussam Al-Tayeb (hussam) - Saturday, 25 November 2006, 18:45 GMT
Can some sort of udev rule fix this?
Comment by Roman Kyrylych (Romashka) - Monday, 27 November 2006, 12:10 GMT
Ehm, so where's the problem actually? HAL? Udev? Gnome? :-/ I mean which package update broke things working?
Note there was no such problem in Gnome 2.14 (with hal and udev versions at that time).
Comment by Hussam Al-Tayeb (hussam) - Monday, 04 December 2006, 20:36 GMT
here's the thing:
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?


Comment by Aaron Griffin (phrakture) - Monday, 04 December 2006, 22:16 GMT
Actually, that's a good idea, and the best solution I've seen.

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?
Comment by Roman Kyrylych (Romashka) - Monday, 04 December 2006, 23:07 GMT
Neither rc.sysinit hack nor udev rules don't fix Nautilus problem for me.
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.
Comment by Roman Kyrylych (Romashka) - Monday, 04 December 2006, 23:14 GMT
oops, that was my mistake.
After few /etc/start_udev runs mount output became stripped :-/
Comment by Roman Kyrylych (Romashka) - Monday, 04 December 2006, 23:22 GMT
Nah, udevtest says that these udev rules are invalid. :(
Comment by Roman Kyrylych (Romashka) - Saturday, 09 December 2006, 20:37 GMT
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?
Comment by Roman Kyrylych (Romashka) - Saturday, 09 December 2006, 21:56 GMT
# cat /proc/cmdline | sed "s/ /\n/" | grep root= | sed "s/root=\/dev\///"
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?
Comment by Damjan Georgievski (damjan) - Monday, 11 December 2006, 02:14 GMT
@Romanshka
> 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.

Comment by Roman Kyrylych (Romashka) - Monday, 11 December 2006, 11:45 GMT
> The root filesystem IS mounted (but readonly) when the system starts to initialize (I'm not talking about the initramfs).
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 /
Comment by Roman Kyrylych (Romashka) - Monday, 11 December 2006, 12:48 GMT
@ hussam:
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.
Comment by Hussam Al-Tayeb (hussam) - Monday, 11 December 2006, 22:41 GMT
Roman Kyrylych, your fix is good and I'm using it now but what if the user runs /etc/start_udev ? /dev/root will dissappear.
you need a udev rule for /dev/root to be recreated when the user runs /etc/start_udev.
Comment by Roman Kyrylych (Romashka) - Tuesday, 12 December 2006, 09:49 GMT
Eureka!!!

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

Comment by Roman Kyrylych (Romashka) - Tuesday, 12 December 2006, 09:51 GMT
sed "s/anyway/anywhere/"

@ hussam:
could you please test my runlevel-change-fix.patch (as you seems to use init s / init 5 often)?
Comment by Roman Kyrylych (Romashka) - Tuesday, 12 December 2006, 09:59 GMT
@damjan:
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.
Comment by Hussam Al-Tayeb (hussam) - Tuesday, 12 December 2006, 10:00 GMT
Just runlevel-change-fix.patch? Ok, testing now.
Comment by Hussam Al-Tayeb (hussam) - Tuesday, 12 December 2006, 10:01 GMT
the patch didn't apply.
Comment by Roman Kyrylych (Romashka) - Tuesday, 12 December 2006, 10:09 GMT
BTW, please confirm that my udev fix works. ;)

Oh, it was broken. Try this one.
Comment by Roman Kyrylych (Romashka) - Tuesday, 12 December 2006, 10:10 GMT
That runlevel-change-fix.patch should probably be another bug report, of course
As this BR can be closed when fix will be implemented.
Comment by Roman Kyrylych (Romashka) - Tuesday, 12 December 2006, 11:27 GMT
Important: do not forget to do chmod +x /lib/udev/root-link.sh ! :D
Comment by Hussam Al-Tayeb (hussam) - Tuesday, 12 December 2006, 11:57 GMT
The udev fix seems to work. Can we get this into the Udev package in current?
Comment by Damjan Georgievski (damjan) - Tuesday, 19 December 2006, 03:54 GMT
@status "Mounting Root Read-only" /bin/mount -n -o remount,ro /

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?
Comment by Damjan Georgievski (damjan) - Tuesday, 19 December 2006, 03:59 GMT
@Romashka,
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"
Comment by Damjan Georgievski (damjan) - Tuesday, 19 December 2006, 04:08 GMT
Actually this one command will do the same:
cat /proc/cmdline | sed 's:.*root=\(.*\) .*:\1:'

(additional optimisation would be: sed 's:.*root=\(.*\) .*:\1:' < /proc/cmdline )
:)
Comment by Roman Kyrylych (Romashka) - Tuesday, 19 December 2006, 10:13 GMT
@damjan: I meant that no partitions aremoved RW, when said this. :p
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.
Comment by Hussam Al-Tayeb (hussam) - Tuesday, 19 December 2006, 11:21 GMT
I know people rarely have to manually run /etc/start_udev but manually making the symlink is really bad because it will disappear if the user for whatever reason has to run start_udev

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?
Comment by Roman Kyrylych (Romashka) - Tuesday, 19 December 2006, 11:44 GMT
As brain0 explained /dev/root is not needed, software should use /etc/mtab instead of /proc/mounts
But I think we need this workaround now, until mainstream devs fix it.
Comment by Hussam Al-Tayeb (hussam) - Tuesday, 19 December 2006, 11:47 GMT
then should I report this to gnome bugzilla?
Comment by Roman Kyrylych (Romashka) - Tuesday, 19 December 2006, 11:49 GMT
Yes, that will be nice.
Comment by Jan de Groot (JGC) - Tuesday, 19 December 2006, 12:19 GMT
so what about distributions that link /proc/mounts to /etc/mtab, or readonly / filesystems that can't update /etc/mtab? Also, relying on a stupid file managed by userspace utils is wrong when you can read out these things from the kernel using the /proc filesystem.

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 ;)
Comment by Roman Kyrylych (Romashka) - Tuesday, 19 December 2006, 12:29 GMT
Does kde/konqueror make use of hal too?
because this issue exists only for hal+nautilus users AFAIK. And there was no problem in gnome 2.14.3.
:/
Comment by Jan de Groot (JGC) - Tuesday, 19 December 2006, 12:39 GMT
KDE uses hal too now yes. This issue exists in KDE also. In previous versions, harddisks weren't managed by hal if they weren't removable, so your root drive wouldn't show up in KDE and GNOME would only show it as "root filesystem", which is a static entry that's always there.
Comment by Hussam Al-Tayeb (hussam) - Tuesday, 19 December 2006, 13:14 GMT
Jan, I only mentioned gnome bugzilla because we were under the impression that only nautilus is affected.

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.
Comment by Alper Kanat (T-u-N-i-X) - Tuesday, 09 January 2007, 15:00 GMT
If every test is OK, can you please release an update for udev so that this bug is no more occurs ?
Comment by Aaron Griffin (phrakture) - Monday, 12 February 2007, 09:19 GMT
This looks like it could easily be fixed with udev - assigning to tpowa.

Loading...