Jump to content

SD card partition recovery: Difference between revisions

From Costa's Wiki
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..."
 
No edit summary
 
Line 19: Line 19:


Mount the partition in the disk image (optional)
Mount the partition in the disk image (optional)
  mount /dev/loop0 /mnt
  mount /dev/loop0 /mnt/image
 
Also possible as
  mount -oloop,offset=32256 sdb.img /mnt/image


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

Latest revision as of 19:17, 23 June 2024

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/image

Also possible as

 mount -oloop,offset=32256 sdb.img /mnt/image

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