losetup loop_device
losetup -a
losetup -d loop_device
losetup -f Print name of first unused loop device:
losetup [{-e|-E} encryption] [-o offset] [-p passfd] [-r] {-f|loop_device} file
losetup is used to associate loop devices with regular files or block devices, to detach loop devices
and to query the status of a loop device.
a loop device, vnd (vnode disk), or lofi (loopback file interface) is a pseudo-device that makes a file accessible as a block device.
Before use, a loop device must be connected to an existing file in the filesystem that allows the file to be used in place of a block special file (cf. device file system).
For example if the file contains an entire file system, the file may then be mounted as if it were a disk device.
Used for CD ISO and floppy disc images. Mounting a file containing a filesystem via such a loop mount makes the files within that filesystem accessible. They appear in the mount point directory.
-E or -e. -e .)
| -a | Show status of all loop devices.
losetup -a /dev/loop0: [0011]:8839 (/boot/sysrcd.dat) | ||||||||||||
-d |
usage:
losetup [options] loop_device file # setup
losetup -F [options] loop_device [file] # setup, read /etc/fstab
losetup loop_device # give info
losetup -a # give info of all loops
losetup -f # show next free loop device
losetup -d loop_device # delete
losetup -R loop_device # resize
options: -e encryption -o offset -s sizelimit -p passwdfd -T -S pseed
-H phash -I loinit -K gpgkey -G gpghome -C itercountk -v -r
-P cleartextkey
insmod loop.o
encryption modules may be needed.
insmod des.o
insmod cryptoloop.o
Using the loop device:
dd if=/dev/zero of=/STUFF bs=1k count=100 # make a 100k file of zeros
losetup -e des /dev/loop0 /STUFF # encrypt it (?)
Password:
Init (up to 16 hex digits):
mkfs -t ext2 /dev/loop0 100 # make an ext2 file system there
mount -t ext2 /dev/loop0 /mnt # mount it so it can be used for ???
...
umount /dev/loop0 # unmount it since we are done with it
losetup -d /dev/loop0 # detach loop0 from it
loadable module may be remove with rmmod loop