Bug#655582: initscripts: incorrect rootfs unmount logic causes dirty FS at every boot

2012-01-21 Thread Roger Leigh
On Thu, Jan 12, 2012 at 03:42:16PM +0100, Michele Mazzucchi wrote:
 
 do_stop () {
 exec 90 /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=$(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?

After testing it, it appears to work correctly.  I'm afraid my sed
skills don't go this far, so I can't tell just by looking that it's
obviously correct, but it certainly looks OK.  Unless there are any
objections, I'll apply this.

If you could possibly humour my poor understanding, and briefly
explain what the different parts of the sed program do, it would go
a long way to improving my understanding and confidence in it.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?   http://gutenprint.sourceforge.net/
   `-GPG Public Key: 0x25BFB848   Please GPG sign your mail.



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#655582: initscripts: incorrect rootfs unmount logic causes dirty FS at every boot

2012-01-12 Thread Michele Mazzucchi
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 90 /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-1GNU core utilities
ii  debianutils 3.4  Miscellaneous utilities specific t
ii  libc6   2.11.2-10Embedded GNU C Library: Shared lib
ii  lsb-base3.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




umountfs.patch
Description: Binary data