changed 3 years ago
Linked with GitHub

Squashfs as alternative archive format

https://github.com/plougher/squashfs-tools

General advantages

  • single compressed file that could be mounted transparently with squashfuse i.e. any program can access (read-only) the files directly.
  • duplicate files are detected and stored efficiently.

Create squashfs

https://techoverflow.net/2013/01/11/creating-a-highly-compressed-squashfs-from-a-folder/

$ mksquashfs [source_folder] [SquashFS_target_file] -b 1048576 -comp xz -Xdict-size 100%

Example:

$ mksquashfs _del /tmp/test.squash -b 1048576 -comp xz -Xdict-size 100%

Parallel mksquashfs: Using 16 processors
Creating 4.0 filesystem on /tmp/test.squash, block size 1048576.
[====================================================================================================================================\] 742/742 100%

Exportable Squashfs 4.0 filesystem, xz compressed, data block size 1048576
        compressed data, compressed metadata, compressed fragments,
        compressed xattrs, compressed ids
        duplicates are removed
Filesystem size 95387.81 Kbytes (93.15 Mbytes)
        65.34% of uncompressed filesystem size (145980.43 Kbytes)
Inode table size 6348 bytes (6.20 Kbytes)
        24.90% of uncompressed inode table size (25493 bytes)
Directory table size 7446 bytes (7.27 Kbytes)
        40.26% of uncompressed directory table size (18493 bytes)
Number of duplicate files found 125
Number of inodes 764
Number of files 655
Number of fragments 46
Number of symbolic links  7
Number of device nodes 0
Number of fifo nodes 0
Number of socket nodes 0
Number of directories 102
Number of ids (unique uids + gids) 1
Number of uids 1
        user (1000)
Number of gids 1
        user (1000)

Comparison with other compressing tools. Data contains variety of data and the results might be biased i.e. it will depend on the data type.

# Check the space of the folder
$ du -h -d 0 _del
145M    _del

# zip the folder for comparisson
$ zip -r -9 /tmp/test.zip _del
...

# tar the folder for comparisson
$ tar -cvjf /tmp/test.tgz _del

# Compare the file size
$ ls -lh /tmp/test.squash 
-rw-r--r-- 1 user user  94M Jun 10 14:00 /tmp/test.squash
-rw-rw-r-- 1 user user  99M Jun 10 14:05 /tmp/test.tgz
-rw-rw-r-- 1 user user 102M Jun 10 14:03 /tmp/test.zip

Accessing the files in the archive

# create empty folder to moun the archive
$ mkdir squash-mount

# mount the archive
$ squashfuse /tmp/test.squash squash-mount

# access the content of the mounted archive and the original folder...
$ ls -l squash-mount/click/click/
-rw-rw-r-- 1 user user 794 Jan  3 13:21 meta.yaml

$ ls -l _del/click/click/
-rw-rw-r-- 1 user user 794 Jan  3 13:21 meta.yaml

# unmount the archive
$ umount squash-mount

Contacts:


tags: UPPMAX, SNIC
Select a repo