Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#19785 - [initscripts] 2010.06-2 handle mounts incorrectly

Attached to Project: Arch Linux
Opened by Sylvain Laurent (Magicking) - Sunday, 13 June 2010, 12:43 GMT
Last edited by Andrea Scarpino (BaSh) - Wednesday, 14 July 2010, 21:48 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Thomas Bächler (brain0)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 3
Private No

Details

Description:
I recently updated my initscripts to initscripts version 2010.06-2 and now initscritps use /proc/mount as base for /etc/mtab wich leads to a crappy /etc/mtab

Additional info:
$ cat /etc/mtab
rootfs on / type rootfs (rw)
proc on /proc type proc (rw,relatime)
sys on /sys type sysfs (rw,relatime)
udev on /dev type tmpfs (rw,nosuid,relatime,size=10240k,mode=755)
/dev/disk/by-uuid/0d21f223-9208-4661-9e82-3f77266173aa on / type ext4 (rw,noatime,nodiratime,barrier=1,data=ordered)
/dev/sdb2 on /mnt/sdcard type ext2 (ro,relatime,errors=continue)
devpts on /dev/pts type devpts (rw)
shm on /dev/shm type tmpfs (rw,nosuid,nodev)
/tmp on /tmp type tmpfs (rw,size=120m)
/dev/sda1 on /boot type vfat (rw)
/dev/mapper/home on /home type ext4 (rw,noatime,nodiratime)

As you can see the / is specified two times and

This diff(relevant lines) made with a last [core] rc.sysinit make it looks right:
[14:28:48]% diff /etc/rc.sysinit rc.sysinit
300c300,306
< cat /proc/mounts >| /etc/mtab
---
> : >| /etc/mtab
> # make sure / gets written to /etc/mtab
> /bin/mount -o remount,rw /
> # Write /proc, /sys and /dev to /etc/mtab
> if [ -e /proc/mounts ]; then
> /bin/grep -e "/proc " -e "/sys " -e "/dev " /proc/mounts >> /etc/mtab
> fi

Regards
This task depends upon

Closed by  Andrea Scarpino (BaSh)
Wednesday, 14 July 2010, 21:48 GMT
Reason for closing:  Fixed
Additional comments about closing:  initscripts 2010.07-1
Comment by Thomas Bächler (brain0) - Sunday, 13 June 2010, 13:40 GMT
I was thinking about that. What it says is actually correct, as "rootfs" exists and is actually mounted. The new root was just mounted above it. On the other hand, it is unintuitive and might confuse userspace. I am considering stripping the rootfs line from mtab.
Comment by Sylvain Laurent (Magicking) - Sunday, 13 June 2010, 17:30 GMT
The tiny patch attached seems to do the job right as it get info from /proc/self/mountinfo and correlate it with /proc/self/mounts to set up mtab.
Comment by Andres P (llanero) - Sunday, 20 June 2010, 03:58 GMT
@magicking

uuoc

$ diff -s <(cat /proc/self/mountinfo | cut -d\ -f9) <(cut -d\ -f9 /proc/self/mountinfo)
Files /dev/fd/63 and /dev/fd/62 are identical
Comment by Gerardo Exequiel Pozzi (djgera) - Friday, 25 June 2010, 22:43 GMT
  • Field changed: Summary (initscripts 2010.06-2 handle mounts incorrectly → [initscripts] 2010.06-2 handle mounts incorrectly)
