1

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

Conclusion:

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)

1
  • Oh dear. Neither unsquashfs, file nor the squashfs filesystem driver did recognize a squashfs filesystem in that file, so unfortunately it looks like your bitrot theory is proven, and the rot may have hit the vital parts.
    – telcoM
    Aug 9 at 14:11
1

Try to check the file with any hex editor. (hexedit for example) You can try to change the 1st four bytes to 0x73717368 ( 68 73 71 73 -> hsqs). (Backup the file of course.) https://dr-emann.github.io/squashfs/ Which version of squashfs you use?

1
  • Thanks for the suggestion. I added hexdump information to my post.
    – Rucent88
    Aug 12 at 23:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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