In order to compile and package a Linux livecd that can be started and run from vbox, these two days have severely supplemented the knowledge of Linux. The following describes the concept of a loop device. I think I have already explained it clearly on the Wiki, so I can directly paste it for subsequent index search.
/Dev/Loop Wikipedia, a free encyclopedia HanBytes Bytes
In Unix-like systems,/Dev/Loop(OrVND(Vnode disk ),Lofi(Circular file Interface) is a pseudo-device that allows files to be accessed as Block devices.
Before use, the cyclic device must be associated with files on the existing file system. This association provides you with an application interface that allows you to use a file as a special block file (see the device file system. Therefore, if a file contains a complete file system, the file can be mounted as a disk device.
These device files are often used on CDs or disk images. PassCyclic mountingTo mount files containing the file system, so that files in the file system can be accessed. These files will appear in the mount point directory.
A cyclic device may be able to process data during redirection. For example, a device may be decrypted by an encrypted file. In this case, the file related to the cyclic device may be another pseudo device. This data processing is useful when the device contains an encrypted file system. If data processing is supported and the original file is encrypted, the circulating device decrypts the encrypted file and the device can be mounted like a common file system.
| Directory [Hide]
- 1 Use of cyclic mounting
- 2 Availability
- 3 Instance
- 4 See
- 5 Reference
- 6 External link
|
[Edit] Use of cyclic mounting
After a file containing a file system is mounted, files stored in the file system can be accessed by conventional file system interfaces or systems without the support of special functions. For exampleProgram.
Applications include managing and editing file system images for future use (especially CD, DVD images, or installation systems) or permanently isolate some data in actual applications (such as simulating a faster and more convenient hard disk or encapsulated Encrypted File System on removable media ).
The cyclic device provides a convenient way to install the operating system in a single file, so that the operating system does not have to be repartitioned for the disk drive.
[Edit] Availability
The naming of cyclic devices in various operating systems is confusing. In various UNIX operating systems, functional cyclic devices are named differently.
In Linux, the device name is named according to the symbol table of the corresponding device driver. These devices are called "loop" devices./Dev/loop0,/Dev/loop1And so on. Static device directories can be created using makedev scripts, or dynamically by the Device File System (udev) facility. The management interface for cyclic devices isLosetupThis is part of the util-Linux software package.
Sometimes cyclic devices are incorrectly considered as loopback devices, but the term is reserved for network devices in the Linux kernel (see loopback devices ). The concept of a cyclic device is different from that of a loop device, although its name is similar.
In a system derived from BSD such as NetBSD and OpenBSD, cyclic devices are called "virtual node devices" or "Vnd" and devices are placed in/Dev/vnd0,/Dev/rvnd0Or/Dev/svnd0. In the file system, useVnconfigProgram.
FreeBSD follows the same conventions as other BSD systems before release 5, and then the cyclic device is incorporated into the memory disk device ("MD "). Currently usedMdconfig[1] program configuration.
In Solaris/opensolaris, cyclic devices are called "loop file interfaces" or lofi,[2] located/Dev/lofi/1. Owned by SunOSLofiadmConfiguration program. The lofi driver supports read-only compression and read-write encryption. Third-party drivers for the SunOS/Solaris platform "FBK" have been available since the summer of 1988"[3] (File simulation block device; English: file emulates blockdevice)
Mac OS X implements a local image mounting mechanism and serves as an abstraction for Random Access to disk devices. These devices appear in/DevRead/write operations are sent to a user-mode secondary process, and the secondary process is responsible for reading and writing operations. It is automatically enabled when the disk image is opened on the user interface. This can process disk, CD-ROM, or DVD images in multiple formats.
In Microsoft Windows, circular mounting is not supported by the native system (this function is not implemented by the native until Windows 7, and works through the diskpart tool ).[4] However, this capability is often implemented through third-party programs, suchDaemon toolsAndAlcohol 120%VMware's free tools and LTR data (imdisk) can all implement similar functions.
[Edit] Instance
To mount a file containing a file system in a directory, You need to perform the following two steps:
- Connect a file with a cyclic device node.
- Mount the cyclic device to the directory
These two operations can be completed by using two commands, or by adding a special Mount symbol to the mount command. The first operation can be performed throughLosetup[5] or on SunOSLofiadm[6] The command is complete.
For example, ifExample. imgIs a common file that contains the file system, and/Home/you/DirIs the directory of a Linux User. A super user (Root) may be able to mount the file to the directory by executing the following command:
Losetup/dev/loop0 example. imgmount/dev/loop0/home/you/Dir
The second command mounts the device to the directory./Home/you/Dir. The result of executing the preceding statement is that the file is mounted as a file system, and the file content appears in the mounted directory (the mounted directory is used as the root directory ).
In addition, the Mount tool is often competent for the entire mounting program:
Mount-o loop example. img/home/you/Dir
Then, the device can unmount it with the following command:
Umount/home/you/DIR # or use such as Mount | grep "/home/you/DIR" # Or losetup-A | grep example. find the loop device number associated with the file in the IMG search # and execute the following command: (<n> indicates the device number) umount/dev/loop <n>
In lower-layer application interfaces, file association and disassociation are implemented through the ioctl System Call on the cyclic device.