7

I've created an image of my hd with dd, but grub was installed on it, and I'm trying to figure out how to mount the image file, but mount doesn't recognise it as an ext4 partition because of the grub header.

I know it's there because when I run file -k disk.img, I get the following:

disk.img: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, 1st sector stage2 0x3a883d7, code offset 0x48\012- Linux rev 1.0 ext4 filesystem data, UUID=6d1e45d1-8fac-4995-839b-fa5691a898ad (needs journal recovery) (errors) (extents) (large files) DOS executable (COM), boot code

Anyone have any thoughts as to how I could find the beginning of the partition so that I can tell mount (well, losetup really) where the offset is to load the partition?

3
  • what does file -s disk.img give?
    – Stefan
    Commented Oct 11, 2010 at 10:41
  • Basically the same thing, but doesn't indicate anything about the ext4 partition. disk.img: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, 1st sector stage2 0x3a883d7, code offset 0x48\012- Commented Oct 11, 2010 at 11:23
  • MY GREAT SOLUTION TO SAVE YOUR /DATA PARTITION FILES: dropbox.com/s/v0lfolrvgxwgbnx/Instruction.txt?dl=0
    – user134066
    Commented Sep 20, 2015 at 18:03

2 Answers 2

8

Parted should be able to read disk image from file and interpret the partition table. So use

parted -s disk.img unit s print

For my (testing) disk image it gives:

# parted -s /root/sdd.img unit s print
Model:  (file)
Disk /root/sdd.img: 16384s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End     Size   Type     File system  Flags
 1      5s     7812s   7808s  primary               type=83
 2      7872s  16383s  8512s  primary               type=83

You can see which sector each partition starts (and ends) at.

1
  • 2
    Also sfdisk -uB -l will print out that info, but using 1024-byte blocks, which can make it easier to compute offsets. Commented Oct 11, 2010 at 12:38
1

I found out the problem wasn't related to grub at all. The image had errors in it, and the fix involved running e2fsck.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .