How to write/make changes to an existing squashfs filesystem

  • 19th day of Aftermath, in the yold 3182
  • 2 Comments

Most LiveCD distributions (Debian, Ubuntu, Fedora, Mint, etc) contain a filesystem.squashfs file, which is a container with a squeeze file system that is unzipped and loaded when the LiveCD boots. The following will describe how to add/remove and edit files in such a container.

To update the contents of squashfs you must install the squashfs-tools package; most popular Linux distributions have this package. Then go to the directory where filesystem.squashfs is located and log into a super-user session:

cd ~/work_dir
su

and unpack the container:

unsquashfs filesystem.squashfs

And immediately afterwards delete or move the original file to another folder:

mv filesystem.squashfs ~/backup/

After unpacking, a directory squashfs-root will appear in the folder where the original container was located – modify it as you need to: add, remove, edit its contents.

When all necessary changes have been made, you can recreate the updated squashfs-container file:

mksquashfs squashfs-root filesystem.squashfs -b 1024k -comp xz -Xbcj x86 -e boot

This will take a while, but it should give you an updated filesystem.squashfs. If you want to add this to an existing iso image, you can do so with the handy isomaster gui tool.

It is important to do all these commands as root. If done as a normal user, squashfs will rebuild, but the su and sudo programs may not work on the live system as a result.

  1. opendx says:

    the main question not addressed here – how to insert this updated file into bootable .iso file from which it was taken?

Leave a Comment to opendx

Your email address will not be published. Required fields are marked *