Squashfs
Jump to navigation
Jump to search
Various notes on manipulating squashfs image files.
Unpack
- Copy squashfs file to working directory
- Run the following command to unpack:
unsquashfs <image>
Pack/Re-Pack
- Go to root directory where top level directory of the files you want to pack are located at
- Run the following command to pack/re-pack:
mksquashfs <squashfs-root-dir> <filename-of-squashfs-image> -b 1024k -comp xz -Xbcj x86
Using overlayfs
If your system supports some union-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.