Sunday, August 12, 2012

Linux SSD optimalization

Since the SSD prices are dropping and it's still summer vacation so I have a more spare time than usual, I decided to upgrade one of my servers with an SSD. Since the server I upgraded is very multifunctional it could benefit a lot from optimization, it functions mainly as NAS (CrashPlan for Windows, Time Machine for OS X) but is also used as Home Theatre PC (XBMC).

Luckily there are a lot of resources about optimizing your SSD in Linux.

Very helpful resources were:

I ended up doing the following:

  • Partitioning the hard disk with gdisk, which helps me align the partitions
  • Use Logical Volume Management (lvm) 
    • Using the --dataalignment option (see also link) for the physical volume
    • Creating an ext4 partition on the logical volume with adjusted block size and stripe/stride-parameters
  • Mounting the ext4 partition with noatime and discard options
  • Using noop scheduler for the ssd's only (see script below)
  • Mounting /var/tmp and /var/log in ramdisk
  • Enable writeback (see script below)
  • Make the "swappiness" as low as possible
  • Use ionice to give XBMC priority over netatalk/crashplan when watching movies
    This is not because of the SSD, but I moved one of my RAID-0 harddisks from S-ATA600 to S-ATA300 because I expect the SSD will use the higher throughput better but apparently this caused problems (stuttering in movies) when a computer was backing up and watching a movie at the same time..
To set the scheduler and writeback to the right disks I modified the rc.local-script I found on the ArchLinux wiki:

declare -ar SSDS=(

for SSD in "${SSDS[@]}" ; do

  if [[ -e $BY_ID ]] ; then
    DEV_NAME=`ls -l $BY_ID | awk '{ print $NF }' | sed -e 's/[/\.]//g'`

    if [[ -w $SCHED ]] ; then
      echo noop > $SCHED
   hdparm -W1 /dev/$DEV_NAME

I also used this opportunity to switch to UEFI and LVM. Especially the UEFI took a whole lot more than I expected. I will write an article about that later.

No comments:

Post a Comment