[Pkg-sysvinit-devel] Bug#655582: initscripts: incorrect rootfs unmount logic causes dirty FS at every boot
Michele Mazzucchi
m.mazzucchi at keencons.com
Thu Jan 12 14:42:16 UTC 2012
Package: initscripts
Version: 2.88dsf-13.1
Severity: important
Hello folks,
While building a system based on an "aufs" root, I noticed that all
partitions, at start up, always require fsck when the union is used,
even after clean shutdowns.
The /etc/rc0.d/K08umountfs node (really /etc/init.d/umountfs ) fails
to unmount them at shutdown. That script contains this logic to determine
which mounted entries not to unmount:
========================
do_stop () {
exec 9<&0 </proc/mounts
PROTECTED_MOUNTS="$(sed -n '0,/^\/[^ ]* \/ /p' /proc/mounts)"
========================
This protects all mounts "up to the / ". However, such sed pattern matches the
root filesystem as "is mounted on path <slash> AND the mount device starts
with <slash>". If the root filesystem is mounted from a node such as "aufs",
the root line does not match, and all mounts end up in PROTECTED_MOUNTS.
I suppose the additional "/" constraint is a hack used to prevent matching the
initial "rootfs /" entry. I would rewrite this as:
PROTECTED_MOUNTS="$(awk 'NR==1,$1 != "rootfs" && $2 == "/"' /proc/mounts)"
or, since awk dwells in /usr,
PROTECTED_MOUNTS="$(sed -n ':a;/^[^ ]* \/ /!{H;n;ba};{H;s/.*//;x;s/\n//;p}'
/proc/mounts)"
This unmounts all entries down to the "base" root which is not the kernel standard
"rootfs". If / is mounted multiple times, this unmounts all "stacked" entries as well.
In the "aufs" case I described above, this ensures the additional partitions are
cleanly unmounted.
Any comments?
cheers
michele
-- System Information:
Debian Release: 6.0.3
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: armel (armv5tel)
Kernel: Linux 2.6.32-5-kirkwood
Locale: LANG=en_US.UTF-8, LC_CTYPE=UTF-8 (charmap=locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash
Versions of packages initscripts depends on:
ii coreutils 8.5-1 GNU core utilities
ii debianutils 3.4 Miscellaneous utilities specific t
ii libc6 2.11.2-10 Embedded GNU C Library: Shared lib
ii lsb-base 3.2-23.2squeeze1 Linux Standard Base 3.2 init scrip
ii sysv-rc 2.88dsf-13.1 System-V-like runlevel change mech
ii sysvinit-utils 2.88dsf-13.1 System-V-like utilities
Versions of packages initscripts recommends:
ii e2fsprogs 1.41.12-4stable1 ext2/ext3/ext4 file system utiliti
ii psmisc 22.11-1 utilities that use the proc file s
initscripts suggests no packages.
-- debconf information excluded
-------------- next part --------------
A non-text attachment was scrubbed...
Name: umountfs.patch
Type: application/octet-stream
Size: 169 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-sysvinit-devel/attachments/20120112/89fd3be6/attachment.obj>
More information about the Pkg-sysvinit-devel
mailing list