Mount a disk image file

From Luniwiki
Jump to: navigation, search

Disk image

# fdisk -l IMAGES_00000
Disk IMAGES_00000: 10 TiB, 10995116277760 bytes, 21474836480 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
Disklabel type: gpt
Disk identifier: 805C472C-9237-0647-91F1-4881354FC0D8

Device Start End Sectors Size Type IMAGES_00000p1 2048 21474836446 21474834399 10T Linux filesystem

The partition starts at sector 2048 and the sector size is 512 bytes

Mount partition

Create the mount point

# mkdir /mnt/images

Mount the partition as a loop with the correct offset 512 * 2048 = 1 048 576

# mount -o loop,offset=1048576 IMAGES_00000 /mnt/images

Check the mount

# mount | grep /mnt/images
/volume2/@iSCSI/LUN/BLUN/e5f5aa43-d1a3-47cf-a69a-97b25505acde/IMAGES_00000 on /mnt/images type ext4 (rw,relatime,data=ordered)

Read only

If you need the partition mounted as read only, add the ro option

# mount -o ro,loop,offset=1048576 IMAGES_00000 /mnt/images

Check the mount

# mount | grep /mnt/images
/volume2/@iSCSI/LUN/BLUN/e5f5aa43-d1a3-47cf-a69a-97b25505acde/IMAGES_00000 on /mnt/images type ext4 (ro,relatime,data=ordered)

Unmount partition

# umount /mnt/images/

References

Daniel Simao 23:39, 17 September 2021 (EDT)