Sunday, November 22, 2009

Create an Encrypted Image

(1) load required modules
$ modprobe aes
$ modprobe cryptoloop

(2) list used loop devices
$ losetup -a

(3) setup our image image
# input your key afterwards
$ losetup -e aes -k 256 /dev/loop1 dev.img
$ mkfs.ext4 /dev/loop1

(4) delete loop
$ losetup -d /dev/loop1

(5) create a script to mount the device
#!/bin/bash
# you can also add this to /etc/modules
modprobe aes
modprobe cryptoloop
mount -o loop,encryption=aes,keybits=256 dev.img /tmp/t