I'm trying to setup a Linux system that runs from an LVM-formatted image file. After some tinkering with the initramfs and boot options I managed to make it up and running by mounting the host file system to /run/initramfs/host, losetuping the image to /dev/loop0 and making sure the kernel and udev detect the LVM (and the root LV) in there. So far so good.The problem is that when shutting down (or rebooting, or ) the system neither the  root file system nor the host are unmounted properly, because of a chicken-and-egg scenario: the root (or /oldroot, as it's referred to by the shutdown script) cannot be unmounted, because /oldroot/run/initramfs/host is still mounted, and the host cannot be unmounted, because doing so would make /oldroot inaccessible.Unclean shutdowns aren't the end of the world, because both file systems are journaled, so during the next boot fsck simply replays the journals, but obviously clean shutdowns would be better.So the question is: is it somehow possible to arrange the shutdown sequence (I can modify the shutdown script), or the bootup sequence (perhaps by moving the host mount point to a different place) so that both file systems can be cleanly unmounted?
Ensure that loopback root and host are unmounted on shutdown
linux;shutdown;loop device;root filesystem;unmounting
In case somebody has the same problem:All I needed was to move the mount point of the host file system to a place outside the root file system in the shutdown script (that's fine, because it runs in a tmpfs pivot root) before any unmounting takes place:mount --move /oldroot/run/initramfs/host /hostThis allows /oldroot to unmount cleanly. The host file system can be then unmounted with a simpleumount /host