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
, losetup
ing 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?
losetup
underlvm
? Lvm usedmsetup
wich is a kind of more featured losetup. – F. Hauri Jan 13 '13 at 16:55mount --move
– F. Hauri Jan 13 '13 at 16:57losetup
, because it's the first thing I thought of that turns a file into a block device. Also, the chicken-and-egg problem at hand is not really related to LVM, is it? – user30223 Jan 13 '13 at 17:42