Tuesday, February 23, 2010

Disk Encryption in OpenWrt

I have an external USB disk connected to my Asus WL-500gP which runs OpenWrt KAMIKAZE (8.09.1, r16278).

I want to have the disk encrypted. So I installed every possible package that has aes or loop in name but I still got the following error message:

root@OpenWrt:~# losetup -e aes /dev/loop/0 /dev/scsi/host0/bus0/target0/lun0/part1
Password:
ioctl: LOOP_SET_STATUS: Invalid argument

The solution was easy - install losetup that supports aes encryption. You can find the package on http://www.roth.lu/download/openwrt-usb-raid1-loopaes/. Download it, install it and viola - it works :-)

root@OpenWrt:~# losetup -e aes /dev/loop/0 /dev/scsi/host0/bus0/target0/lun0/part1
Password:
root@OpenWrt:~# mkfs.ext2 -vm0 /dev/loop/0
mkdir /mnt/disk/
mount /dev/loop/0 /mnt/disc
To mount the disc in script use
echo password | losetup -e aes /dev/loop/0 /dev/scsi/host0/bus0/target0/lun0/part1 -p0

No comments: