Welcome to Deadman.org.


Creative Commons License

Tuesday Apr 26 11:24am 2005
by Deadman

This post is mostly a reminder to myself. If you ever dd a whole disk to a file and you need to loopback mount an individual partition from that file, here's how:

  • sfdisk -l -uS myimg.img
    • Disk myimg.img: cannot get geometry
      
      Disk myimg.img: 0 cylinders, 0 heads, 0 sectors/track
      Warning: The partition table looks like it was made
        for C/H/S=*/64/63 (instead of 0/0/0).
      For this listing I'll assume that geometry.
      Units = sectors of 512 bytes, counting from 0
      
         Device Boot    Start       End   #sectors  Id  System
      myimg.img1   *        63   3515903    3515841  83  Linux
      myimg.img2       3515904   4124735     608832  82  Linux swap / Solaris
      myimg.img3             0         -          0   0  Empty
      myimg.img4             0         -          0   0  Empty
      
  • Since "End" is the end point, not a count point, subtract the Start from the end:
    echo 3515903 - 63 | bc
    • 3515840
  • create a file with just the partition you want:
    dd if=myimg.img of=part1.img bs=512 skip=63 count=3515840
  • mount -o loop /path/to/part1.img /mnt
Home

© 2009 Sam Rowe. Some rights reserved.
RSS headlines