co.de.mon.key

Weblog

Do zapamiętania: Linuks - szyfrowanie za pomocą dm-crypt / luks

| Comments

Zacząłęm to pisać sam, nawet już z pamięci, ale znalazłem stronę na której jest dokładnie to co chciałem. Nie lubię korzystać w taki sposób z czyjejś pracy ale tym razem to będzie prywatnie dla mnie do zapamiętania.

modprobe dm_mod

Tworzenie zaszyfrowanego systemu plików:

# create a 10M file
$ dd if=/dev/urandom of=testfs bs=1M count=10

# associate it with the loop device
$ losetup /dev/loop0 testfs

# encrypt it (will ask for password to use)
$ cryptsetup luksFormat /dev/loop0

# open the encrypted loop device
$ cryptsetup luksOpen /dev/loop0 testfs

# format it with ext2 (or whatever you prefer)
$ mkfs.ext2 /dev/mapper/testfs

# mount it
$ mount /dev/mapper/testfs /mnt/test

# confirm mount
$ df -h /mnt/test
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/testfs 9.2M 88K 8.7M 1% /mnt/test

Odmontowanie systemu plików:

# unmount it
$ umount /mnt/test

# close encryption
$ cryptsetup luksClose /dev/mapper/testfs

# release loop device
$ losetup -d /dev/loop0

Montowanie szyfrowanego systemu plików:


# associate file with the loop device
$ losetup /dev/loop0 testfs

# open the encrypted loop device
$ cryptsetup luksOpen /dev/loop0 testfs

# mount it
$ mount /dev/mapper/testfs /mnt/test

Comments