[Lxc-users] Rootfs as rw overlay on top of ro directory

Ivan Vilata i Balaguer ivan at selidor.net
Fri Jun 14 08:30:33 UTC 2013


Ivan Vilata i Balaguer (2013-06-13 16:36:49 +0200) wrote:

> Serge Hallyn (2013-06-11 17:11:47 +0200) wrote:
>
>> The pre-start and post-stop routines run in the monitor's namespace.
>> The pre-mount routine runs in the container's namespace.  You might
>> try moving the pre-mount stuff all into pre-start instead, and
>> umounting them (-l) in the post-stop.  My guess is that the aufs is
>> not being umounted for one reason or another.
>
> I moved everything to pre-start and post-stop and the result is the
> same, i.e. ``overlay.ext4`` is badly unmounted (needs journal
> recovery) and the overlay loop device cannot be detached.  It looks
> like something doesn't get cleaned up and may be holding the overlay
> file in use, but I don't know where and how to look for it.  I tried
> reenabling the ``umountfs`` and ``umountroot`` init scripts in the
> container (Debian) just in case but nothing changed.

> For ``lxc.hook.pre-start`` and ``lxc.hook.post-stop`` version:
>
>     #!/bin/sh
>     LXC_DIR=$(dirname "$LXC_ROOTFS_PATH")
>
>     ACTION="$3"
>     case "$ACTION" in
>       (pre-start)
>         mount -t squashfs -o ro "$LXC_DIR/template.squashfs"
>         "$LXC_DIR/template"
>         mount -t ext4 "$LXC_DIR/overlay.ext4" "$LXC_DIR/overlay"
>         mount -t overlayfs -o "lowerdir=$LXC_DIR/template,upperdir=$LXC_DIR/overlay" sliver "$LXC_ROOTFS_PATH" \
>         || mount -t aufs -o "br=$LXC_DIR/overlay:$LXC_DIR/template" sliver
>         "$LXC_ROOTFS_PATH"
>         ;;
>       (post-stop)
>         umount -l "$LXC_ROOTFS_PATH"
>         umount -l "$LXC_DIR/overlay"
>         umount -l "$LXC_DIR/template"
>         ;;
>       (*)
>         echo "Invalid action: $ACTION" > /dev/null
>         exit 1
>         ;;
>     esac

For the curiosity, I also tried to setup myself the ``rootfs`` directory
running the commands from this script directly at the host before
running ``lxc-start`` but the problem stays the same.  Not surprising
anyway since I'd bet this is mostly identical to using the pre-start and
post-stop hooks.

Any guru with an idea on how to find who's using the filesystem images
and loop devices?  fuser and lsof show nothing about them...

Cheers,

-- 
Ivan Vilata i Balaguer -- https://elvil.net/





More information about the lxc-users mailing list