Losetup command and loop device usage

Source: Internet
Author: User
The losetup command and the use of the loop device 1loop device introduce that the loop device is a pseudo-device or a simulation device. It allows us to access a file like a block device. Before using the losetup command, a loop device must connect the losetup command with a file and use the loop device. loop device description the loop device is a pseudo-device, or a simulation device. It allows us to access a file like a block device. Before use, a loop device must be connected to a file. This combination provides you with an interface to replace block special files. Therefore, if the package contains a complete file system, the file can be mounted like a disk device. As mentioned above, we often see CD or dvd iso disc image files or a floppy disk (hard disk) *. img image files. Through this loop mount method, these image files can be mounted to a directory of the current file system. So far, we can understand the meaning of loop: for the first-level file system, it is directly installed on the physical devices of our computer; for this mounted Image file (which also contains a file system), it is built on the first-level file system. In this case, it is like a file system that is circled on the first level of the file system, so it is called loop. 2. losetup command losetup [-e encryption] [-o offset] loop_device filelosetup [-d] loop_device description: this command is used to set cyclic devices. Cyclic devices can virtualize files into blocks to simulate the entire file system, so that users can regard them as hard drive, optical drive, or soft drive devices and mount them as directories. Above, options and parameter names in the command format:-e indicates the encryption method-o sets the data offset-d detaches the device loop_device loop device name, such as/dev/loop0 in linux, /dev/loop1. The file name to be associated with the cyclic device. this is often a disk image file, such *. img3. use example (1) to create an empty disk image file. here, create a 1.44M floppy disk $ dd if =/dev/zero of = king. img bs = 256 count = 5760 (2) use losetup to virtualize the disk image file into a fast device $ losetup/dev/loop0 king. img (3) mount block devices $ mount/dev/loop0/mnt after the above three steps, we can use the/tmp Directory, access the disk image file king just like accessing a real fast device. img (4) uninstall the loop device $ umount/tmp $ losetup-d/dev/loop0

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.