I have an old filesystem backup that I made and compressed into a squashfs. It was stored on an ext4 filesystem, and I suspect it suffered from some bitrot. I don't have a backup of the file. Is there any way I might be able to rescue this squashfs archive?
$ unsquashfs olddrive.sfs Can't find a SQUASHFS superblock on olddrive.sfs
Edit: Adding Info
$ file olddrive.sfs olddrive.sfs: data $ sudo mount -t squashfs -o ro olddrive.sfs /tmp/sq mount: /tmp/sq: wrong fs type, bad option, bad superblock on /dev/loop10, missing codepage or helper program, or other error.
Edit: Interestingly, running hexdump on the file shows that it starts entirely with zero's. Perhaps reading the file from disk had some bad sectors, and they were replaced with zero's?
0000000 0000 0000 0000 0000 0000 0000 0000 0000 * 0000060 8008 0000 0010 0008 0000 37fd 587a 005a 0000070 0100 2269 36de c003 ffa5 8003 4080 0121 0000080 0010 e48c b888 59ef efe8 5dfe 7500 0d80 0000090 8c81 25e2 b847 a0cc 766a b649 c919 3768
I tried copying (overwriting) several bytes from the head another good squashfs to the corrupted one, but with no luck. It appears I had 96 zero'd bytes at the head of my corrupted squashfs. There seems to be no redundant data for the superblock, and therefore if it is destroyed, then the archive is lost. If there were only a couple bytes damaged, then the solution by user K-att- may have fixed the problem.
For anyone wishing to prevent such damage/loss, I recommend using
par2 (Parchive). I did not know about
par2 previously, but it can create a small file that is capable of recovering from minimally damaged files (when drive sectors go bad)