Tag Archives: Ubuntu

Encrypting a Linux home partition with Truecrypt

Scope:

This post will be short (and sweet). We will secure the majority of our personal data by encrypting our home partition. This is important for users with personal or sensitive data on their laptops, as well as other mobile devices such as the Google Nexus 7 when it runs Ubuntu Linux.

General Information:

The steps to encrypt a partition with Truecrypt are probably the easiest ones compared to alternatives such as LUKS and other Linux Kernel built in tools. This involves installing Truecrypt, creating an encrypted partition, copying all the sensitive data into it, deleting the sensitive data from the unencrypted partition it was previously on, and configuring mounting and umounting of the Truecrypt volume during startup/shutdown. You will need to perform this as the root user, and you will need an empty partition which you can encrypt. The steps are generic: they assume you are encrypting a brand new home partition (and not something else), after storing your user data under the /home folder on the root partition. They have been tested on Slackware64 but will work on all Linux distributions. Please adjust the partitions, runlevel scripts and installation procedure for your Linux distribution (as an example, for Ubuntu, Truecrypt might be available via Aptitude repositories vs. a binary installation package, and the runlevels will not be in traditional BSD style).

Procedure:

  1. Install Truecrypt after downloading from here:
    # tar vxf ./truecrypt-7.1a-linux-x64.tar.gz
    # ./truecrypt-7.1a-setup-x64
  2. Create an encrypted Truecrypt partition. You will be asked about the partition, passwords and keyfiles to use:
    # truecrypt --text --create
  3. Mount the new encrypted volume in a temporary location and copy all sensitive data to it. This should be done as root from singleuser runlevel if operating on the /home folder:
    # telinit 1
    # mkdir /tmp/encrypted
    # /usr/bin/truecrypt --text --mount --protect-hidden=no --volume-type=normal --keyfiles= /dev/sda6 /tmp/encrypted
    # cp -aR --preserve=all /home/* /tmp/encrypted/
    # rm -rf /home/*
  4. Configure mounting/unmounting on startup/shutdown:
    Edit /etc/rc.d/rc.S and add the following line after “/sbin/mount -a …”:

    /usr/bin/truecrypt --text --mount --protect-hidden=no --volume-type=normal --keyfiles= /dev/sda6 /home

    Edit /etc/rc.d/rc.6 and add the following line before “/sbin/umount -a …”:

    /usr/bin/truecrypt --text --dismount /dev/sda6
  5. Test with a reboot!

1 Comment

Filed under #!, Slackware

Slackware 13.37 and the ASUS PCE-N13 Wireless Adapter

ASUS PCE-N13

The ASUS PCE-N13 is not especially pretty, but its cheap, fast, and officially supported!

If you are on the market for a wireless adapter for your Linux desktop, the best bang for the buck today seems to be the ASUS PCE-N13. Not only will ~30$ get you a/b/g/n support, 300Mbps transfer rates, 2 antennas and a PCIe bus, but it also says “Linux Support” right on the box, and not in some fine print in an obscure corner. The only card in my local shop to read that, although all of them work just fine. So this is a *moral* choice as well 😉

The card is indeed supported by the rt2860sta module. Unfortunately, with Both Slackware 13.37 and Ubuntu 10.10, the kernel module fails to bind to the card because the various rt2800 and rt2x00 modules conflict with rt2860sta. The module loads, but all attempts to initialize the card result in error messages. To remedy this, simply blacklist the other modules from loading by adding those modules to /etc/modprobe.d/blacklist.conf like this:

# Blacklist rt2800 and rt2x00 modules
# This will allow the rt2860sta module to bind to the ASUS PCE-N13 card:
blacklist rt2800lib
blacklist rt2800pci
blacklist rt2x00lib
blacklist rt2x00pci

2 Comments

Filed under Slackware

Are YOU paranoid? 10 steps for encrypting your Ubuntu HOME.

Are you paranoid? I am.

