Article:Mounting iso images and other tricks with loop mounts

by Calvin Austin

A loop device in Unix and Linux is a special virtual device that allows you to access a file as a device and therefore mount it and access it using existing device tools. The most common use of the loop device is to mount a cd/dvd iso image as a real cd and browse its contents copying files without having to have the iso image transcribed onto physical media.

The simplest option is to let the operating system map the loop device for you at the directory mount point you choose, for example /media/mycd

mount -o loop mycd.iso /media/mycd

You will quickly find that the loop devices are quickly allocated (8 devices normally) this is why thee losetup command is useful if you need a number of mounts. losetup specifies the loop device associated with the file which you can later remove using losetup -d.

losetup /dev/loop0 mycd.iso  
mount /dev/loop0 /media/mycd

If you have used VMware workstation this ability to map an iso image to a pseudo device may seem familiar. VMware does something very similar and given that Windows does not support loop devices you can use the VMware disk mount tool instead. The download location at vmware changes so its best to search directly for "diskmount"

Edit

Encrypting using loop mounts

Given that the loop device offers a translation between a device and a file a newer option is the -e for encryption . By default the kernel has not got crypto modules built in, so the encryption by default is none so first run

modprobe cryptoloop
modprobe aes

next create an empty file to be used as the device to be encrypted

dd if=/dev/zero of=/opt/secret count=10000

now tell the loop device we want this to be mounted and add a new file system and mount it

losetup -e aes /dev/loop0 /opt/secret
mkfs /dev/loop0
mount /dev/loop0 /opt/crypt

Once we are finished we umount and remove the loop back interface leaving our encrypted file

umount /opt/crypt
losetup -d /dev/loop0

Most Recent

Most Popular

Most Active Categories




Back To Top Add New Article Printable Page
MediaWiki

This page has been accessed 2,057 times.

This page was last modified 21:33, 6 January 2009.