From RootdevWiki

Jump to: navigation, search

Contents

How to use a file as an encrypted filesystem

Create the filesystem

dd if=/dev/zero of=/tmp/cyptfile bs=1024 count=2000000
losetup -e blowfish /dev/loop0 /tmp/cryptfile
mkfs.ext3 /dev/loop0

Mount the filesystem

Just mount /dev/loop0 as you would any other filesystem, eg:

mount -t ext3 /dev/loop0 /mnt/crypto

Unmount the filesystem

First unmount the filesystem, then release the loop device.

umount /dev/loop0
losetup -d /dev/loop0

Remounting the filesystem

If you unmount as above then to remount the filesystem you need to reattach the loop device:

losetup -e blowfish /dev/loop0 /tmp/cryptfile
mount -t ext3 /dev/loop0 /mnt/crypto

NB The password is set on the filesystem the first time you run losetup -e

A cleaner way to mount the filesytem is:

mount -t ext3 /tmp/cryptfile /mnt/crypto -oencryption=blowfish