I have an Ubuntu installation backed up as a .squashfs file. I would like to extract it to the root of a partition, but when I try gives me an error saying the directory exists. I can extract just fine to non-existent directories. I've searched for information about using squashfs-tools, but can't find what commands would be used to extract to an existing location such as an empty partition.

This is the command I'm using that works for extracting to non-existent locations:

sudo unsquashfs -d /media/location1/locationthatdoesntexist /media/location2/file.squashfs

I tried using this to extract to an empty partition,but it doesn't work:

sudo unsquashfs -d /media/location1 /media/location2/file.squashfs


2 Answers 2


The source you link to tells you what you need to do:

The tool does not extract a squashed file system on already exsisting directory unless the -f option is specified.

So this should work

sudo unsquashfs -f -d /media/location1 /media/location2/file.squashfs
  1. Mount the squashfs FILE.SQUASHFS :

    sudo mount -t squashfs PATH/TO/FILE.SQUASHFS /mnt
  2. Copy his content to DIRECTORY (must exist) :

    sudo cp -av /mnt/. PATH/TO/DIRECTORY
  3. Unmount the squashfs FILE.SQUASHFS :

    sudo umount /mnt

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .