Saturday, February 1, 2014

Disk Partition Setup

When I bought my new computer I decided early on that I wanted to create a hybrid disk solution. Having the OS and apps on an SSD was a given but I also wanted to have a large scratch space for rendered video frames, virtual machines and games. That meant buying a conventional hard drive. Since Linux has flexible partitioning, and SSDs last longer with fewer writes, there was an opportunity to optimize things.

First I created GPT disk labels on each drive. On the SSD I created two partitions: one for boot and a second for lvm. Note that I left some room free on the ssd for TRIM and made sure the partitions were aligned. On the HDD I created one partition for lvm. The volume groups were appropriately labeled ssd and hdd.

In the ssd volume group I created two logical volumes: root and home. In the hdd volume group I created the following volumes: var, data (the big scratch space) and swap.

Putting /var on a HDD is recommended because there tends to be a lot of writes. Var stands for variable, after all.

Here is the final configuration:

disk 1 (ssd):
  gpt partition label:
    /dev/sda1: 0% - 512MB ext2 (no journalling required) /boot
    /dev/sda2: 512MB - 80%  lvm
      ssd logical volume:
    /dev/ssd/root: 15GB     ext4    /
    /dev/ssd/home: 150GB    ext4    /home

disk 2 (hdd*):
  gpt partition label:
    /dev/sdb1*: 0% - 66% lvm    
      hdd logical volume:
    /dev/hdd/swap:  4GB swap    swap
    /dev/hdd/var:   10GB    ext4    /var
    /dev/hdd/data:  600GB   ext4    /mnt/data

I also did a couple more tweaks along the same lines. I configured /tmp to be mounted in memory, sym-linked Chrome’s cache directory to be in /tmp and changed Firefox’s browser.cache.memory.enable to true and browser.cache.disk.enable to false.

Honestly, I am not sure that all of this was really necessary, but it is done and I had fun doing it.

* Those labels are not 100% true. More on that in later.