root entry in /etc/fstab: first field (fs_spec) ignored
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Which OS are you using and do your kernel parameter root= and fstab / entry first field values differ?
I am planning to use the new GRUB (why is it called GRUB2 when it's actually GRUB 1.99?) but have deferred the plan until it is convenient to re-partition the HDD because the Arch WIKI says regards MBR partitioning "Usually the post-MBR gap (after the 512 byte MBR region and before the start of the 1st partition) in many MBR (or msdos disklabel) partitioned systems is 32 KiB when DOS compatibility cylinder alignment issues are satisfied in the partition table. However a post-MBR gap of about 1 to 2 MiB is recommended to provide sufficient room for embedding GRUB2's core.img ([2]). It is advisable to use a partitioner which supports 1 MiB partition alignment to obtain this space as well as satisfy other non-512 byte sector issues (which are unrelated to embedding of core.img)".
Actually I think the boot loader is irrelevant to what happens after it has loaded the kernel image and passed it the kernel parameters.
The linked thread is interesting but is about ext2/3/4 file systems; as the OP shows the / file system is JFS.
Update: the behaviour is diffferent and more misleading under Slackware64 14.0 which has the 3.2.29 kernel.
Using legacy GRUB and booting sda3 with this stanza ...
Code:
title Slackware64 14.0 (1 TB HDD, Linux partition 3)
root (hd1,2)
kernel /boot/vmlinuz root=/dev/sda3 vga=791 vt.default_utf8=1 acpi_enforce_resources=lax ro
... when etc/fstab on /dev/sda3 contains this mismatched entry (sda14 instead of sda3) for / ...
Code:
/dev/sda14 / jfs noatime,errors=remount-ro 0 1
... after booting, there are some confusing outputs about the root file system:
Code:
root@CW8:~# /bin/df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda14 12944784 7144732 5800052 56% /
[snip]
root@CW8:~# cat /etc/mtab
/dev/sda14 / jfs rw,noatime,errors=remount-ro 0 0
[snip]
root@CW8:~# cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / jfs rw,noatime 0 0
[snip]
root@CW8:~# /bin/ls -l /dev/root
/bin/ls: cannot access /dev/root: No such file or directory
root@CW8:~# mount /dev/sda3 /mnt/hd/sda3
root@CW8:~# mount /dev/sda14 /mnt/hd/sda14
root@CW8:~# /bin/df / /mnt/hd/sda3 /mnt/hd/sda14
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda14 12944784 7144732 5800052 56% /
/dev/sda3 12944784 7144732 5800052 56% /mnt/hd/sda3
/dev/sda14 12944752 6965476 5979276 54% /mnt/hd/sda14
Maybe it works something like this:
The root=/dev/sda3 kernel parameter causes /dev/sda3 to be mounted as / by the kernel
The kernel runs the boot scripts from /dev/sda3
udev(?) creates /dev/root as a symlink to /dev/sda3 in the normal way.
The boot scripts remount / rw
The kernel logs /dev/root as the / device, later visible via /proc/mounts
The boot scripts run mount -a which actions the erroneous fstab line for /. This does not change the file system mounted at / but does remove the /dev/root symlink and writes an erroneous entry to /etc/mtab.
The phenomenon seems to be a bug in df or wherever it gets its information from but there is one command which correctly detects which partition is mounted as root, lsblk. /proc/mounts is unhelpful.
root@CW8:~# df /
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda14 jfs 13G 8.8G 3.7G 71% /
root@CW8:~# cat /proc/mounts | grep ' / '
rootfs / rootfs rw 0 0
/dev/root / jfs rw,noatime 0 0
root@CW8:~# ls -l /dev/root
ls: cannot access /dev/root: No such file or directory
root@CW8:~# lsblk | grep -E 'sda14|sdb7'
└─sdb7 8:23 0 12.4G 0 part /
├─sda14 8:14 0 12.4G 0 part
Notes:
The information from df is wrong (sda14).
/proc/mounts does not say which partition is /
Only lsblk correctly identifies sdb7 as /
sdb7 is a backup clone of sda14, taken by dd. At the time of my initial post they had identical UUIDs and I thought that could be the cause of the problem but the symptoms are the same after changing sda14's.
Last edited by catkin; 06-23-2013 at 04:10 AM.
Reason: Typo
Slackware's rc.S populates the missing entries of /etc/mtab after the root filesystem is remounted read-write using the "mount -f" fake-mount option. Specifically it does a /sbin/mount -f -w / which assumes that the fstab is correct and as such any inconsistency will be propagated to /etc/mtab and through it to all the other utilities such as 'df' that refer to it.
Of course, if you keep your fstab entry correct this isn't a problem, but perhaps pulling the root device from /proc/mounts rather than fstab would be more reliable when encountering untidy people who have the wrong value in their fstab.
Something along the lines of: /sbin/mount -f -w "$(grep -v '^rootfs' /proc/mounts | grep '^[^ ]\+ / ' | cut -f1 -d ' ')" /
Testing on Slackware64 14.0 (booted from /dev/sda14 which matches its fstab line for /) showed there is no /dev/root ...?
On Slackware64 13.37 /dev/root was a symlink to the /dev/sd[[:lower:]] that was mounted as /
IDK if the absence of /dev/root is usual or a strange feature of my personal computer. I browsed /lib/udev/rules.d/* files, looking for a rule that would create /dev/root but did not find. I could have missed it -- there are a lot of rules.
EDIT:
After posting that I looked for how /dev/root (the symlink and the /proc/mounts entry) are created. No clear picture emerged. The most illuminating pages were on the Gentoo Forums and lkml.org.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.