Mounting a squashfs filesystem in read-write
As root, copy filesystem.squashfs
to some empty dir, e.g.:
cp /mnt/clonezilla/live/filesystem.squashfs /path/to/workdir
cd /path/to/workdir
Unpack the file then move it somewhere else (so you still have it as a backup):
unsquashfs filesystem.squashfs
mv filesystem.squashfs /path/to/backup/
Go in squashfs-root
, add/modify as per your taste then recreate filesystem.squashfs
:
cd /path/to/workdir
mksquashfs squashfs-root filesystem.squashfs -b 1024k -comp xz -Xbcj x86 -e boot
copy the newly created filesystem.squashfs
over the existing one on your USB drive, e.g.:
cp filesystem.squashfs /mnt/clonezilla/live/
then reboot and use your LIVE USB.
Note: the above commands are part of squashfs-tools
.
If your system supports some uion-filesystem, such as aufs or overlayfs, you don't have to extract your original squashfs file.
For example the overlayfs is used( a kernel option to enable it): You can mount your squashfs.file to /fm or somewhere else first. Prepare a writable filesystem with 2 directories in it, say /to and /temp. prepare another writable directory /fin for the merged results. Mount them together as an overlayfs to your system ---
mount -t overlay -o lowerdir=/fm,upperdir=/to,workdir=/temp overlay /fin
Now you can add/modify files in /fin. Once everything done, you can mksquashfs /fin to a new squashfs file,
mksquashfs /fin newfile; umount /fin
, then clear/unmount all the other used directories as you will.
The squashfs and some unionfs are commonly used for a live-cd.
Here, I found an other answer:
bash# mount dir.sqsh /mnt/dir -t squashfs -o loop