11

I have a DD image taken from the raw HDD image (/dev/sdb). This image file contains an XFS filesystem that I need to mount. It is much too large to restore to disks (2.6TB img file) so I would like to mount it using loopback.

However, the partition table becomes a problem. I tried to determine the partitions offset using both parted and fdisk -lu. Parted returns "unrecognized disk label", fdisk -lu shows me a blank partition table.

How would you recommend finding the partition start so that I can mount it with -o loop

coderego
  • 175
  • 2
  • 8
  • sfidsk does not show me the partition table. "No partitions found" I used head -c 15000 sdb.img in order to see what I was looking at. I then did some researcha nd saw that it is a LVM volumegroup meta data. Contains things like dev_size, pe_start, pe_count. etc – coderego Apr 18 '11 at 19:42
  • how are you using those tools? – Keith Apr 18 '11 at 20:05
  • I am using the tools through bash with sudo. – coderego Apr 18 '11 at 21:04

5 Answers5

6

The kpartx command will do all the work for you of detecting where the partitions exist and setting up loop devices with the appropriate offsets.

# kpartx -l /dev/ganderData/example-sysdisk
ganderData-example--sysdisk-1 : 0 497952 /dev/ganderData/example-sysdisk 63
ganderData-example--sysdisk-2 : 0 62412525 /dev/ganderData/example-sysdisk 498015

# kpartx -a /dev/ganderData/example-sysdisk
# mount /dev/mapper/ganderData-example--sysdisk-2 /mnt/tmp
MikeyB
  • 39,291
  • 10
  • 105
  • 189
3

See if testdisk can find your partition labels. You can try and see if kpartx can find and enable it first:

# kpartx -a -v image

Also remember to try those two things on a copy of the image. You don't want to destroy your backup image with tests.

coredump
  • 12,713
  • 2
  • 36
  • 56
1

You can use sfdisk to dump the partition table of the image. Pretty well any of the *fdisk variants will do so, but some complain more than others. This will enable you to calculate the offset of the partition.

BillThor
  • 27,737
  • 3
  • 37
  • 69
0

Run file - </dev/sdb to see what you actually have on the disk, since it doesn't seem to be an image of a disk with a PC partition system.

Given your comment, you probably have an LVM physical volume. So first associate a block device to it with losetup, then register the loop device as a physical volume and go on from there.

losetup -fv /path/to/image/file
pvs  # will show /dev/loop99 (for some value of 99) as a physical volume
vgs  # will show the VG(s) on /dev/loop99
lvs  # will show the LV(s) on the VG(s) on /dev/loop99
mount /dev/mapper/groupname-volumename /mnt
…
vgchange -an groupname
losetup -u /dev/loop99
0

kpartx was mentioned twice and you should use it! This post will give you some pratice with kpartx &Co.: Can I "atomically" swap a raid5 drive in Linux software raid?

ThorstenS
  • 3,122
  • 19
  • 21