Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Obviously I don't want to actually modify a squashfs. What I would like to do though is take an existing squashfs, a set of files and create a new squashfs which is identical to the old one except that the files in the set either replace similar files in the squasfs or are just added if there is no similar files.

Ok that last part sounded wierd. So let me give an example:

there is a squashfs called mfs.squash. Inside it there is a file ./a/foo. I want to crewate a new squashfs which is identical to the old squashfs -- except that there is a new file a/b and I overwrite the ./a/foo with one of my specification.

share|improve this question

Mount the squashfs:

mkdir /mnt/squishy
mount mfs.sqash /mnt/squishy -t squashfs -o loop

Copy the squashfs to another place:

mkdir /tmp/squooshtacular
find /mnt/squishy -xdev -print0 | cpio -pa0V /tmp/squooshtacular

Copy the new files into place:

cp ./a.foo /tmp/squooshtacular/a.foo

Make the new squashfs:

mksquashfs /tmp/squooshtacular mfs_with_bbq_sauce.squash
share|improve this answer
I think this should read: find /mnt/squishy -xdev -print0 | cpio -pd0V /tmp/squooshtacular – fpmurphy1 Jun 30 '11 at 22:15
@fpmurphy Why? -d isn't necessary since find is producing all the directory names, and there's no reason to remove -a. – Gilles Jun 30 '11 at 23:46
Did not work for me without the -d option – fpmurphy1 Jul 1 '11 at 2:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.