What is loopback file device and what is a send-back Device

Source: Internet
Author: User

In Unix-like operating systems,Loop Device
,Loopback
Device

,VND
(Vnode disk), orLofi
(Loopback File
Interface) is a pseudo-device that makes a file
Accessible as a pseudo-device. A loop device may allow some kind
Data elaboration during this redirection; for example, the device may
Be the unencrypted version of an encrypted file.

Since loop devices allow seeing a regular file as a device, they
Allow for mounting those regular files that contain an entire file
System. Files of this kind that are often used are cd iso images and
Floppy disc images. Mounting a file containing a filesystem via suchLoop
Mount

Makes the files within that filesystem accessible as regular
Files, located on the mount point directory.

The file that is associated to a loop device may be a regular file,
But also another pseudo-device. This is mostly useful when this device
Contains an encrypted file system. If supported, the loop device is in
The case the decrypted version of the original device, and can
Therefore be mounted directly.

Examples

Mounting a file on a directory requires two steps:

  1. The file is associated with a loop device node, which is
    Special File
  2. The loop device is mounted on the directory

These two operations can be saved med either using two separate
Commands, or by leader the mount command perform the first step before
Actually doing the Mount. The first operation can be executed by
Specific command suchLosetup
In Linux. As an example, ifexample.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
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 fileexample.img
. This association can be
Later destroyed by executinglosetup -d /dev/loop0
.
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 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 Mount handle
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
File with the loop device and the Mount itself.

At the level of system CILS, the Association and disassociation of
File with a loop device are done via IOCTL
'S on
The loop device. Both losetup and mount therefore use such IOCTL's
Operate on loop devices. For example,losetup /dev/loop0
example.img

Opens Device/dev/loop0
And performs
IOCTL on the resulting file descriptor, passingLOOP_SET_FD
As the request number and the stringexample.img
As
Third argument.

Uses of loop mounting

After mounting a file containing a filesystem, the files within
Filesystem can be accessed through the usual filesystem interface
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

Various Unix-like operating system provide the loop device
Functionality under different names. in Linux, the device is called
Loop device and generally named/Dev/loop0
,/Dev/loop1
,
Etc. And created by the makedev script. in BSD, is called virtual node
Device or VND, and generally located/Dev/vnd0
,/Dev/rvnd0
Or/Dev/svnd0
, Etc. In SunOS, is called loopback File
Interface or lofi, and located/Dev/lofi/1
, Etc.

 

From: http://gorebill.blog.163.com/blog/static/240616372008575646832/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.