ArchLinux setup on a Thinkpad e330

I have a Lenovo Thinkpad Edge e330:

  • Intel i5-3210M CPU @ 2.50GHz
  • 8GB RAM
  • 16GB SSD + 500GB HDD "hybrid" drive
  • Intel HD 4000 + nVidia Geforce 610M
  • 13'' non-glare screen 1366x768 resolution
I comes with Windows 7, but I have installed my distro of choice on it, ArchLinux.

The hybrid lie

Lenovo advertises the laptop as if it has a hybrid drive with 500GB of capacity and 16GB of SSD cache. But when I opened it to add 4GB of extra ram I found that there are actually two disks, one rotational disk of 500GB and one SSD with 16GB. All the cache magic is happening at software level, thanks to some utilities installed on Windows.

So the first step was to get rid of all the bloatware that came with Windows. I didn't remove Windows because it may be useful one day, I might need IE and I like to play games. It comes with tons of crap, like evaluation versions of antiviruses or office suites, and with Express Cache, a utility from Condusiv to convert the SSD into a cache. So I removed it.

After that, the SSD disk was unused and ready to be partitioned and converted into a ext4 filesystem.

Partitioning

I divided my Linux into these partitions:

  • / in the whole 16GB SSD
  • /opt/ is a 5GB partition in the HDD
  • /home/ is a 350GB partition in the HDD
  • swap is a small 1536MB partition in the HDD
  • /run/ is a tmpfs mounted in RAM
  • /var/tmp/ in RAM
  • /var/spool/ in RAM
  • /tmp/ in RAM
You can find my fstab file in pastebin, you will notice something weird with the /home/ partition, ignore it, I'll explain it latter.

The most important things here are the options of the / (root) partition:

rw,noatime,nodiratime,discard,errors=remount-ro 0 1

Because / is on the SSD, I mounted it with some special parameters to ext4 so it goes gentle on the drive and increases performance. The key is the discard option, this activates the TRIM command, which is a specific mode of operation for SSD disks, you can learn more about it in the previous link to the fabulous ArchLinux wiki.

You will read around the web that you also need to change the I/O scheduler from CFQ to noop or deadline. Well, it seems that nowadays the CFQ scheduler is smart enough to realize it is dealing with a SSD disk, so it optimizes accordingly. No need to change the scheduler then.

Home encryption

I wanted to encrypt my home partition to satisfy my inner paranoid and for those times when you have to send the machine to the technical support center.

First I recommend you to read this wiki page, it is long but very instructive. After reading it thoroughly I chose to use dm-crypt with LUKS. Read that link too, I know it is long but it is worth your time.

I chose to use a pass-phrase instead of a pendrive key. Execute this command to encrypt the partition:

cryptsetup --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random --verify-passphrase luksFormat /dev/sdb7

It will ask you to confirm writing YES all in uppercase letters. Don't forget about the uppercase thing. It will also ask you for the pass-phrase. It is possible to use several keys thanks to LUKS, in case you have more than one user, you can read more about it in the Arch wiki.

Once it has prepared the partition and the pass-phrase has been established, I opened it with this command:

cryptsetup luksOpen /dev/sdb7 home

This created an entry on /dev/mapper/ called home. That is the partition mounted and accessible. Then I proceeded to format it using:

mkfs.ext4 /dev/sdb7

The only thing left to take care of was mounting the thing when the system booted. For that I used the crypttab file. Is like fstab but for your encrypted partitions, you can find it in /etc/. I added one line to it:

home  /dev/disk/by-uuid/xxxxxx-xxx-xxxx-xxxxxxxxxxxxxx   none   luks,tries=3

This will create a virtual and accessible partition on /dev/mapper/ with the name "home". It will do it at boot, and it will ask for your pass-phrase then. Having that line in the crypttab file is not enough, the partition must be declared on the fstab so it gets mounted. It is like any other partition, just remember to point it to /dev/mapper/home instead of the regular device (see? I told you I would explain that fstab line). Here is my complete fstab.

Wrapping things

Well, this is my laptop configuration, I hope it would be useful to somebody. Check also this post from my pal Lorenzo Gil, he doesn't use ArchLinux (nobody is perfect) but you will find some useful tips there.

Show Comments