Loop device

Loop device

In Unix-like operating systems, 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. The association provides the user with an API that allows the file to be used in place of a block special file (cf. device file system). Thus, if the file contains an entire file system, the file may then be mounted as if it were a disk device.

Files of this kind are often used for CD ISO images and floppy disc images. Mounting a file containing a filesystem via such a loop mount makes the files within that filesystem accessible as regular files, located in the mount point directory.

A loop device may allow some kind of data elaboration during this redirection; for example, the device may be the unencrypted version of an encrypted file. In such a case, the file associated with a loop device may be another pseudo-device. This is mostly useful when this device contains an encrypted file system. If supported, the loop device is in this case the decrypted version of the original encrypted file and can therefore be mounted as if it were a normal filesystem.

Examples

Mounting a file on a directory requires two steps:

# the file is associated with a loop device node, which is a special file
# the loop device is mounted on the directory

These two operations can be performed either using two separate commands, or by letting the mount command perform the first step before actually doing the mount. The first operation can be executed by a specific command such as losetup [http://www.cl.cam.ac.uk/cgi-bin/manpage?8+losetup losetup manual page] in Linux. As an example, if example.img is a regular file containing a filesystem 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 overall effect of executing these two commands is that the content of the file is used as the whole mounted directory. The system call used by losetup to associate and disassociate files with loop devices is an ioctl on the loop device.

An alternative way of doing the same is to let the mount utility handle the setting up of the loop device:

mount -o loop example.img /home/you/dir

In this case, the mount command performs both the association of the file with the loop device and the mount itself.

At the level of system calls, the association and disassociation of a file with a loop device are done via ioctl's on the loop device. Both losetup and mount therefore use such ioctl's to operate on loop devices. For example, losetup /dev/loop0 example.img opens device /dev/loop0 and performs an ioctl on the resulting file descriptor, passing LOOP_SET_FD as the request number and the string example.img as the third argument.

Uses of loop mounting

After mounting a file containing a filesystem, the files within the filesystem can be accessed through the usual filesystem interface of the operating system, without any need for special functionality, such as reading and writing to ISO images, in applications.

Uses include managing and editing filesystem images meant for later normal use (especially CD or DVD images or installation systems) or permanent segregation of data in actual use (for example simulating removable media on a faster and more convenient hard disk or encapsulating encrypted filesystems).

Availability

Some confusion exists about the naming of the loop device under various operating systems.Various Unix-like operating system provide the loop device functionality under different names.

In Linux [http://www.kernel.org The Linux kernel archives] , device names are encoded in the symbol table entries of their corresponding device drivers. The device is called "loop" device and device nodes in the device file system are named /dev/loop0, /dev/loop1, etc. and created by the makedev script. The management user interface for the loop device is losetup and is part of the util-linux package.

Sometimes, the loop device is erroneously referred to as 'loopback' device, but this term is reserved for a networking device in the Linux kernel (cf. loopback). The concept of the 'loop' device is distinct from that of 'loopback', although similar in name.

In BSD, the loop device is called "virtual node device" or "vnd", and generally located at /dev/vnd0, /dev/rvnd0 or /dev/svnd0, etc., in the file system. The configuration is called the vnconfig program.

In SunOS, it is called "loopback file interface" or lofi, and located at /dev/lofi/1, etc. SunOS has the lofiadm program for configuration.

Loop mounting is not natively available on Microsoft Windows operating systems; however, the facility often added using third-party applications such as "Daemon Tools" and "Alcohol 120%".

A freely-available [http://www.stoev.org/vmware/diskmount.html] tool from VMware can also be used to achieve similar functionality.

See also

* device file system
* Disk image emulator
* Network block device used when the file to associate with the device is on a remote computer
* With similar name, but different concept, a loopback interface, or loopback device is network facility in UNIX-like operating systems

References

External links

* [http://www.linux.org/docs/ldp/howto/Cryptoloop-HOWTO/loopdevice-setup.html Setting up the loop device] from the cryptoloop HOWTO.
* [http://bochs.sourceforge.net/doc/docbook/user/loop-device-usage.html Mounting a disk image using the loop device] from the "Bochs User Manual"


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Loop device — Ein loop device ist allgemein ein Gerät, das auf sich selbst zurück zeigt. Es werden folgende loop devices unterschieden: in der Netzwerktechnik eine Netzwerkschnittstelle, die alle über sie versendeten Pakete direkt wieder als empfangene Pakete… …   Deutsch Wikipedia

  • Loop — (engl.: ‚Schleife‘ oder ‚Schlaufe‘) bezeichnet eine Universal Chess Interface Schachengine, siehe Loop (Schach). bei Druckwasserreaktoren einen Rohrleitungsstrang der Hauptkühlmittelleitung. in der Funktechnik eine Antennenbauweise, bei der die… …   Deutsch Wikipedia

  • Loop — A loop is generally something that closes back on itself such as a circle. The closing can appear in time or in space.cience and technology*Loop (algebra), a quasigroup with an identity element *Loop (graph theory), an edge that begins and ends… …   Wikipedia

  • Loop unwinding — Loop unwinding, also known as loop unrolling, is a loop transformation technique that attempts optimize a program s execution speed at the expense of its size.The goal of loop unwinding is to increase the programs speed by reducing (or… …   Wikipedia

  • Loop nest optimization — (LNO) is a special case of loop transformation, dealing with nested loops, that allows large reductions in the cache bandwidth necessary for some common algorithms.Example: Matrix multiplyMany large mathematical operations on computers end up… …   Wikipedia

  • loop — loop1 [lo͞op] n. [ME loup < Anglo N forms corresponding to ON hlaup, a leap, hlaupa, to run (akin to LEAP) > Dan løbe(knude), lit., running (knot)] 1. a) the more or less circular figure formed by a line, thread, wire, etc. that curves back …   English World dictionary

  • Device driver — Operating systems Common features …   Wikipedia

  • Loop bin duplicator — A loop bin duplicator is a specialized audio tape machine utilized in the duplication of pre recorded audio cassettes. Analog Loop Bin Duplicator An analog loop bin uses a long loop of 1/2 wide tape loaded in a large bin located in the front of… …   Wikipedia

  • Loop around — A Loop line or Loop Around is a telephone company test circuit. The circuit did not connect to a specific place, and required two numbers dedicated to it. When one side of the loop was called (Side A), the caller got an approximately 1000 Hz tone …   Wikipedia

  • Loop antenna — A shortwave loop antenna A loop antenna is a radio antenna consisting of a loop (or loops) of wire, tubing, or other electrical conductor with its ends connected to a balanced transmission line. Within this physical description there are two very …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”