If you are using the loadable module you must have the module loaded first with the command:
$ sudo modprobe loop
The following commands can be used as an example of using the loop device.
$ dd if=/dev/zero of=file bs=1k count=100 100+0 records in 100+0 records out 102400 bytes (102 kB) copied, 0.00126554 s, 80.9 MB/s $ sudo losetup /dev/loop0 file $ sudo mkfs.ext3 /dev/loop0 mke2fs 1.40.8 (13-Mar-2008) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 16 inodes, 100 blocks 5 blocks (5.00%) reserved for the super user First data block=1 1 block group 8192 blocks per group, 8192 fragments per group 16 inodes per group Writing inode tables: done Filesystem too small for a journal Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 24 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
mount loop device
$ sudo mkdir /mnt/loop $ sudo mount /dev/loop0 /mnt/loop
Now! you can using it as harddisk.
umount loop device
$ sudo umount /mnt/loop/ $ sudo losetup -d /dev/loop0
Maybe also encryption modules are needed.
$ sudo modprobe cryptoloop $ sudo modprobe des
enable data encryption
$ dd if=/dev/zero of=encryption_file bs=1k count=100 100+0 records in 100+0 records out 102400 bytes (102 kB) copied, 0.00130537 s, 78.4 MB/s $ sudo losetup -e des /dev/loop0 encryption_file
If you are using the loadable module you may remove the module with the command
$ sudo rmmod loop des cryptoloop
EXAMPLE
If you are using the loadable module you must have the module loaded first with the command # insmod loop.o Maybe also encryption modules are needed. # insmod des.o # insmod cryptoloop.o The following commands can be used as an example of using the loop device. # dd if=/dev/zero of=/file bs=1k count=100 # losetup -e des /dev/loop0 /file Password: Init (up to 16 hex digits): # mkfs -t ext2 /dev/loop0 100 # mount -t ext2 /dev/loop0 /mnt ... # umount /dev/loop0 # losetup -d /dev/loop0 If you are using the loadable module you may remove the module with the command # rmmod loop