Turn your Linux PC into a gaming machine

While processors, graphics cards, RAM and network connections have all got faster over the years, hard drive technology seems to have moved on very little.

Hard disk drives still use mechanical parts, and are therefore among the heaviest, slowest, least reliable and most power-hungry components in a typical computer.

SSDs (solid state drives) are changing that though, and are one of the most exciting developments in PC hardware in the past five years.

In this section, we're going to look at these miraculous devices. As well as comparing the two drives we have here, we're going to answer the most common questions people have about SSDs: '"Are they worth it?", "How long will they last?" and "How can I get the best out of mine?'"

Are SSDs worth it?

Traditional hard drives contain a spinning disk, which is coated with a magnetic material. This magnetic material gets manipulated by a read/write head as it flies over the disk, and is what stores the data.

In contrast, SSDs have no moving parts. Instead, they're made of millions of tiny transistors (of the floating gate variety), each one capable of storing one bit of information. Because they have no moving parts, they're quieter, lighter, more energy efficient, more durable and faster.

This is obviously great if you're intending to use the drive in a laptop, where space, energy use and noise are all major considerations. The increased speed of the drive will also have a huge impact on PC and application startup times (and any other operation that reads from the disk a lot), and can make your computer feel dramatically quicker.

All of these benefits sound great, but SSDs are not without their downsides, and you should take these into consideration before deciding to invest. Most notably, you can't buy SSDs that are as large as traditional-style mechanical hard drives, and they're much more expensive.

Parts for penguins

For example, the Crucial M4 128GB that we have on test costs around £80; the same cash will net you a 2TB hard drive. If you need a lot of space or are on a very tight budget, an SSD might not be for you.

The answer to the question of whether SSDs are worth it, then, is: "It depends on how you use your computer."

Lifespan

Two common concerns that people have about SSDs are how long they last, and whether the performance you get when they're new will last all the way to old age. These concerns certainly aren't unfounded.

The transistors in an SSD will last only for approximately 10 years, or 10,000 writes, whichever comes first - so they have a limited life. What's more, in some early models, badly designed firmware meant that performance could degrade significantly over time.

In modern drives, with a modern operating system and filesystem, the significance of these problems has been reduced massively thanks to something called TRIM. This helps the drive's firmware to manage the allocation of blocks of data, ensuring that each transistor is written to the minimum number of times without degrading performance.

How big an impact does TRIM have? In one of the most authoritative articles on the subject, Anand Lal Shimpi found that on an aged drive, write performance was just 52 per cent that of a clean drive without TRIM; with TRIM, the aged drive performed at 98 per cent that of the clean one. TRIM is worth enabling.

So, how do you get TRIM working? The first thing to do is make sure that your drive supports it. If it has been bought in the last few years, it almost certainly will, but anything older and you'll need to check whether it's supported. You can do this with the hdparm command, as follows:

hdparm -I /dev/ | grep "TRIM supported"

Remember to replace with the device name of your SSD. If that command returns something, then you're ready to enable TRIM in the operating system.

To do this, you need to format your partitions with either the ext4 or btrfs filesystem. These are the only two that support TRIM. Here at PCF towers, we use ext4, since btrfs is still lacking a stable repair tool, which makes it less able to recover from disaster, and we recommend that you do the same.

Modify the mount

After that, you will need to modify the mount options of the filesystems, as they don't enable TRIM support by default. This can be done by editing the /etc/fstab file. Before making any modifications to the file, however, make sure you create a backup, as if you get things wrong in this file, it can stop you from booting.

cp /etc/fstab /etc/fstab.bk

If anything goes wrong at this point, you can always boot to a live CD, reverse the copy and then reboot your system to get it working again. With the backup in place, you need to modify, on each line that describes a partition on your SSD, the part that has the word 'defaults' in it. To this, you want to add ,discard, so that the entire line looks something like this:

/dev/sda1 / ext4 defaults,discard01

That's it. Now you just need to save the file, reboot, and your drive has TRIM support enabled. This is the most important tweak to apply to your SSD.

Extending life

There are other ways to tweak your drive and extend its life still further.

The easiest of these other techniques is to add the noatime option to your mount options, just like we did with discard above. Normally, Linux filesystems store the last time a file was read from, and the last time it was modified. With the noatime option, it will store only the last time it was modified, reducing the number of writes in order to keep this metadata up to date and increasing the life of your drive.

A word of warning, however: older applications, such as Mutt, won't function properly if you enable noatime, so first check application compatibility.

You can also increase the life of your drive by thinking carefully about what partitions you put on it. For instance, if you have a traditional hard drive available on your system as well, you might consider using the SSD for filesystems that don't change frequently, such as / and /home, while putting things such as /var, /tmp and swap on the spinning disk.

If this isn't an option, you can make other changes to reduce the frequency of writes to these directories. For instance, you can increase the severity of log messages which will be recorded by editing the /etc/rsyslog.conf file (see man rsyslog. conf for details), or you can decrease your system's 'swappiness', which encourages it to use swap space less frequently. You can do this by executing:

echo 1 > /proc/sys/vm/swappiness

The underlying storage technology in most SSDs varies little. What makes the biggest difference to their performance is the controller and firmware - the hardware that decides how and where to write your data on the drive. A bad controller can slow your drive down, particularly as it ages, and can lead to varying performance across different-sized writes (like 4k vs 9k).

The two test drives that we have represent two competing controller solutions. The Crucial M4 uses a Marvell controller, while our Intel 330 uses a Sandforce one. These same controllers are used on many different drives, so our results will be able to inform your buying decisions, even if you don't choose either of the specific drives we have on test.

We tested the drives using the Postmark, Compile Bench and Kernel Unpacking tests in the Phoronix Test Suite, with a view to seeing how the drives performed in real situations. All of the tests were carried out on an Ubuntu 12.04 system, with ext4 and the discard option set in /etc/fstab.

The Compile Bench test is perhaps the most interesting, as its operations attempt to simulate operations that age a filesystem - the most likely scenario to tax the controller. On these tests, the Intel drive, with a Sandforce controller, performed much better. That said, the Crucial drive was much quicker when it came to dealing with many small files in the PostMark test, and marginally better when unpacking the kernel.

Both drives are in the same price bracket, being available online anywhere from £84 and upwards.

Benchmarks

SSD bench