Personal tools
You are here: Home Lab Servers crypto filesystem under linux
Document Actions

crypto filesystem under linux

short how-to for setting up crypto file system under linux

very brief explanation

setup

note: works for kernels 2.6.22 and newer

first create random file (cd size for easy backup). using randomized file is important for the security.

mount image as loop. other possibility is to use whole partition - just omit first two lines.

format file/partition with appropriate cipher (depends on your kernel setup) using cryptosetup and setup initial password. here we use keys in LUKS format - this way we'll be able to use more than one password or change password without reformating whole crypto file system.

open mapping and create file system. here we use ext2. there were suggestions not to use journaling file system on filesystems in file, but i tried also ext3 and reiserfs and both work just fine for me. but etx2 is the safe choice.

close crypto mapping and umount file. you're done.

using it

mounting and umounting is easy, but do not forget to close crypto mapping after umounting crypto file system.

code

preparing

dd if=/dev/urandom of=~/.crypt bs=1M count=700k
losstup /dev/loop/0 ~/.crypt 
cryptsetup -c aes-cbc-plain luksFormat /dev/loop/0
cryptsetup -c aes-cbc-plain luksOpen /dev/loop/0 my.crypt
mkfs.ext2 /dev/mapper/my.crypt 
cryptsetup luksClose my.crypt
losetup -d /dev/loop/0

mount

losetup /dev/loop/0 ~/.crypt
cryptsetup -c aes-cbc-plain luksOpen /dev/loop/0 my.crypt
mount /dev/mapper/my.crypt ~/crypt

check

dmsetup ls

umount

umount ~/crypt
cryptsetup luksClose my.crypt
losetup -d /dev/loop/0

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: