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
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
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?