If you keep most of your work on a net-book/laptop, you should consider the possibility of having it lost or stolen. All the backups in the world will not prevent someone else from having full access to all your personal and embarrassing information. One way to get around this is to encrypt your hard drive. The safest way is to encrypt the whole drive before the operating system is installed. Encrypted installation is offered by Debian, and soon by SUSE.

To be really safe, you should keep check-sums of your unencrypted boot sectors, etc, on your encrypted partition, to prevent tempering with the few unencrypted bits. But, if you didn’t piss the KGB off very recently, you might feel safe with encrypting only the folder that contains your user documents. Under Windows Vista +, that would be \Users\YOUR USER NAME, but I suspect that would inevitably leave some loose ends. One way or another, if your are even slightly paranoid, you are probably not using Windows. On Linux, encrypting your home directory is probably reasonable enough.

Here are 10 steps to accomplish this on Debian/Ubuntu systems (Adapt to your Linux/BSD/OpenSolaris):

1. Install the packages: initramfs-tools, hashalot and lvm2:

$ sudo apt-get install initramfs-tools hashalot lvm2

2. load (or make sure have been built into the kernel) the modules: aes-x86_64 or aes-i586, dm-crypt and dm-mod:

$ sudo modprobe aes-x86_64 dm-crypt dm-mod

3. Create (or designate) a partition that would be encrypted. Allow enough room because I’m not sure growing it later is an option. Any data on it will be destroyed:

$ sudo fdisk /dev/YOUR DRIVE ON WHICH THE TO-BE-ENCRYPTED PARTITION IS

4. Check for bad blocks:

$ sudo /sbin/badblocks -c 10240 -s -w -t random -v /dev/YOUR TO-BE-ENCRYPTED PARTITION

5. Fill you to-be-encrypted partition with random data. Note: (This takes AGES, but makes things safe. By ages I mean ~ 2 hours for every 10 GB):

$ sudo dd if=/dev/urandom of=/dev/YOUR TO-BE-ENCRYPTED PARTITION

6. Setup an encrypted luks volume

$ sudo cryptsetup -y –cipher aes-cbc-essiv:sha256 –key-size 256 luksFormat /dev/YOUR TO-BE-ENCRYPTED PARTITION

7. Unlock it:

$ sudo cryptsetup luksOpen /dev/YOUR TO-BE-ENCRYPTED PARTITION pvcrypt

8. Create a volume group and a volume:

$ sudo pvcreate /dev/mapper/pvcrypt
$ sudo vgcreate vg /dev/mapper/pvcrypt
$ sudo lvcreate -n VOLUME-NAME
-L VOLUME-SIZE vg

9. Create a file-system on /dev/mapper/vg-VOLUME-NAME:

$ sudo mkfs.ext3 /dev/mapper/vg-VOLUME-NAME

10. Edit /etc/fstab. Add the line:

mount -t ext3 /dev/mapper/vg-VOLUME-NAME /home

9. Edit /etc/crypttab. Add the line:

pvcrypt /dev/YOUR-ENCRYPTED-PARTITION none luks,retry=1,lvm=vg

10. This is the fun part: log out all users, switch to a console and login as root. Move the /home directory to be /home-SOMETHING. Create a new empty /home directory, and mount the encrypted volume in it. Then copy the entire contents of your /home-SOMETHING into /home preserving all attributes, times and ownerships. Here’s a few simple steps to do it:

$ sudo mv /home /home-plain

$ sudo mkdir /home

$ sudo mount /dev/mapper/vg-VOLUME-NAME /home

$ sudo cp -aR –preserve=all /home-plain/* /home/

Ready to see if it worked? Reboot! you should do this from the console directly:

$ sudo /sbin/reboot

Upon boot up, when your system tries to mount your /home partition, which is now encrypted, you will be asked for a password before booting continues. After the correct password is supplied, the system boots on.

If you have more locations you would like to encrypt, you can create more volumes on the encrypted volume group. To understand how to, or for a detailed guide for installing Ubuntu Linux on an encrypted volume group  to begin with, see the page from which I’ve adapted the steps above.

Leave a comment

Filed under #!