The operating system image in a Fedora LiveCD or LiveUSB can be mounted after exposing the embedded root filesystem. Fedora's livecd-tools package provides a utility liveimage-mount that does this using Python.
The Fedora LiveOS image (Live CD/USB operating system) technology uses the Device-mapper snapshot target to make a compressed, read-only copy of the root filesystem available for read-write mounting at boot time, where filesystem writes go into a temporary or persistent copy-on-write overlay. Everything is accomplished with the dmsetup
command. LVM is not involved (although it also uses Device-mapper technology).
A LiveOS installed device will have a /LiveOS/ directory in it's base filesystem. The /LiveOS/squashfs.img file contains a compressed (and read-only) ext4 filesystem that itself contains a /LiveOS/ directory and within that the distributed root filesystem in a file named ext3fs.img. So, the squashfs.img file contains a directory and file, /LiveOS/ext3fs.img, that itself contains the root filesystem (with /bin, /boot, /dev, /etc, /home, ...).
If there is a persistent overlay file installed on the device, it will be saved as
/LiveOS/overlay-<LABEL>-<UUID>
where LABEL and UUID are the device partition label and UUID as reported by the following command,
lsblk -o LABEL,UUID
One can programmatically
- loop mount the squashfs.img file, then
- set up a loop device for the ext3fs.img file found in mount 1.
- If there is no persistent overlay, you may simply mount the ext3fs.img file or loop device from
step 2 (the read-only, base image).
- If there is a persistent overlay file, set up a loop device for it.
Determine the size of the root filesystem in units of 512-byte sectors,
blockdev --getsz <basefs_loop>
Then setup a Device-mapper snapshot target with this general command,
dmsetup create <target_name> --table "0 <size> snapshot <basefs_loop> <overlay_loop> P 8"
Finally, mount the Device-mapper target on a desired mount point,
mount /dev/mapper/<target_name> <mount point>