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:
https://wiki.archlinux.org/index.php/Solid_State_Drives
http://www.void.gr/kargig/blog/2012/01/11/linux-ssd-partition-alignment-tips/

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 void.gr 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=(
        'ata-OCZ-AGILITY4_OCZ-xxxxx',
        'ata-SAMSUNG_SSD_830_Series_xxxxx'
)

for SSD in "${SSDS[@]}" ; do
  BY_ID=/dev/disk/by-id/$SSD

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

    #scheduler
    if [[ -w $SCHED ]] ; then
      echo noop > $SCHED
    fi
   #writeback
   hdparm -W1 /dev/$DEV_NAME
  fi
done

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.

Friday, August 10, 2012

LCDproc on Mac OS X

I had the opportunity to order some small LCD's (HD44780) at a very fair price, since I already got one in my backup-server i tried to get it working on my docked MacBook running Mac OS X (10.8). Took some time, but in the end I got it working with not too much effort.


Steps I took were:

  1. Download LCDproc source from the official website
  2. Install libusb from homebrew (brew install libusb)
  3. Install libftdi from homebrew (brew install libftdi) <-- this was needed because I used a FT245RL brekout board to connect it.
  4. Configure with "./configure --prefix=/usr/local/ --enable-drivers=all --includedir=/usr/local/include/ --enable-libftdi=yes"
  5. make -j6
  6. sudo make install
Then changed /usr/local/etc/LCDd.conf like this: (only changed/added values shown).

[server]
DriverPath=/usr/local/lib/lcdproc/
Driver=hd44780

[hd44780]
ConnectionType=ftdi
ftdi_mode=4
ftdi_line_EN=0x10
ftdi_line_RS=0x20
ftdi_line_RW=0x40

Device=/dev/tty.usbserial-A80048fE
Size=16x2

Of course, you need to have the XCode Command Line tools installed. Also I had the FTDI D2XX driver already installed, the VCP drivers will most likely conflict with libftdi.


I also got it showing my Growl notifications thanks to http://maclcd.blogspot.nl/