5

I enjoy using squashfs for compression because of the simplicity of mounting them as loop devices to access the files inside.

I have a lot of rar, tgz and zip files that I would like to convert to squashfs.

In this answer, I saw that it is possible to use a pseudo file when compressing a disk image to squashfs to avoid having to use a temporary file the size of the whole disk.

mkdir empty-dir mksquashfs empty-dir squash.img -p 'sda_backup.img f 444 root root dd if=/dev/sda bs=4M' 

I would like to use pseudo files to convert from rar, tgz or zip to squashfs in the same way (on the fly), so I don't have to first extract the whole archive to disk and then compress to squashfs in a separate operation.

Some of these archives contain thousands of individual files, some of which will have spaces or other special characters in their filenames.

I looked at the README, and I think I would need to use the -pf <pseudo-file> option, but I'm not sure how to create the pseudo file on the fly (and also not have problems with filenames with spaces). I think I would need to use process substitution to create the list of files from the source archive.

Ideally I would like to have a command that is able to convert any rar, tgz or zip without having to individually create the pseudo file for each archive, but if anyone can tell me how I can do it with one of those archive formats, then hopefully I can work it out for the others.

Thanks everyone.

2 Answers 2

6

You could mount them with fuse-zip or archivemount and then create the squashfs file from the mount point.

For example, this would work for a zip file:

$ mkdir /tmp/zmnt $ fuse-zip -r /path/to/file1.zip /tmp/zmnt $ mksquashfs /tmp/zmnt /path/to/file1.squashfs $ fusermount -u /tmp/zmnt 
0

There is tar2sqfs from https://github.com/AgentD/squashfs-tools-ng/

Might at least be an alternative worth investigating.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.