# dd if=/dev/zero of=disk-image bs=100M count=1 ←Create a 100MB image file # losetup /dev/loop0 disk-image ←Use losetup to simulate "/dev/loop0" as a disk # mkfs -t ext4 /dev/loop0 ←Format "/dev/loop0" # mount /dev/loop0 /mnt ←Mount "/dev/loop0" # umount /dev/loop0 ←Unmount # losetup -d /dev/loop0 ←Detach "/dev/loop0" from the image file |
After the second step of losetup, operating on "/dev/loop0" is just like working with a real disk. You can format, mount, and store files on it. For more information on losetup usage, operations, and examples, refer to the provided link.