Jan 17, 2015 04:52 AM
(This post was last modified: Jan 23, 2015 05:18 PM by Crypto™.)
Figured I'd share this, since I just found out about this tonight. It also helped me get Kali Linux working with my pain-in-the-ass UEFI.
Keep in mind that when reading from/writing to an encrypted partition, the disk I/O speed is significantly slower. (An initial execution of apt-get update && apt-get upgrade will likely take in excess of three hours, possibly longer.) Even unencrypted storage partitions on a USB drive are going to be much slower than even HDDs or SSDs. However, this will allow persistent data across reboots.
Step 1: Changing the USB Partition Scheme
I created this from an Ubuntu instance, so some of these steps will be linux specific.
The first thing I did was fire up gparted, and select the USB device. (/dev/sdb for me, your results may vary) Then I went to Device -> Create Partition Table... and selected "gpt", which is the new scheme that is used on UEFI devices, and supercedes the older "MBR" standard. However, if your computer uses BIOS instead of UEFI, "gpt" will not work. Instead, try "msdos", which is the default. This will wipe ALL data on the device, including all partitions. You do not need to recreate partitions yet, and it will actually probably be easier if you don't.
Step 2: Cloning The Kali Linux Image
Linux and OS X provide the awesome "dd" utility, which makes the process a snap. You can see Windows, OS X, and Linux specific instructions in the Kali Docs. I'll cover the Linux ones here as well.
To clone the image using dd, simply run this command: (Note: Ensure that /dev/sdb is indeed the correct path to the device, and that you have backed up anything important or you will lose data.)
Syntax highlighted snippet of this step
And theeeennnnn? No and then. That's it for this step.
Step 3: Creating an encrypted storage partition
This is the final step, and can be done from the same instance where you installed Kali, or from a live instance of Kali itself. Keep in mind, if you do this in Kali, you will still have to restart for the changes to take effect.
Now, you can either create the storage partition in gparted, or use the command line all the way through. Be sure to format the partition as ext3 if you use gparted.
Syntax highlighted snippet of this step
Now you should be able to restart, and when you go to the startup screen, you'll see a couple new options in the boot menu:
[img]http://docs.kali.org/wp-content/uploads/2014/01/Screen-Shot-2014-05-25-at-5.58.00-PM-e1401035177510.png[/img]
With an encrypted partition, you can use both encrypted, and unencrypted storage I believe.
Hope this helps you out!
Keep in mind that when reading from/writing to an encrypted partition, the disk I/O speed is significantly slower. (An initial execution of apt-get update && apt-get upgrade will likely take in excess of three hours, possibly longer.) Even unencrypted storage partitions on a USB drive are going to be much slower than even HDDs or SSDs. However, this will allow persistent data across reboots.
Step 1: Changing the USB Partition Scheme
I created this from an Ubuntu instance, so some of these steps will be linux specific.
The first thing I did was fire up gparted, and select the USB device. (/dev/sdb for me, your results may vary) Then I went to Device -> Create Partition Table... and selected "gpt", which is the new scheme that is used on UEFI devices, and supercedes the older "MBR" standard. However, if your computer uses BIOS instead of UEFI, "gpt" will not work. Instead, try "msdos", which is the default. This will wipe ALL data on the device, including all partitions. You do not need to recreate partitions yet, and it will actually probably be easier if you don't.
Step 2: Cloning The Kali Linux Image
Linux and OS X provide the awesome "dd" utility, which makes the process a snap. You can see Windows, OS X, and Linux specific instructions in the Kali Docs. I'll cover the Linux ones here as well.
To clone the image using dd, simply run this command: (Note: Ensure that /dev/sdb is indeed the correct path to the device, and that you have backed up anything important or you will lose data.)
Syntax highlighted snippet of this step
Code
# if is the input file. In this case, the Kali image
# of is the output file. In this case, the path to the device, NOT to a mounted partition (E.g. NOT /dev/sdb1, only /dev/sdb, /dev/sdc, etc.)
# bs is Block Size, or the size of the chunks that will be transfered to the device. 512k or 1M should be about perfect
dd if=/path/to/kali-image.iso of=/dev/sdb bs=1MAnd theeeennnnn? No and then. That's it for this step.
Step 3: Creating an encrypted storage partition
This is the final step, and can be done from the same instance where you installed Kali, or from a live instance of Kali itself. Keep in mind, if you do this in Kali, you will still have to restart for the changes to take effect.
Now, you can either create the storage partition in gparted, or use the command line all the way through. Be sure to format the partition as ext3 if you use gparted.
Syntax highlighted snippet of this step
Code
# Start here if you didn't set up the partition in gparted
size=5gb # This is the size of the storage partition that you want. Make sure it doesn't exceed the unallocated space on the drive (the space not taken up by Kali most likely)
read bytes _ < <(du -bcm /path/to/kali-image.iso |tail -1); echo β # This will get the size of the disk image, and thus get the necessary offset for the beginning of the new primary partition.
parted /dev/sdb mkpart primary β $size # This creates the partition
# Start here if you already set up the partition in gparted
cryptsetup --verbose --verify-passphrase luksFormat /dev/sdb3 # Initialize encryption on the partition
cryptsetup luksOpen /dev/sdb3 my_usb # Decrypt the partition and prepare for mounting
mkfs.ext3 -L persistence /dev/mapper/my_usb # Create ext3 filesystem with label persistence, and map virtual device to /dev/mapper/my_usb
e2label /dev/mapper/my_usb persistence # Label drive persistence
mkdir -p /mnt/my_usb # Make directories recursively to create a mountpath for the USB drive
mount /dev/mapper/my_usb /mnt/my_usb # Mount the drive
echo "/ union" > /mnt/my_usb/persistence.conf # Create a peristence.conf file to tell Kali to use that partition for storage.
umount /dev/mapper/my_usb # Unmount the drive
cryptsetup luksClose /dev/mapper/my_usb # Remove the decrypted mapped driveNow you should be able to restart, and when you go to the startup screen, you'll see a couple new options in the boot menu:
[img]http://docs.kali.org/wp-content/uploads/2014/01/Screen-Shot-2014-05-25-at-5.58.00-PM-e1401035177510.png[/img]
With an encrypted partition, you can use both encrypted, and unencrypted storage I believe.
Hope this helps you out!
Get a signed message before dealing: Keybase
Still here sometimes.
Still here sometimes.



