Trimming Your SSD

Kingston SSD Ready for InstallationNearly three years ago, I wrote an article on optimizing for SSDs under Linux. Recently, I decided to revisit the issue after reading a recent blog post.

The recommendation at the time was to enable TRIM support, using the discard option to mount the drive. The first question is, if this is such a good idea, why isn’t it enabled by default? Why do you have to add it to your options, like below?

/dev/sda1 / ext4 discard,defaults

It turns out that enabling the discard option does have a performance hit on deletes. So, how do you keep your SSD Trimmed and avoid a costly performance penalty?

It turns out you can trim manually using the fstrim command, and set up a cron job to run this command once a day. The command takes only one argument by default, the mountpoint of the partition.

Seems like something worth thinking about. However, with the majority of the systems I run SSDs on, the solid state acts an an OS drive. Therefore, the number of deletes are minimal compared to writes.

In the end, enabling TRIM on your drive ensures that the drive will have the best wear-leveling and performance, but there is a cost. For some systems, it is just easier to mount with the discard option, others to run fstrim.

Planning for and Optimizing Solid State Drives

This past week, we installed our first Solid State Drive. We had a lot of concern about this technology early on. There were reports of gradual performance degradation.This has been improved, however, and we’ll discuss some ways to better optimize your experience. Hopefully, in future Linux releases some of these options will be configured automatically

The biggest development that has been made to preserve longevity on these drives is TRIM. The TRIM command allows the operating system to inform the drive which data blocks are no longer in use and can be wiped. TRIM is supported beginning in kernel 2.6.33 and can be enabled under Linux by editing the mount options to include the discard option, such as in the below example.

/dev/sda1 / ext4 discard,defaults

Other suggestions include removing journaling and limiting read and writes to the drive. This will extend life as well, but without journaling, there is some risk of data loss in the event of a crash. However, Theodore Tso debunked this thought last year in a blog post, in which he concluded that the overhead is minimal.

  • Another Linux-based tuning technique is to disable Linux from writing the last accessed time to files. This can be done by adding noatime to the above command. Realistically, on many computers the last accessed time is not extremely important. Do not confuse accessed time with the last modified time.
  • Add the option elevator=deadline to your grub boot configuration to use the deadline disk scheduler. If you have a slower CPU go for the noop scheduler. The default schedulers are optimized for traditional hard drives.
  • Move your Firefox Cache to RAM – Open Firefox and enter about:config in the location bar.  Right-click and choose the option New->String.  Enter “browser.cache.disk.parent_directory” for the preference name, and for the string value enter “/dev/shm/”. That will also reduce writes and improve performance.
  • Reduce kernel swappiness(the tendency for the OS to swap from physical memory to a hard drive based swap file). Add vm.swappiness  = ? to /etc/sysctl.conf. Default is 60, out of 0-100. Some suggest lowering it all the way to 0. Experiment with what works for you. This suggestion is not limited to systems with SSDs.

Bear in mind for the Firefox and Swappiness suggestions, you should have enough RAM to support reducing the swap and moving the cache to memory.

Now that we’ve covered optimizing the solid state drive, let’s discuss usage. We used the Kingston 30GB SSD, reviewed here in comparison to the Intel value SSD, which we also considered. The SSD, because of price and size considerations, is not ideal for all functions. You can see a picture of it just before install in the laptop we used to write this blog entry above.

SSDs are small in size, but speedy. Their best use is as an operating system drive. In our first test case, which is a laptop, they are the only drive. However, the laptop is mostly OS only. All media and other files are stored on a file server. With this drive, the laptop flies along and is extremely quiet as an SSD makes no noise. We have not done any battery life tests, but there is some evidence from those who have that some SSDs may be less energy efficient than conventional hard drives.

In conclusion, with the price of SSDs continuing to drop, it is a good time to start considering it as a boot/OS drive for your systems. Now that we’ve grown comfortable with its usage, we plan on expanding it to future renovations, including in our file server.

Update(06/03/10): The day after we wrote this, AnandTech released a review of three SSDs, including our Kingston 30GB as well as the Onyx and Intel budget SSDs. Certainly makes us feel better about our purchase.

Linux for Netbooks

Knoppix to the rescue / Knoppix al rescate
Image by Oneras [what about peace?] via Flickr

We’ve been expanding our reading to include a variety of new information sources daily. After our recent thoughts on netbooks, we did a little research and found out that Knoppix released a new version last month.

We admire Knoppix, which was the original bootable live Linux CD, and did a lot to advance the cause. Now every distribution offers a live CD, but Knoppix is still known for its flexibility. Recently, Dmitri Popov of Linux Magazine said that due to its excellent hardware detection, blazingly fast boot process, and the lightweight LXDE desktop environment(which we previously mentioned), Knoppix 6.0 makes a perfect distro for netbooks.

Even though it isn’t designed specifically for netbooks, Knoppix can be installed to a USB key and offers a variety of boot options that would work. Also, the replacement of KDE with LXDE lightens the load considerably. Popov follows up in an additional article here. In that article, one of the commenters points out that most standard distributions are not optimized for the Atom processor, nor are they customized for the Solid State Drives(SSD) common on some systems.

Solid State Drives are limited in the number of writes compared to a conventional hard drive, but offer fast reads. Originally the primary drive type in netbooks, they have been replaced with more convention hard drives due to various problems in their longevity and reliability. One only need to read reviews of these items over at Newegg to see some complaints, leading us to believe that until further notice, SSD drives should not be relied on as a primary drive. There are ways to partition your drives to reduce wear, however.

A few distributions customized for netbooks are available. Easy Peasy is a customized distribution of Ubuntu for netbooks. Ubuntu has a Netbook Remix shipped with several netbooks based on the Moblin Project. The Moblin Project, sponsored by Intel, aims to create a netbook OS based on Linux and optimized for its Atom processor. Intel switched from an Ubuntu to a Fedora base for the project, claiming the move to Fedora was largely a “technical decision based on the desire to adopt RPM (Red Hat Package Manager) for package management” instead of Ubuntu’s Debian DEB extension. RPM offers the advantage of containing license information, thereby enabling developers to create collections of software by license type or exclude software by license type.

An alternative is Eeebuntu, another customized Ubuntu distribution specifically for the Eee, possessing a custom kernel for those machines. For additional distributions, check out Linux Netbook, or similiar sites.  Our favorite distribution, Fedora, is behind, although there is a SIG for Fedora Mini, which may pop up as a future spin. They are already focused on reducing dependencies so Fedora could fit into the smallest space possible for netbooks, mobile internet devices, and possibly future set top box hardware.

We look forward to more, as more distributions create optimized versions for the Atom Processors and special spins designed to work with these netbooks. Keep reading.

Reblog this post [with Zemanta]