Losetup

From Tech
Jump to: navigation, search

losetup can be used to associate a file with a loopback device. This way, you can make files and use them to experiment with LVM, mdadm, or whatever else might require block devices.

List loopback devices that are currently associated with files

losetup -a

List the next available loopback device

losetup -f

Associate a loopback device with a file

losetup /dev/loop0 /path/to/file.img

Disassociate the loopback device from the file

losetup -d /dev/loop0

You can also mount just a partition within an image file

lomount -diskimage /path/to/your/backup.img -partition 1 /mnt/foo

when refering to the file for mounting or formatting, etc., use /dev/loop0 to refer to /path/to/file.img

Personal tools