Installing and Optimizing an SSD with Ubuntu Jaunty

written by bryan on March 23rd, 2009 @ 12:19 PM

With Anand's latest review of SSD's and Linus' endorsement of that review, it seemed like a good time to move my noisy hard drives to the basement and switch to an flash based hard drive (AKA solid state drive: SSD).

The 30GB Vertex SSD is currently CAD$ 160. Getting anything other than the smallest one seems very silly - I assume that prices are going to drop like a rock, so it'd be very painful to spend much more than that on anything that will be worthless in a year or two.

Luckily, Linux will fit very easily into 30GB. The plan is to put just about everything except for the operating system and work onto the NFS server in the basement.

The process did not go very smoothly at all. I highly recommend staying away from the Vertex drives for a few months to let them mature. But if you insist, here's the procedure I went through.

The first thing I had to do was upgrade my kernel to 2.6.29. The SSD worked for a little while, and then failed completely. It appeared to work on an Intel based machine, but my AMD 780G machine was not happy at all. I even went through the hassle of installing Windows XP to see if it worked there, but XP didn't even see the drive. Note that my other machine appeared to work fine with the SSD, so I think it's sort of SB700/SSD interaction. Others have reported issues on the forum as well.

The first thing you'll probably want to do is a secure erase of the drive. SSD's slow down as they're used, so starting fresh is essential. Warning, this will completely erase any ATA drive, so make sure you have that drive letter right!

hdparm --security-erase NULL /dev/sda

Following Ted Tso's instructions on how to properly align the partitions for maximum speed:

fdisk -H 224 -S 56 /dev/sda
# enter 'n, p, 1, 1, 5082' at the prompts to create a partition covering the entire drive
# enter 'x, b, 1, 256, w' to move the start of the partition into alignment
mke2fs -t ext4 -E stripe-width=32,resize=50G /dev/sda1
mkdir /mnt/ssd
mount /dev/sda1 /mnt/ssd

Now follow these instructions to copy your operating system over to the new drive. We're going to copy over everything except for /home/blarsen, which we're going to mount over NFS.

ls / > ~/root_files
vi ~/root_files  # remove proc, sys, mnt, home et cetera
tar --create --one-file-system --file - `cat ~/root_files` | (cd /mnt/ssd ; tar xvf -)
mkdir /mnt/ssd/proc
mkdir /mnt/ssd/sys
mkdir /mnt/ssd/mnt
mkdir -p /mnt/ssd/home/blarsen
chown blarsen.blarsen /mnt/ssd/home/blarsen

Let's set up our fstab to nfs mount /home/blarsen, and run tmpfs on /tmp and /var/tmp. The size parameter to tmpfs is a maximum size -- it doesn't use any RAM if it isn't needed. The default is half your RAM, so you'll probably want to limit down a bit.

cat > /mnt/ssd/etc/fstab
bulti:/home/blarsen     /home/blarsen           nfs             rsize=8192,wsize=8192,timeo=14,intr,noatime,nodiratime 0 0
none    /tmp            tmpfs     size=500M,mode=777,auto      0       0
none    /var/tmp        tmpfs   size=500M,mode=777,auto       0       0

Change your root partition in fstab:

blkid # to determine the UUID
vi /mnt/ssd/etc/fstab

Now, update the grub menu.lst. These instructions are missing from the tech republic link above. You want to look for the kopt= and groot= option lines. They look like comment lines, but they are actually instructions to update-grub. While you're at it, add "elevator=deadline" to your kopt.

vi /mnt/ssd/boot/grub/menu.lst # update kopt, groot UUID's.  Also add elevator=deadline to kopt
chroot /mnt/ssd

And install grub on the new drive:

grub-install --root-directory=/mnt/ssd /dev/sda

Let's save our SSD by logging to our NFS server. See these instructions from Sun.

cat >> /mnt/ssd/etc/hosts bulti loghost
cat >  /mnt/ssd/etc/syslog.conf
*.*;            @loghost
*.err;*.emerg   /var/log/messages

On your loghost, edit /etc/default/syslogd to add the "-r" option and restart sysklogd.

Switch your network interface away from network-manager so it comes up earlier in your boot cycle:

cat >> /mnt/ssd/etc/network/interfaces
auto eth0
iface eth0 inet dhcp

rsync your home directory to your NFS server.

rsync -av /home/blarsen/ bulti:/home/blarsen/  # those trailing slashes are important

Reboot and enjoy!


  • Wayne on 23 Mar 20:09

    What’s your first impression? The SSD’s look pretty good against a fast desktop drive. Put them up against a slow notebook drive, and it becomes pretty damn tempting. On the other hand though, 30GB isn’t really enough for a standalone drive. And the 80GB X25-M is still $550. Oh well, I guess I can put up with Safari beachballing on me for a while yet.

  • Bryan on 01 Apr 11:45

    Hmmm, I can’t say I’ve noticed much. The big win is on boot—Ubuntu boots faster than my BIOS does. But my home directory is NFS mounted, so that’s slower, and counteracts my root and work directories being on SSD to a large degree. The new machine has a faster processor and more RAM, so that contributes to extra speed. But rails-dev-boost sped things up more than anything else! :)

    P.S. I think it’s time to kill feedburner. Your comment never showed up on my feed.

Post a comment