How to mount image created with dd

mount

I used 'dd' to create an image of my hard drive as a file on another
drive. Question: how do I mount this image to see that it's valid? Notes:

  • "file image" yields (all one line, I just broke it up for readability):

file maindisk.image.out


maindisk.image.out: x86 boot sector, LInux i386 boot LOader; GRand Unified Bootloader,
stage1 version 0x3, boot drive 0x80, 1st sector stage2 0x44841, GRUB version 0.94;
partition 1: ID=0x83, active, starthead 1, startsector 63, 409600 sectors; partition 2:
ID=0x8e, starthead 127, startsector 409663, 312167042 sectors, code offset 0x48
  • The obvious mount command (as root) fails:

# mount -o loop -t ext3 maindisk.image.out /mnt/loop/ 

mount: wrong fs type, bad option, bad superblock on /dev/loop0, 
       missing codepage or helper program, or other error 
       In some cases useful info is found in syslog - try 
       dmesg | tail  or so

# dmesg | tail -1

# VFS: Can't find ext3 filesystem on dev loop0. 
  • The thing that I dd'd was /dev/sda, a block device. According to file (again, all on one line, no backslashes):
 
# cat /dev/sda | file - 

/dev/stdin: x86 boot sector, LInux i386 boot LOader; GRand Unified Bootloader, \
stage1 version 0x3, boot drive 0x80, 1st sector stage2 0x44841, GRUB version 0.\
94; partition 1: ID=0x83, active, starthead 1, startsector 63, 409600 sectors; \
partition 2: ID=0x8e, starthead 127, startsector 409663, 312167042 sectors, cod\
e offset 0x48 
  • According to "mount", here's how I have /dev/sda mounted:

/dev/mapper/VolGroup-lv_root on / type ext4 (rw) 
/dev/sda1 on /boot type ext3 (rw) 
  • Did I back up the wrong thing? Should I have backed up /dev/sda1
    instead? Is my system doing some sort of volume management that's
    making this image mount difficult?

Best Answer

Based on Mounting a raw partition file made with dd or dd_rescue in Linux.

See that startsector 63 in file's output? It means there is an offset of 63 sectors * 512 bytes/sector = 32256 bytes from the beginning of the disk.

Try:

mount -o loop,offset=32256 -t ext3 maindisk.image.out /mnt/loop/ 
Related Question