Encrypted Loop-Back Filesystem

Encrypted Loop-Back Filesystem: "

This HowTo will walk us through the process of creating an encrypted filesystem. The filesystem will be a single file that can be moved to other systems but only accessible with the decryption password. Please be careful not to overwrite any existing files (or device file) during this HowTo.


Install the dependencies:



sudo apt-get install cryptsetup

Create the file (called “/home/encfile”) that will eventually be the new filesystem. This example uses a 100MB file:



dd if=/dev/zero of=/home/encfile bs=1024 count=100000

make sure the required module is loaded:



modprobe aes loop cryptoloop

Now we create the encrypted filesystem within the new file:



losetup -e aes /dev/loop1 /home/encfile

The above will request the password which will protect your encrypted filesystem. Make it good. Now create the filesystem with your new encrypted file:



mkfs.ext3 /dev/loop1

Now mount the new filesystem:



mkdir /media/encdir
mount -o loop,encryption=aes -t ext3 /home/encfile /media/encdir

At this point you can use the new encrypted filesystem. You can dismount securely as follows:



umount /media/encdir

Again, you can mount your encrypted filesystem using the following:



mount -o loop,encryption=aes -t ext3 /home/encfile /media/encdir
"