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