4

After re-installing a Linux machine, I inadvertently ran wipefs -a on the installer pendrive:

$ wipefs -a /dev/sd? /dev/sda: 8 bytes were erased at offset 0x00010040 (btrfs): 5f 42 48 52 66 53 5f 4d /dev/sdb: 8 bytes were erased at offset 0x00010040 (btrfs): 5f 42 48 52 66 53 5f 4d ... /dev/sdw: 8 bytes were erased at offset 0x00010040 (btrfs): 5f 42 48 52 66 53 5f 4d /dev/sdx: 8 bytes were erased at offset 0x00010040 (btrfs): 5f 42 48 52 66 53 5f 4d /dev/sdy: 5 bytes were erased at offset 0x00008001 (iso9660): 43 44 30 30 31 /dev/sdy: 2 bytes were erased at offset 0x000001fe (dos): 55 aa /dev/sdy: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54 /dev/sdy: calling ioctl to re-read partition table: Success 

As wipefs output contains the offset and the content of the deleted bytes, it seems possible to restore /dev/sdy. How would you do it?

1 Answer 1

6

First off, make a copy of the affected area of /dev/sdy before touching it again:

dd if=/dev/sdy bs=65536 count=1 of=sdy.back 

Then, to restore the original data:

printf '\x55\xaa\x45\x46\x49\x20\x50\x41\x52\x54' | dd bs=1 seek=$((16#1fe)) of=/dev/sdy printf '\x43\x44\x30\x30\x31' | dd bs=1 seek=$((16#8001)) of=/dev/sdy 

(adding sudo before dd if necessary). 0x200 immediately follows two bytes at 0x1FE, so the ten bytes can be written in one step.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.