Archive for March, 2014

NOTE: This article assumes that you have the necessary software installed in your GNU/Linux distribution.

1] Do a "su -", or do everything here as root.
2] You should have a Linux partition (hex code 83 if you use fdisk in GNU/Linux) for this purpose. Mine is /dev/sdb1
3] Do the following:

mkdir /encrypted

# Note: The following 2 commands will ask you for input.
cryptsetup -y -v luksFormat /dev/sdb1
cryptsetup luksOpen /dev/sdb1 encrypted

mkfs.ext4 /dev/mapper/encrypted
mount /dev/mapper/encrypted /encrypted

4] To unmount your encrypted filesystem:

umount /encrypted
cryptsetup luksClose encrypted

5] To remount your encrypted filesystem:

# Note: The following command will ask you for input.
cryptsetup luksOpen /dev/sdb1 encrypted

mount /dev/mapper/encrypted /encrypted

NOTE: This article assumes that you have the necessary software installed in your GNU/Linux distribution.

1] Do a "su -", or do everything here as root.
2] Create a file for the filesystem and then secure its permissions. This will create 2 GB file on the present working directory:

dd of=encrypted bs=1G count=0 seek=2 # You may substitute an absolute path for "encrypted".
chmod 600 encrypted # You may substitute an absolute path for "encrypted".

3] Do the following on the present working directory in step 2:

mkdir /encrypted
losetup /dev/loop0 encrypted # You may substitute an absolute path to the file "encrypted".

# Note: The following 2 commands will ask you for input.
cryptsetup -y luksFormat /dev/loop0 # A password for the encrypted filesystem will be asked here.
cryptsetup luksOpen /dev/loop0 encrypteddev # This will show "/dev/mapper/encrypteddev".

mkfs.ext4 /dev/mapper/encrypteddev # This will make a EXT4 filesystem on your encrypted file.
mount /dev/mapper/encrypteddev /encrypted

4] To unmount your encrypted filesystem:

umount /encrypted
cryptsetup luksClose encrypteddev # This will remove "/dev/mapper/encrypteddev".
losetup -d /dev/loop0

5] To mount your encrypted filesystem again (your present working directory should be where the "encrypted" file is located):

losetup /dev/loop0 encrypted # You may substitute an absolute path to the file "encrypted".

# Note: The following command will ask you for input.
cryptsetup luksOpen /dev/loop0 encrypteddev # This will show "/dev/mapper/encrypteddev".

mount /dev/mapper/encrypteddev /encrypted # You may substitute an absolute path to the file "encrypted"

Back to top