I agree with /proc/self/mountinfo as source of mtab, It seems that the information is more appropiate, because the rootfs is on another namespace (chroot is done in switch_root).
For example in archiso [#1] there are others fs mounted before switch_root that are not moved to "/new_root" so having on /etc/mtab is not correct. (like for rootfs are part of another namespace).

Remember that mountinfo is available since Linux >= 2.6.26. So should be used conditionally. (Arch Linux is supposed to run with older kernel with some "hacks")

[#1]  FS#19983  - [archiso] umount errors, on shutdown (with > initscripts 2010.06-2)
Comment by Gerardo Exequiel Pozzi (djgera) - Saturday, 26 June 2010, 01:07 GMT
  • Field changed: Category (Packages: Testing → Packages: Core)
I guess that this will be handled better with future release of util-linux-ng with findmnt+libmount.

See http://article.gmane.org/gmane.linux.utilities.util-linux-ng/3239
Comment by Gerardo Exequiel Pozzi (djgera) - Monday, 05 July 2010, 17:44 GMT
Ok now util-linux-ng-2.18 is on testing so findmnt is available and can parse /proc/self/mountinfo

(the issue now, is that -u (notruncate) does not work correctly with OPTIONS column)

$ findmnt -rnu -o SOURCE,TARGET,FSTYPE,OPTIONS
proc /proc proc rw,relatime
sys /sys sysfs rw,relatime
udev /dev devtmpfs rw,nosuid,relatime,size=10240k,nr_inodes=216873,mode=
none / aufs rw,relatime,si=48993
none /dev/pts devpts rw,relatime,mode=600,ptmxmode=
none /dev/shm tmpfs rw,relatime
Comment by Thomas Bächler (brain0) - Monday, 05 July 2010, 17:58 GMT
Yes, that is what I am going to do. However, it is buggy, see how the longer lines miss the last 3 characters? That needs to be fixed first.
Comment by Gerardo Exequiel Pozzi (djgera) - Monday, 05 July 2010, 18:05 GMT
Yes, that I was said, seems is broken for now.

This patch can be used when findmnt works OK.
Comment by Gerardo Exequiel Pozzi (djgera) - Monday, 05 July 2010, 23:23 GMT
@Thomas: I tested the fix in response to your report in util-linux-ng mailing list [#1] and seems to works fine.

$ ./findmnt -rnu -o SOURCE,TARGET,FSTYPE,OPTIONS | grep loop
/dev/loop0 /tmp/a/veryloooonnnnn/ggggggg/pathhhhh/arch/linux/loves/you ext4 rw,noatime,nodiratime,min_batch_time=1,max_batch_time=1,barrier=1,data=ordered

[#1] http://article.gmane.org/gmane.linux.utilities.util-linux-ng/3291
Comment by Thomas Bächler (brain0) - Monday, 05 July 2010, 23:42 GMT
The new util-linux-ng in testing (2.18-2) fixes the problem. Patch applied to initscripts.git: http://projects.archlinux.org/initscripts.git/commit/?id=05cd2ffd945f409eeb9fdbb020c41584a8d1536e
Comment by Thomas Bächler (brain0) - Monday, 05 July 2010, 23:44 GMT
Hmm, one more thing. I thought about it earlier: mtab has "0 0" at the end of each line, as has /proc/mounts. If tried to find out what they are good for, and it seems they have the same meaning as in fstab - which makes no sense. Do you have any more info on that?
Comment by Gerardo Exequiel Pozzi (djgera) - Tuesday, 06 July 2010, 00:12 GMT
Thanks!
Yes, I was thinking about that in these days, but these two parameters are optional, so if not present are (or should be) interpreted as 0 for programs that looks for it (dump, fsck).

There is another minor thing (I guess is inoffensive) is that small difference in the output (findmnt outputs more/few options that present on mtab regenerated via normal mount)

example will be better than my description:
rw,noatime,nodiratime,max_batch_time=1,min_batch_time=1,journal_ioprio=7 (mtab on mount -o loop,max_batch_time=1,min_batch_time=1,journal_ioprio=7,noatime,norelatime,nodiratime)
rw,noatime,nodiratime,min_batch_time=1,max_batch_time=1,barrier=1,data=ordered (findmnt output this)
Comment by Thomas Bächler (brain0) - Tuesday, 06 July 2010, 06:24 GMT
If they are optional, then we omit them.

The different in options is normal: when mount manages mtab, it omits some options, and may add some that the kernel doesn't know about. Note that the purpose here is not re-creation of mtab in the running system, but rather the initial creation of mtab.
Comment by Gerardo Exequiel Pozzi (djgera) - Tuesday, 06 July 2010, 23:11 GMT
OK.

Perfectly, mtab looks good now, tested on three scenarios:
* archiso (fixes  FS#19983 )
* machine that boots with root=/dev/sdaN
* machine that boot with root=/dev/disk/by-label/NNNNN.... and label is OK.

PS: there is a plan to release in next days a new initscripts and mkinitcpio? Thanks.
Comment by Thomas Bächler (brain0) - Wednesday, 07 July 2010, 08:54 GMT
Whenever I get to my computer outside of work ... which might not be before Thursday.

Loading...