Linux Command Learning Note--losetup command: Set up a looping device

Source: Internet
Author: User

Losetup command: Set up a loop device loop device can virtual a file into a block device, in order to simulate the entire file system, so that users can think of it as a hard disk drive, optical drive or floppy drives and other devices, and hang in as a directory to use.   is commonly used to load and access an. iso file as a looping device.   1, command parameter losetup: Set and Control loop (loop) device.   Syntax: Losetup loop device   parameters: Loop device can be/dev/loop0,/dev/loop1 .../dev/loop7-a shows the status of all loop devices. -D Dismount Device-e < encryption options > Start encryption encoding  -f look for the first unused loop device-O < offset > Set the data offset in bytes.   Example: (a) The 1.iso file virtual into a loop device under the shell input: losetup/dev/loop0  1.iso and then under the shell losetup/dev/loop0 will get some relevant information.   (ii) unloading as circulating equipment/dev/loop0losetup-d/dev/loop0 in operation Losetup/dev/loop0 It can be seen that the equipment has been removed.   (iii) find the first unused loop device losetup-f  (iv) displays all circulating device states that have been used losetup-a  combat: Create a 5M file and operate the virtual loop device. 1, create a file 5M files, 5,120 sectors, each sector size 1KDD If=/dev/zero  of=abc  bs=1k  count=51202, virtual cycle equipment losetup-f ABC   The ABC virtual into a loop device, specifically on which loop device with the-F automatic search. 3, format the virtual disk file mkfs.ext4/dev/loop04, mount the virtual disk file Mount/dev/loop0  /mnt/iso 5, you can copy the file to the inside or delete (test successful)  6, Unmount the file system Umount/mnt/iso7 and dismount the loop device. Losetup-d/dev/loop0  gave me the feeling that the loop is like a CD-ROM, and the file as a disc, put in the loop, and then mount it can be accessed, do not know how to understand it.

Linux Command Learning Note--losetup command: Setting up a looping device

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.