How to mount ".img" file with multiple partitions;
1. First, check partition table of the image by using fdisk;
[root@Linux]# ls Ubuntu.img
hive.img
[root@Linux]# fdisk -l Ubuntu.img
Disk hive.img: 7549 MB, 7549747200 bytes, 14745600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x244b7fbe
Device Boot Start End Blocks Id System
Ubuntu.img1 2048 43007 20480 e W95 FAT16 (LBA)
Ubuntu.img2 * 43008 14690303 7323648 83 Linux
2. Now we need to mount hive.img2 means the second partition of the disk image;
Now offset of hive.img2 is "Start Sector" X "Block Size"
mount -o loop,offset=$((43008*512)) Ubuntu.img /mnt
[root@Linux]# df -hP /mnt
Filesystem Size Used Avail Use% Mounted on
/dev/loop0 6.8G 4.3G 2.1G 68% /mnt
Comments
Post a Comment