Append to sub-directory inside squashfs file
Of course ;it is possible to append directory or file to a squashfs_file.
One has to understand the way mksquashfs works : Roughly speaking it is incrementally adding compression blocks of data in similar way as growisofs writes to dvd ; and at the end update the TOC ,kind of table contents of the image. You cannot "clear" the old directory of course, because incremental writing only cares about future and not the past !!!!
But there is a very simple way of modifying a squashfs file without unsquashfs the whole image ( which could take a lot of space on ram or storage device ... think of dvd_iso 3-5 GB image ! ). The guiding idea works like this :
1 mount squashfs_file /mnt ( mounting is far less using storage than unsquashfs )
2 Re build squashfs_file by excluding the directory to modify then append the new directory we want.
Details ex:
cp /mnt/specific_dir $home ##modify $home/specific_dir as needed
mksquashfs /mnt new_squashfs_file -wildcards -e specific_dir
mksquashfs $home/specific_dir new_squashfs_file -keep-as-directory
umount /mnt # cleanup
of course all other options for mksquashfs can be added as ususal (block size;compression scheme ....-b 1048576 -comp xz ....)
The example show one directory modification for clarification purpose ; but on a rootfs you can exclude etc usr ....then append the modified etc usr in 2nd line append mechanism .
This is the way to go if you need to remaster a whole livecd ubuntu on a 4GB ram "windows10 laptop" without any touching on ntfs original partition .
HopeThatHelp, wangji.
Related videos on Youtube
2i3r
Updated on September 18, 2022Comments
-
2i3r over 1 year
Suppose we have
filesystem.squashfs
, we can append to it by:mksquashfs somefile filesystem.squashfs
which appends
somefile
to root of squashfs file. appending directory:mksquashfs somedir/ filesystem.squashfs
would append files and directories inside
somedir/
to the root of squashfs file. and if a directory or file exist in the tree of squashfs thenmksquashfs
would rename new files, not changing old files and directories. well it make sense the phrase of "append".I'm aware of
unsquashfs
which decompress the squashfs, but I'm curious if perhaps there is a way to add a new file or directory to existing sub-directory inside squashfs tree without decompressing?-
Admin almost 7 yearsHave you found any solution to this?
-