Mounting images as devices using loopback devices.
Mounting with a Loopback
Copy the Image that you want to mount using DD
dd if=/dev/zero of=/loopfile
Check for the unused loop device.
# losetup -f
/dev/loop1
Set up the loop device with the backing file. If this has partitions you can use the -P flag.
# losetup /dev/loop1 /loopfile [-P]
Creating an ext4 fs with the device
Make the Ext FS
# mkfs -t ext4 -v /dev/loop1
mke2fs 1.45.3 (14-Jul-2019)
fs_types for mke2fs.conf resolution: 'ext4', 'small'
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
12800 inodes, 12800 blocks
640 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=14680064
1 block group
32768 blocks per group, 32768 fragments per group
12800 inodes per group
Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
Create a mount point
# mkdir /mnt/loopfs
Mount the fs
# mount -t ext4 /dev/loop1 /mnt/loopfs
Unmounting and deleting the loop and fs
# umount /mnt/loopfs/
# losetup -d /dev/loop1