Jump to content

SD card partition recovery

From Costa's Wiki
Revision as of 19:14, 23 June 2024 by 10.0.0.200 (talk) (Created page with "Create an image of /dev/sdb called sdb.img dd if=/dev/sdb of=sdb.img Mount the dd disk image Establish sector size. Establish where the partition starts fdisk -l sdb.img...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Create an image of /dev/sdb called sdb.img

dd if=/dev/sdb of=sdb.img

Mount the dd disk image

Establish sector size. Establish where the partition starts

fdisk -l sdb.img

Calculate the offset

startsector*sectorsize
63*512=32256

Mount the disk image

losetup --offset 32256 /dev/loop0 sdb.img

Fix the partition in the disk image Use the appropriate version of fsck and switches

e.g.  fsck.reiserfs --fix-fixable /dev/loop0

Mount the partition in the disk image (optional)

mount /dev/loop0 /mnt

Restore the disk image to a new physical drive (ensure it is unused and not mounted) Unmount the partition, if mounted

umount /mnt

Unmount the disk image

losetup -d /dev/loop0

Restore the fsck'd disk image

dd if=sdb.img of=/dev/sdb