[Pkg-sysvinit-devel] Bug#655582: initscripts: incorrect rootfs unmount logic causes dirty FS at every boot

Roger Leigh rleigh at codelibre.net
Sat Jan 21 11:28:28 UTC 2012


On Thu, Jan 12, 2012 at 03:42:16PM +0100, Michele Mazzucchi wrote:
> ========================
> 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="$(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.





More information about the Pkg-sysvinit-devel mailing list