Map regular files to loop devices to treat them like physical disks and test storage workflows. 09.07.2026 | reading time: 2 min When a file must behave like a disk, losetup maps it to a loop device so the system treats it as a block device; learn by doing and see how images become mountable volumes. Quick demo Create a 100 MB image, attach it, make a filesystem, mount and then clean up: ``` truncate -s 100M disk.img losetup --find --show disk.img # example output: /dev/loop0 mkfs.ext4 /dev/loop0 mkdir -p /mnt/loopdisk mount /dev/loop0 /mnt/loopdisk ls -l /mnt/loopdisk umount /mnt/loopdisk losetup -d /dev/loop0 ``` Options that matter List and inspect with `losetup -a`, reserve a free device with `--find` or `-f`, print the device used with `--show`, detach with `-d`, scan partitions inside an image using `-P` or `--partscan`, and control offsets with `--offset` and size limits with `--sizelimit` to mount single partitions inside larger images. Practical uses Use losetup to build disposable test volumes, mount installer images, prepare files for loopback encryption, attach container image layers for inspection, and combine with kpartx or device-mapper to expose partitions or encrypted containers; always unmount before detaching to avoid data loss. Complementary tools Pair losetup with `mount` to access filesystems, `mkfs` for formatting, `kpartx` to map partitions, and `cryptsetup` for encrypted loop devices when testing secure storage scenarios. Final note Mastering losetup makes image-based workflows fast and safe, and it opens practical paths into virtualization, backup testing and secure storage; keep experimenting and consider formalizing that skillset with certifications like CompTIA Linux+ or LPIC-1 and intensive exam preparation at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. setup filesystem utilities storage This page was created with the help of AI.