Gregory Hildstrom Projects Publications Resume Contact About Youtube

SSD and Btrfs

After my semester ended and I got my final grades, I thought it was time to backup/rsync my HP Pavilion g7-1117cl laptop to my external USB 2.5" hard disk drive (HDD) again. Unfortunately, somewhere in the middle of the rsync, it would hang and my laptop would become mostly unresponsive. After a hard reboot, the Windows 7 system log showed hardware errors on the internal HDD. I had to exclude a few files and truncate a few large video files, but I ended up getting most everything since my last backup. My Windows 7 experience definitely degraded a bit over time, but not quite as bad as previous versions of Windows.

I decided to breathe some life into my 1.5-year-young dual-core laptop with both hardware and software changes. I maxed out the memory at 8GB and got an ADATA XPG SX900 256GB solid state drive (SSD) to replace my failing HDD. I installed the new hardware and installed Fedora 18 Linux last night. I've been curious for a while, so I chose to use the Btrfs file system instead of ext3/ext4/LVM because of its snapshot, copy-on-write, and wear leveling features. The Fedora 18 installer still uses ext4 for the small boot partition. I rebooted into single user mode and updated the mount options in /etc/fstab. I added "noatime,nodiratime,discard" to all of the partitions; the Btrfs partitions already had the "ssd" option set. I did not configure a swap partition. So, here was my configuration:

Wow! This thing is fast now! I mean crazy fast compared to the previous Windows 7 on a conventional HDD. It also feels much faster than my Linux workstation on a conventional HDD at work. Power on, boot, and 10-character-password login to a usable desktop takes about 33 seconds. For comparison, my Nexus 10 tablet is usable after about 24 seconds. So, there's still some work to do, but I'm happy so far. I installed Chrome, installed some codecs, and restored all of my files from backup. Almost everything worked immediately. After an update, the only issue seems to be that the built-in webcam doesn't work, but I think a little tinkering can take care of that. This has been a much more pleasant experience than my last Linux laptop effort several years ago. A friend of mine had an SSD failure in his MacBook Pro after a couple years, but he confirmed that he was using OSX HFS and he had not enabled noatime, nodiratime, or discard. He also ran some virtual machines without any special consideration toward reducing writes or wear leveling. I hope this configuration will help my SSD last.

Update

I took a similar approach on my workstation at work, but with a 512GB SSD. It had been working great for 6 months or so, but then I ran into a major annoyance with btrfs. I tried to crate another virtual machine, but it failed with a no free space type of error. The standard 'df' command said I had plenty of free space. The old copies in the copy-on-write scheme were taking up what would otherwise be usable space. I was not using any snapshots, so this turned out to be quite annoying and seemingly avoidable. I had to run 'btrfs fs show /dev/sda3' to see the difference between free space and file system free space. The temporary fix was to manually balance the file system with 'btrfs balance start /home', which _slowly_ cleaned things up and made the free space approximately the same as the file system free space. Did I mention that this was slow and things were pretty unresponsive during the balance? Since I wasn't really taking advantage of btrfs-specific features, I decided to switch to ext4 for familiarity, speed, and simpler free space reporting. I found a great article about layered TRIM/discard support in Linux, but my file systems are on the raw disk partitions.

For maximum speed and minimum writes, any virtual machines should also mount their filesystems with "noatime,nodiratime" if possible.