/etc/init.d/umountroot doesn't umount root, resulting in possible data loss
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
sysvinit (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
util-linux (Ubuntu) |
Invalid
|
Low
|
Unassigned |
Bug Description
For the last few weeks I've been noticing that my root filesystem is having its transaction log replayed every time I boot. This usually indicates that the filesystem wasn't umounted before shutting down.
I found out what is going on.
I run dapper, and have a breezy partition which I chroot to sometimes.
I want the breezy chroot to be able to see my dapper files, so I use a --bind mount to make dapper's root partition available inside the breezy chroot.
The relevant lines in my /etc/fstab are:
# the root partition
/dev/hda6 / reiserfs defaults 0 0
# remount the root partition inside the breezy chroot
/ /mnt/breezy/
Now... when /etc/init.
mount -n -o remount,ro /
The mount command sees that I only specified one of <mountpoint> and <device> and so tries to "find the other pathname in fstab" (mount/mount.c, line 1700).
It does this as follows:
if ((mc = getfsspec (spec)) == NULL && /* Find the device SPEC in fstab. */
(mc = getfsfile (spec)) == NULL && /* Find the dir FILE in fstab. */
ie. it first of all tries to find a line in /etc/fstab with a device of "/", before trying to find a line with a mountpoint of "/", and so it finds the "bind" line, and uses that.
This results in the error message:
mount: /mnt/breezy/
(since everything other than / has been umounted already by /etc/init.
The end result is that /dev/hda6 is left mounted, and then the power is turned off, resulting in possible data loss.
Switching the order of the calls to getfsspac() and getfsfile() in util-linux-
An alternative solution would be to work around the problem in /etc/init.
The mount(8) man page says:
(ii) When mounting a file system mentioned in fstab, it
suffices to give only the device, or only the mount point.
but doesn't say what happens if the argument you give appears in both the device and mount point fields of the fstab.
Could somebody look at this bug please? It's quite important, and results in my root filesystem never being remounted readonly before a reboot.
To reproduce it, try this:
1. try remounting the root filesystem like /etc/init. d/umountroot does it when you shut down. it can't, because it's busy,but at least it finds the first mount point:
$ sudo mount -n -o remount,ro /
mount: / is busy
2. add a "bind" mount of the root filesystem to /etc/fstab:
$ mkdir /tmp/root
$ sudo bash -c "echo / /tmp/root none bind 0 0 >> /etc/fstab"
3. repeat step 1. this time mount doesn't find the correct mount point, so even if the filesystem wasn't busy, the command would still fail when you shut down:
$ sudo mount -n -o remount,ro /
mount: /tmp/root not mounted already, or bad option