먼저 dd 명령으로 가상 블럭 장치로 사용할 512KB 크기의 VirtualDisk.img라는 파일을 만든다.
# dd if=/dev/zero of=VirtualDisk.img bs=512 count=1024
1024+0 records in
1024+0 records out
# ls -l ./VirtualDisk.img
-rw-rw-r-- 1 root root 524288 Dec 21 15:50 ./VirtualDisk.img
# devb-loopback loopback blksz=512 fd=./VirtualDisk.img
# ls -l /dev/lo*
brw------- 1 root root 9, 0 Dec 21 15:54 /dev/lo0
# df -P /dev/lo*
Filesystem 512-blocks Used Available Capacity Mounted on
/dev/lo0 1024 1024 0 100%
$ sudo losetup /dev/loop0 ./VirtualDisk.img
아래를 보면 Sector(Block Size)크기가 512 이며 1024개의 실린더로 생성 되었음을 알 수 있다.
# ls -l /dev/lo*
brw------- 1 root root 9, 0 Dec 21 15:59 /dev/lo0
# df -P /dev/lo0
Filesystem 512-blocks Used Available Capacity Mounted on
/dev/lo0 1024 1024 0 100%
# fdisk -z /dev/lo0
FDISK
Ignore Next Prev Change Delete Boot Unboot Restore Loader Save Quit
_____OS_____ Start End ______Number_____ Size Boot
name type Cylinder Cylinder Cylinders Blocks
--> 1. ______ (___) _______ _______ _______ _________ _____
2. ______ (___) _______ _______ _______ _________ _____
3. ______ (___) _______ _______ _______ _________ _____
4. ______ (___) _______ _______ _______ _________ _____
Choose a partition by typing the partition number OR moving the pointer
with the UP/DOWN arrows.
Then, choose one of the actions on the top line of the screen.
Drive : /dev/lo0 Config: 1 Heads
Size : 0 Mbytes 1 Sectors/track
Loader: None 1024 Cylinders
Blocks: 1024 512 Block Size
Last cylinder is 1023
# mkdosfs /dev/lo0
Format complete: FAT12 (4096-byte clusters), 492 kB available.
# mount -tdos /dev/lo0 /mnt/dos
# mount
/dev/hd0t179 on / type qnx6
/dev/lo0 on /mnt/dos type dos (fat12)
# df -P /mnt/dos
Filesystem 512-blocks Used Available Capacity Mounted on
/dev/lo0 984 0 984 0% /mnt/dos/
참고 사이트
http://wiki.osdev.org/Loopback_Device
http://en.wikipedia.org/wiki/Loop_device
http://www.tldp.org/HOWTO/archived/Loopback-Root-FS/Loopback-Root-FS-2.html
http://web2.clarkson.edu/projects/itl/honeypot/ddtutorial.txt
http://icarus21.tistory.com/32
http://wiki.osdev.org/Loopback_Device
http://en.wikipedia.org/wiki/Loop_device
http://www.tldp.org/HOWTO/archived/Loopback-Root-FS/Loopback-Root-FS-2.html
http://web2.clarkson.edu/projects/itl/honeypot/ddtutorial.txt
http://icarus21.tistory.com/32