Tuesday, November 16, 2010

[Level 2] Create loopback device file in Ubuntu.

Create loopback device file in Ubuntu as following steps:

1. Create  block file
# dd if=/dev/zero of=/file bs=1k count=500
2. Create loopback device
# losetup /dev/loop0 /file
# losetup -a

3. Create filesystem
# mkfs -t ext2 /dev/loop0
4. Mount loopback device
# mount -t ext2 /dev/loop0 /mnt 
5. Umount loopback device

# umount /dev/loop0
6. Delete loopback device
# losetup -d /dev/loop0

ref:
http://manpages.ubuntu.com/manpages/lucid/man8/losetup.8.html

Wish this helps.
regards,
Stanley Huang