May 12, 2022

Mounting Disk Image File

After we create disk image file with dd, we have two options: restore it, or mount he file directly.

Once we finished cloning from a partition to a disk image file as below:

# dd if=/dev/sdb1 of=/mnt/share/disk_120G.img

We can mount the file with the following instruction to access some of the files without restoring the whole partition to a drive.

# file disk_120G.img

# fdisk -l disk_120G.img

Check what is the start sector. Let say the filesystem starts on sector 63 (from the fdisk output). Each sector is always 512 bytes long, thus we will use an offset of 32256 (63*512) bytes. 

# losetup -f

# losetup --offset 32256 /dev/loop2 disk_120G.img

# mount /dev/loop2 /mnt/point


Links: