Skip to content

Instantly share code, notes, and snippets.

@oktayacikalin
Created May 28, 2015 06:38
Show Gist options
  • Save oktayacikalin/395f351d6262ce560733 to your computer and use it in GitHub Desktop.
Save oktayacikalin/395f351d6262ce560733 to your computer and use it in GitHub Desktop.
How to mount a partition inside a disk image
http://ubuntuforums.org/archive/index.php/t-1576011.html
---
To mount a partition inside the disk image you need to calculate the offset of where the partition starts.
parted picked.img
GNU Parted 2.3
Using picked.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit
Unit? [compact]? B
(parted) print
The output should look something like:
Model: ATA ST3160815AS (scsi)
Disk /dev/sda: 160041885696B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32256B 10733990399B 10733958144B primary ext4
2 10733990400B 21500881919B 10766891520B primary ext3
3 21500881920B 158961761279B 137460879360B primary ext4
4 158961761280B 160039272959B 1077511680B primary linux-swap(v1)
type q to exit from parted.
Now to mount a partition, you have to run something like:
sudo mount -o loop,offset=32256 picked.img mount/point
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment