< Back to index
In Unix-like operating systems, a loop device, loopback device, vnd (vnode disk), or lofi (loopback file interface) is a pseudo-device that is able to redirect and transforms data that goes through its "loop". It is mostly used for encryption of a file-system, but since any regular file can be associated with a loop device, it makes it possible to turn any file into a pseudo-device.
Examples
Mounting a file on a directory can be done in one of two different ways. The first one involves two steps:
#The file is associated with a loop device node using a specific command (losetup in Linux, for example);
#Then, the device node is mounted on the directory as for any other block device. For example, if example.img
is a regular file and /home/you/dir
is a directory on a Linux box, the root user can mount the file on the directory by executing the following two commands:
losetup /dev/loop0 example.img
mount /dev/loop0 /home/you/dir
The first command associates the loop device node /dev/loop0
with the regular file example.img
. This association can be later destroyed by executing losetup -d /dev/loop0
. The second command mounts the device on the directory /home/you/dir
.
The global effect of executing these two commands is that the content of the file is used for storing the whole mounted directory.
The second way lets mount handle the setting up of the loop device:
mount -o loop example.img /home/you/dir
The loop device is capable of encryption, the type and strength depend on version of kernel and of util-linux.
losetup is part of the util-linux package, which can be found [http://www.kernel.org/pub/linux/utils/util-linux/ here] or [http://freshmeat.net/projects/util-linux/ here], or with the package manager of your distro. The latest version is 2.13-pre7 from 5th March 2006.
This entry uses material from from Wikipedia, the leading user-contributed encyclopedia. It is licensed under the GNU Free Documentation License. Disclaimer.