[Pkg-sysvinit-devel] Bug#588675: / left as /dev/root with non-initrd kernel
Elliott Mitchell
ehem+debian at m5p.com
Wed Jul 30 01:32:54 UTC 2014
Alas my upgrade cycle is a bit behind due to certain steps being slow,
but due to lack of any news of this bug being resolved I've ended up
doing experimentation and gotten some interesting results. While the
results of this bug might not be that severe, given the number of
utilities effected I'm left wondering if it deserves higher severity
(notice bugs, 620465, 653073, 656333, and there may be others I'm unaware
of). I'm left wondering if this is in fact a genuine Linux kernel bug
that appeared between 2.6.18 and 2.6.32.
One pointer towards a version-specific kernel bug, looking at a mipsel
Debian system with a 3.2.57-3 series kernel. While the "rootfs / rootfs"
line remains in /proc/mounts the line for (or what would be) the root
filesystem is:
/dev/mtdblock2 / jffs2 ro,relatime 0 0
No idea of where to point fingers now.
A greater level of experimentation did reveal a workaround of sorts, but
I suspect using this would require reassigning this bug to sysvinit (and
likely need to be cloned to systemd since they'll need to worry about
this too). First step, boot the system with "init=/bin/sh" on the kernel
command-line. Next, run the commands:
mount -t tmpfs tmpfs /lib/init/rw
mkdir /lib/init/rw/old /lib/init/rw/new
# ...or whatever FS and device are specified as root in /etc/fstab
mount -t ext4 -r /dev/sda6 /lib/init/rw/new
mount --bind /lib/init/rw /lib/init/rw/new/lib/init/rw
pivot_root /lib/init/rw/new /lib/init/rw/new/lib/init/rw/old
exec /bin/sh < /dev/console > /dev/console 2>&1
umount /lib/init/rw/old/lib/init/rw
umount /lib/init/rw/old
umount /lib/init/rw
exec /sbin/init
After the last line everything will come up as expected and /proc/mounts
will *only* contain the line for the actual device.
The reason utilizing a temporary filesystem (/lib/init/rw) is required is
the 2.6.32 Linux kernel *refuses* to mount a filesystem on a subdirectory
of itself. While I understand trying to save lusers from themselves,
sometimes admins really do need the power to shoot themselves in the foot
with a gatling shotgun. Another experiment and it looks like 3.2.57-3
may not have this issue. The exec of /bin/sh was required as otherwise
the init shell kept /dev/console on the /dev/root mount open.
Due to how low-level these operations are these operations would likely
need to be done inside init, rather than the init scripts. From what I
observed if one wanted to do these steps in the init scripts, init would
need a super-duper version of SIGUSR1 to cause init to chdir("/").
--
(\___(\___(\______ --=> 8-) EHM <=-- ______/)___/)___/)
\BS ( | EHeM+sigmsg at m5p.com PGP 87145445 | ) /
\_CS\ | _____ -O #include <stddisclaimer.h> O- _____ | / _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445
More information about the Pkg-sysvinit-devel
mailing list