ibuclaw
September 10th, 2009, 01:32 AM
Part One
HowTO: Encrypted LVM Installation on a Netbook
I'll start this guide off with a warning.
ENCRYPTED FILESYSTEMS CAN BE A FORMIDABLE AND UNFORGIVING SETUP.
IF THE SYSTEM GOES INTO AN UNBOOTABLE STATE, RECOVER WHAT YOU CAN WITH THE LUKS PASSWORD ON A LIVECD/LIVEUSB.
YOUR ONLY OPTION IS TO REINSTALL THE OPERATING SYSTEM, LOOSING ALL DATA IN THE PROCESS.
IF YOU FORGET YOUR PASSWORD, THERE IS NOTHING THAT CAN BE DONE TO RECOVER ANY DATA.
And as such, I am not liable for any loss of data, as the smart user always makes backups.
Introduction
This is part one of a two part guide.
Inspiration for this guide comes from the popularity of netbooks and other small, portable devices.
As great as they are, the security implications are at a higher risk as our fallibility and tendencies to loose such devices - and the sensitive data on them - becomes a greater threat.
With normal Laptops that come supplied with a CD Drive, the Ubuntu Text-based installation (http://releases.ubuntu.com/9.04/ubuntu-9.04-alternate-i386.iso.torrent) offers the feature to encrypt your hard drive. But due to size restrictions, there is no CD Drive, and putting it on a USB pendrive will produce a Alternate CD Install Error: "Cannot find CD" (http://ubuntuforums.org/showthread.php?t=978888) during the initial parts of installation, so in this guide, I use the netboot installation image instead.
Prerequisites
In this guide, you will require the following:
Computer Device capable of booting from USB devices
32MB or greater USB storage device.
Ethernet cable.
A netboot installer image.
Ubuntu Jaunty (http://archive.ubuntu.com/ubuntu/dists/jaunty/main/installer-i386/current/images/netboot/mini.iso)
Ubuntu Lucid (http://archive.ubuntu.com/ubuntu/dists/lucid/main/installer-i386/current/images/netboot/mini.iso)
Debian Lenny (http://ftp.nl.debian.org/debian/dists/lenny/main/installer-i386/current/images/netboot/mini.iso)
Debian Squeeze (http://ftp.nl.debian.org/debian/dists/squeeze/main/installer-i386/current/images/netboot/mini.iso)
uNetBootin (apt:unetbootin) to be installed on your current OS.
Installation
Without going into vast detail, load the netboot image onto the USB pendrive using uNetBootin, and reboot.
I won't dictate how you will setup your installation configuration, so anything outside of what is noted below is left to your own discretion.
What I will note though is that with the netboot installation, you will need to be hooked up to the internet via an ethernet cable throughout the entire installation.
The images are there for a point of reference, to help aid the familiarity of the procedure if you have never done this before.
Check disk/Randomise Blocks
The first step is optional, it is not really required, but can be recommended. Since the disk may go through some stress during the installation period.
When you reach the "Partition Disk" stage (see first screenshot below), switch to a console by pressing Alt+F2
Press Enter to activate the console and type in the following.
/sbin/badblocks -c 10240 -s -w -t random -v /dev/sda
This will check the entire hard drive, with the effect of filling it with random bits of data. On a 160GB hard drive, this can take up to 4 hours.
Once complete, you can switch back to the installation by pressing Alt+F1
Partitioning Disks
How you go about doing this is up to you. Generic installation setups will generally follow the image guide I've laid out below.
When asked about which partitioning method you want:
Select "Guided - use entire disk and set up with Encrypted LVM".
Select the disk you want to perform the action on.
Select "Yes" to confirm that you want to save changes to disk.
This will create an encrypted partition with an LVM inside with two partitions for you. The LVM partitions at this point are not formatted.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-0.png
Enter in the passphrase that will be used to decrypt the encrypted filesystem twice.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-1.png
And lastly, again, what you do here is optional depending on what you want, but the majority of users can just type in max when asked for the amount of the volume group you want to user for partitioning the LVM.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-2.png
Blanking the LVM filesystems
Next, you will come to a page asking you to confirm the filesystems layout that you want to use in the LVM.
On Jaunty, by default, the root filesystem is ext3, which through experience is something I don't really recommend on Netbooks. Through testing, ext2 or ext4 are noticeably faster.
So, I advise to work through the following:
Select "No" and you will be taken to an advanced partition layout screen.
Scroll up near the top and you will see the root filesystem, highlight the line and press Enter.
Select "Use As" in the partition menu, and select an alternate filesystem to use.
I use Ext4, others may want Ext2, or ReiserFS.
Select "Done setting up this partition" to leave the menu.
Then select "Finishing partitioning and write changes to disk".
Then you will be back to the original screen.
Don't proceed with the installation just yet, as there is one more thing to do.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-3.png
Once you've done setting up the partitions, press Alt+F2 to switch to a console and press Enter to activate it if you haven't done so already.
Type in the following, and a list of mounted volume groups will be shown.
ls /dev/mapper/
To identify which is the root partition, it should have a -root suffix. The prefix being the hostname you chose to give the OS.
After finding it, run the following:
dd if=/dev/zero of=/dev/mapper/netbook-root
where netbook-root is the location of the root filesystem.
Doing this should be a more efficient use of cryptographic primitives, as now you're using dm-crypt as it was designed, instead of using SHA-1 as a PRNG. a third party user has verified (http://www.saout.de/tikiwiki/tiki-index.php?page=EncryptedDevice) that these zero-filled sectors will not be identical, which suggests that this is suitably secure. And if it isn't secure by some chance, then dm-crypt itself has a serious weakness, as filesystems tend to have repeated blocks of data on them from time to time.
As a worse case scenario, if stolen, whoever has your Netbook/Laptop may be able to tell how much of the filesystem is used, and have a known plaintext (all zeroes) for a cryptanalytic attack. But I'm not expecting them to be that smart in the first place.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-4.png
With that job finished, you can switch back to the installation by pressing Alt+F1 and select "Yes" to confirm the partitioning of the LVM.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-5.png
Encrypted Home Directory
When asked if you want to encrypt your Home Directory, I selected yes, for Onion Layers sake. As if someone did manage to decrypt/analyse my hard disk, then they should hopefully have a harder time attempting to decrypt/analyse my personal data.
NOTE: A colleague advised having an encrypted home folder ontop may be a bit overkill, and may result in losses of read/write access speed.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-6.png
Software Setup
Lastly, you are given the option to select what software you want to install.
I recommend Xubuntu, as it is light. But everyone will have their own preference, and if in doubt, Ubuntu has an option for you to manually select packages via aptitude.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-7.png
HowTO: Encrypted LVM Installation on a Netbook
I'll start this guide off with a warning.
ENCRYPTED FILESYSTEMS CAN BE A FORMIDABLE AND UNFORGIVING SETUP.
IF THE SYSTEM GOES INTO AN UNBOOTABLE STATE, RECOVER WHAT YOU CAN WITH THE LUKS PASSWORD ON A LIVECD/LIVEUSB.
YOUR ONLY OPTION IS TO REINSTALL THE OPERATING SYSTEM, LOOSING ALL DATA IN THE PROCESS.
IF YOU FORGET YOUR PASSWORD, THERE IS NOTHING THAT CAN BE DONE TO RECOVER ANY DATA.
And as such, I am not liable for any loss of data, as the smart user always makes backups.
Introduction
This is part one of a two part guide.
Inspiration for this guide comes from the popularity of netbooks and other small, portable devices.
As great as they are, the security implications are at a higher risk as our fallibility and tendencies to loose such devices - and the sensitive data on them - becomes a greater threat.
With normal Laptops that come supplied with a CD Drive, the Ubuntu Text-based installation (http://releases.ubuntu.com/9.04/ubuntu-9.04-alternate-i386.iso.torrent) offers the feature to encrypt your hard drive. But due to size restrictions, there is no CD Drive, and putting it on a USB pendrive will produce a Alternate CD Install Error: "Cannot find CD" (http://ubuntuforums.org/showthread.php?t=978888) during the initial parts of installation, so in this guide, I use the netboot installation image instead.
Prerequisites
In this guide, you will require the following:
Computer Device capable of booting from USB devices
32MB or greater USB storage device.
Ethernet cable.
A netboot installer image.
Ubuntu Jaunty (http://archive.ubuntu.com/ubuntu/dists/jaunty/main/installer-i386/current/images/netboot/mini.iso)
Ubuntu Lucid (http://archive.ubuntu.com/ubuntu/dists/lucid/main/installer-i386/current/images/netboot/mini.iso)
Debian Lenny (http://ftp.nl.debian.org/debian/dists/lenny/main/installer-i386/current/images/netboot/mini.iso)
Debian Squeeze (http://ftp.nl.debian.org/debian/dists/squeeze/main/installer-i386/current/images/netboot/mini.iso)
uNetBootin (apt:unetbootin) to be installed on your current OS.
Installation
Without going into vast detail, load the netboot image onto the USB pendrive using uNetBootin, and reboot.
I won't dictate how you will setup your installation configuration, so anything outside of what is noted below is left to your own discretion.
What I will note though is that with the netboot installation, you will need to be hooked up to the internet via an ethernet cable throughout the entire installation.
The images are there for a point of reference, to help aid the familiarity of the procedure if you have never done this before.
Check disk/Randomise Blocks
The first step is optional, it is not really required, but can be recommended. Since the disk may go through some stress during the installation period.
When you reach the "Partition Disk" stage (see first screenshot below), switch to a console by pressing Alt+F2
Press Enter to activate the console and type in the following.
/sbin/badblocks -c 10240 -s -w -t random -v /dev/sda
This will check the entire hard drive, with the effect of filling it with random bits of data. On a 160GB hard drive, this can take up to 4 hours.
Once complete, you can switch back to the installation by pressing Alt+F1
Partitioning Disks
How you go about doing this is up to you. Generic installation setups will generally follow the image guide I've laid out below.
When asked about which partitioning method you want:
Select "Guided - use entire disk and set up with Encrypted LVM".
Select the disk you want to perform the action on.
Select "Yes" to confirm that you want to save changes to disk.
This will create an encrypted partition with an LVM inside with two partitions for you. The LVM partitions at this point are not formatted.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-0.png
Enter in the passphrase that will be used to decrypt the encrypted filesystem twice.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-1.png
And lastly, again, what you do here is optional depending on what you want, but the majority of users can just type in max when asked for the amount of the volume group you want to user for partitioning the LVM.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-2.png
Blanking the LVM filesystems
Next, you will come to a page asking you to confirm the filesystems layout that you want to use in the LVM.
On Jaunty, by default, the root filesystem is ext3, which through experience is something I don't really recommend on Netbooks. Through testing, ext2 or ext4 are noticeably faster.
So, I advise to work through the following:
Select "No" and you will be taken to an advanced partition layout screen.
Scroll up near the top and you will see the root filesystem, highlight the line and press Enter.
Select "Use As" in the partition menu, and select an alternate filesystem to use.
I use Ext4, others may want Ext2, or ReiserFS.
Select "Done setting up this partition" to leave the menu.
Then select "Finishing partitioning and write changes to disk".
Then you will be back to the original screen.
Don't proceed with the installation just yet, as there is one more thing to do.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-3.png
Once you've done setting up the partitions, press Alt+F2 to switch to a console and press Enter to activate it if you haven't done so already.
Type in the following, and a list of mounted volume groups will be shown.
ls /dev/mapper/
To identify which is the root partition, it should have a -root suffix. The prefix being the hostname you chose to give the OS.
After finding it, run the following:
dd if=/dev/zero of=/dev/mapper/netbook-root
where netbook-root is the location of the root filesystem.
Doing this should be a more efficient use of cryptographic primitives, as now you're using dm-crypt as it was designed, instead of using SHA-1 as a PRNG. a third party user has verified (http://www.saout.de/tikiwiki/tiki-index.php?page=EncryptedDevice) that these zero-filled sectors will not be identical, which suggests that this is suitably secure. And if it isn't secure by some chance, then dm-crypt itself has a serious weakness, as filesystems tend to have repeated blocks of data on them from time to time.
As a worse case scenario, if stolen, whoever has your Netbook/Laptop may be able to tell how much of the filesystem is used, and have a known plaintext (all zeroes) for a cryptanalytic attack. But I'm not expecting them to be that smart in the first place.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-4.png
With that job finished, you can switch back to the installation by pressing Alt+F1 and select "Yes" to confirm the partitioning of the LVM.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-5.png
Encrypted Home Directory
When asked if you want to encrypt your Home Directory, I selected yes, for Onion Layers sake. As if someone did manage to decrypt/analyse my hard disk, then they should hopefully have a harder time attempting to decrypt/analyse my personal data.
NOTE: A colleague advised having an encrypted home folder ontop may be a bit overkill, and may result in losses of read/write access speed.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-6.png
Software Setup
Lastly, you are given the option to select what software you want to install.
I recommend Xubuntu, as it is light. But everyone will have their own preference, and if in doubt, Ubuntu has an option for you to manually select packages via aptitude.
http://iainbuclaw.files.wordpress.com/2010/05/screenshot-encryped-7.png