Here I'm trying to create a squashfs filesystem but the resulting image is bigger than the original version and not because I added a file or anything as I only modified some configuration files.
What I'm trying to do is modify the existing squashfs filesystem on a live usb and delete some info to start the OS in a login shell. Since I fixed an amount of space to the EXT4 partition I need the modified squashf to have the same size as the original. I can do the changes while the live system is running but since I'm making a script to automate this process I need to do it before creating the live usb itself. The problem comes when recreating the image as the resulting file is about 400mb larger than the original and when I use the -b 4096/1Mbyte option the image is about 800mb larger when the original file is about 2.2gb.
I did the same before to add my script to the filesystem and it worked great but now I can't understand what happen this time. I searched my backup of .bash_history but with no luck
How can I reduce the image size?? What I'm doing wrong, anyone??
# Create Directories mkdir /mnt/kali-iso mkdir /mnt/squash mkdir /tmp/squash_mod # Mount ISO And Squashfs Image mount /root/kali.iso /mnt/kali-iso mount /mnt/kali-iso/live/filesystem.squashfs /mnt/squash -o loop # Copy All Files To A Temp Directory To Modify Them cp -rf /mnt/squash/* /tmp/squash_mod cp /root/foo.sh /tmp/squash_mod/root/Desktop/ # Create Squashfs mksquashfs /tmp/squash_mod filesystem.squashfs
# mksquashfs /tmp/squash_mod filesystem.squashfs -b 4096 # or 1Mbyte
Results from "du" command:
du -ch /mnt/squash | grep "total" = 6.6G total du -ch /tmp/squash_mod | grep "total" = 7.2G total
There are some discrepancies between the same folders, their size are different:
"/tmp/squash_mod/sbin = 8.8mb" "/mnt/squash/sbin = 8.5mb"
"/tmp/squash_mod/var = 309mb" "/mnt/squash/var = 282mb"
"/tmp/squash_mod/bin = 7.0mb" "/mnt/squash/bin = 6.8mb"