HDD drive (EXT4 format reported as GPT table?) is showing empty but has data on it. GPT reports healthy table. fsck fixed errors. tried to copy some superblocks, bad magic. what else?
I am in linux. I have an ext4 disk. It is not in good state generally. It had a lot of data. Now, it shows nothing.
gdisk reports Found valid GPT with protective MBR; using GPT.
fsck fixed errors but no data appeared (fsck /dev/xxx).
superblocks ae reported in default positions eg. 32768, 98304, 163840 etc. Tried e2fsck -b 'some superblock' /dev/xxx but reported bad magic number.
copied gpt table
label: gpt
label-id: DE9B1C2A-E6F4-4A92-A79D-0C76A00E573E
device: /dev/sdb
unit: sectors
first-lba: 34
last-lba: 9767475166
sector-size: 512
/dev/sdb1 : start= 2048, size= 9767471104, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=FE70C7A4-21A7-42CD-B8CB-7036176484FA, name="HDD_XXX_00"
sudo e2fsck /dev/sdb
e2fsck 1.47.0 (5-Feb-2023)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/sdb
What I must do except to dd copy the entire disk as image? What i must do in order to recover my data?
I found that in some cases, magic number may have been moved to other hex address here. How can i find the magic address using a hex editor?
"I also had some luck recently using a hex editor to search for the magic number (ext4 = 0xEF53) that indicates the start of a superblock then using that sector offset as an alternate when mounting. This was in a strange location because something or one had changed the partition layout."
UPDATE: I try to get the hex address of magic number see here. I dont know if i succeed or how many hours it will take.
# get magic number
#with od
sudo od -x /dev/sdb1 | awk '$6 == "ef53"'
#with hexdump
dd if=/dev/sdb1 bs=4k count=4k |hexdump -C |head -n1000
# with hd
hd /dev/sdd1 | grep " [0-9a-f][0-9a-f] 53 ef" | sed -e 's/^/ /' | head
UPDATE 2 Sadly, the above hex commands stop when they encounter input/output errors. How I make them to escape input/output errors and continue to search the disk?
UPDATE 3 - link posted in answer is generic - why? : The link explains how to use ddrescue and other programs to save image of drives and save individual files. This is not the case here as explicity stated that i want to repair the partition and exploring how to fix magic numbers and superblocks. The link has very generic answers that do not cover me. I have found them around the net. I know most of these tools.
Important - Except copying superblocks from other positions, I have read many users that this was unsuccesful. No one was answering how to recover superblocks and do low level things. I found one to copy partial information from one superblock to other and made a whole good superblock. I am searching for such information. However, no information was included how he did it.
In a failing drive, you like to do minimal operations. Most tools weirdingly do not have any option to skip input/output errors. This is a huge BUG for all related tools for rescue / repair.
What I think i need? A tool to find possible superblocks in weird positions and fix them without taking into consideration input/output errors. A tool that can extract partial information from each bad superblock and make a healthy superblock. A tool that will display which parts of superblocks are unreadable. None of these exists.
Plated disks are very unreliable for long time of continue operation - 80% of them are failing in 1st year. SSD very expensive for large TBs and are unreliable for long term backups. So i have not an ideal backup solution, cheap and for many TBs.