How to set up an SSD on Linux

I recently bought an awesome new ASUS G53SW and to go along with it I purchased a 128 Gb Plextor SATA III SSD. I wanted to use the SSD for the Mint Linux OS.

It seems that there are a ton of older articles that talk about getting an SSD correctly configured in Linux. I perused through them, and I found several conflicting and incorrect instructions. In the following tutorial I am going to try to present what I have learned, both how to configure and why it is configured that way.

These instructions should work for all Debian based Linux Distros (Ubuntu Mint). Some of the commands may need to be tweaked for Fedora or others.

Before I begin let me just gloss over the paradigms behind SSD drives. SSD drives are fast compared to the traditional hard drives. Traditional hard drives (7200 rpm) get less than 100 Mb/s read rate which degrade over time. SSD’s with SATA III have seen read and write speeds at 500 MB/s. So with SSD’s your application load times are reduced by 80%. However SSD’s are more expensive, smaller, and as they are written to they lose disc space, leading to a short life time if they are written to too much.

Hard Drive Speeds:
More on SSD Technology:

Before you Buy — Is the SSD compatible with your Hardware?

If your computer is new chances are it supports SATA III for its hard drives. If your computer is older check to see what SATA your computer supports. No sense in buying a SATA III device if your computer only supports SATA II. SATA III is completely backwards compatible with SATA I, II but will only get speeds at the SATA I, II levels.

Before you Install — Linux Partition Type

Before you install Linux you will want to consider the partition type. The partition types for a Linux install are ext2, ext3, ext4. There is a fair amount of dispute as to which is best. There are a lot of fans of ext2 and ext4. The default install of most (or all?) linux distros is ext4. Ext4 is a journaled file system. The journal is there for redundancy in the event of hard drive error/failure. It is a lot easier to recover your data with and ext4 system, however the journal adds writes to your SSD. The ext2 partition type does not have a journal so the life of the SSD is lengthened, but it loses the recovery features. Ext3 is a journaled file system with less features than ext4 so it is typically rejected in favor of ext4.

More info on ext2, ext3, ext4:

In the article listed below a pro ext4 person explains his viewpoint that the lifespan of the SSD is so long that having a journaled file system won’t be a big deal unless you plan on using the drive for more than 10 years. I would suggest that for any desktop user ext4 is a good choice. If you are installing the ssd for a server then you might think about ext2 as long as you keep good backups.

Ext4 suppoter:

After Linux Installation — Know Your Hard Drives

If you have multiple hard drives connected to your Linux machine you will want to know which hard drive the name of the hard drive. If you go to your terminal and type in “df -h” you should see something like this.

$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdb6 89G 9.2G 76G 11% /
none 4.9G 588K 4.9G 1% /dev
none 4.9G 536K 4.9G 1% /dev/shm
tmpfs 4.9G 1.6M 4.9G 1% /tmp
none 4.9G 396K 4.9G 1% /var/run
none 4.9G 0 4.9G 0% /var/lock
tmpfs 4.9G 0 4.9G 0% /var/tmp
/home/chris/.Private 89G 9.2G 76G 11% /home/chris
/dev/sda2 466G 54G 413G 12% /media/Windows Starace
/dev/sdb1 26G 9.5G 16G 38% /media/Windows SSD
/dev/sda1 100M 25M 76M 25% /media/System Reserved

Looking at this screen you can tell that I have two hard discs and a couple partitions on each disc. The entries with /dev/sda and then some number are partitions that are on my 7200 rpm Seagate traditional hard drive while entries with /dev/sd2 are partitions on my 128 Gb Plextor SSD. Knowing that the the ssd’s name is “sdb” is important for the upcoming steps. Most people will probably have their ssd name be sda so I will use that in the rest of the tutorial.

After Installation – Benchmark Your Computer’s Speed

Benchmarking the capability of your computer is an important thing to to to know if the changes you made affected the speed.

A simple utility to benchmark the read speed of your ssd is under the administration Gnome menu and is called “Disc Utility.” You can start it from the command “palimpsest”. Click on the ssd and click benchmark.

Note that benchmarking the write speed of your SSD should be done sparingly, it will use up a lot of writes. If you are concerned then perhaps you should skip benchmarking your computer.

I recommend a utility called Bonie++ for testing the write speed of your ssd. It should be available under your package/software manager. Once it is installed run theses commands.

bonnie -d . >ssdtest.mark
#wait for the benchmark process to finish takes some time
bon_csv2html ssdtest.mark > ssdtest.html
firefox ssdtest.html

This should popup your bonnie++ specs in firefox.

After Installation — Changing the Linux Disc Scheduler

The hard drive scheduler attempts to organize hard drive requests in a way that is efficient. However organization is so old school. With SSD’s the memory access is instantaneous and many of the schedulers that were designed for spinning hard drives will only get in the way of SSD performance.

There are four types of schedulers in the Linux World. Anticipatory, Completely Fair Queuing, Noop, and Deadline. Anticipatory scheduling tries to arrange hard drive reads in a way that will maximize efficiency on a spinning disc. Completely Fair Queuing (cfq) is an anticipatory scheduler that adds in a ranking system for important disc reads. Neither of these are suited for an SSD.

The noop is a simple first in first out queue. The deadline is a biased noop queue that allows an application to get some access to the disc even if another application has already requested it.

The deadline is the best scheduler because it has more features than the noop and doesn’t worry about a rotating disc like cfq. To see what scheduler you are currently using go to your command line and look at this file

cat /sys/block/sda/queue/scheduler

You should get something that looks like this

noop deadline [cfq]

The option in brackets is the scheduler that is currently being used by your system, notice that this is currently the cfq. We want to change this to deadline. To do this we are going to edit the file /etc/default/grub. Type “sudo gedit /etc/default/grub” to edit the file. There should be a line of code that looks like this

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash elevator=deadline"

To make the scheduler add in the elevator=deadline option that is highlighted in red. Be sure to put a space after the previous option. You may have more options than I do and that is perfectly fine. After you make this change reboot your computer. Run the “cat /sys/block/sda/queue/schedule” command and deadline should be bracketed.

Wikipedia on Schedulers:
Tombuntu on Grub:

Changing Hard Drive Parameters

There are a slew of hard drive parameters to change. To change your hard drive parameters you can edit the file “/etc/fstab.” Some articles suggest adding several parameters to the drive options. However I only implemented the most common ones in my parameters. Edit the /etc/fstab file, and add the following parameters in red (this time separated by commas.)

/dev/sdb6 / ext4 noatime,nodiratime,discard,errors=remount-ro 0 1

If your SSD supports trim, adding the discard option will enable the use of trim. Trim helps keep your SSD from fragmenting (yes you can fragment SSD’s read the article below for more info).

noatime, nodiratime
By default the ext4 partition keeps track of when files were las accessed. This is write intensive and bad for jump drives.
Below are links to blogs that have more information about several more of the hard drive parameters.

The hard drive parameters with the exception of the discard option for SSD’s that are on an ext4 partition. So if you chose ext2 then you only need to implement the discard option.

More Options:
What is Trim:

Moving Temporary Files to RAM – Less SSD writes

Temporary files such as images loaded from web pages or parts of files that are being download cause heavy disc usage. They are usually composed of many small files. Since we don’t care if temporary files disappear if we restart the computer it would be a good idea to move them to your RAM– as long as you have RAM to spare. There are two main directories that temporary files are stored in /tmp and /var/tmp.

So to make files stored in these directories get put into ram we are again going to edit the /etc/fstab file. At the end of the /etc/fstab file add the following lines of text.

tmpfs /tmp tmpfs defaults 0 0
tmpfs /var/tmp tmpfs defaults 0 0

Restart your computer. Enter the command “df” and you should see two tmpfs entries and their associated directories.


I was hoping I would speed up my ssd a little after configuring it. Looking at the Bonnie++ tests it appears that there was very little change in the numbers. I do think that the effort to reduce ssd writes was beneficial. My final specs on the Plextor Sata III128 Gb SSD

Min Read Speed: 244.7 Mb/s
Max Read Speed: 423.1 Mb/s
Average Read Speed: 356.7 Mb/s

Bonnie++ Test Results

Version 1.96 Sequential Output Sequential Input Random
Sequential Create Random Create
Size Per Char Block Rewrite Per Char Block Num Files Create Read Delete Create Read Delete
K/sec % CPU K/sec % CPU K/sec % CPU K/sec % CPU K/sec % CPU /sec % CPU /sec % CPU /sec % CPU /sec % CPU /sec % CPU /sec % CPU /sec % CPU

Pre Tweaks20G42199618218413166023229911357294230245316221414++++++++1409045802151++++++++2508671


After Tweaks20G42899551336426646024889910619991231742916797749++++++++2833588859552++++++++3116989


This entry was posted in ASUS G53SW Setup, Everything Penguin Related, Uncategorized. Bookmark the permalink.

8 Responses to How to set up an SSD on Linux

  1. charles says:

    Good article….

    In the end you wrote:
    “Looking at the Bonnie++ tests it appears that there was very little change in the numbers.”

    It was confusing…does it means that there was no improvement is speed ?????

    i am planning to install linux mint 11 on a ssd and this article might prove useful 🙂

    • chris says:

      To tell you the truth, yes making the tweaks I did did not seem to make a huge difference in the read/write performance speeds. Overall the changes reduce the number of writes which prolongs the life of the SSD. I think a few years ago it would have been a big deal to implement all the tweaks I have, but now that SSD’s are more robust it’s not a big deal.

  2. Vishal says:

    This is a great article. I used Bonnie++ for one of projects in school. I had to practically compare performances of HDD, Hybrid HDD and SSD. I referenced many research articles which talked about Bonnie++. One thing was common in all article was though you see small increase in numbers in Bonnie++ results it is a great performance improvement. Because Bonnie++ results are obtained per block unit of data. One file can have many such blocks and one application has many such files. Moreover look at sequential create performance improvement it is more than three times.

  3. Brian says:

    Thanks for the excellent suggestions and clear instructions.

    One small thing – after changing the scheduler option in /etc/default/grub, you do need to run sudo update-grub before rebooting.

  4. Josep says:

    Good article. Thanks.
    If you can edit, there is a typo in:

    “…while entries with /dev/sd2 are partitions on my 128 Gb Plextor SSD…”

    It should be:

    “…while entries with /dev/sdb are partitions on my 128 Gb Plextor SSD…”

    (anyway I would have written “/dev/sda?” and “/dev/sdb?”).


  5. Oscar Frank says:

    Adding noatime and nodiratime

    noatime and nodiratime are mount options in linux for linux file system. noatime disables atime updates on file system, and nodiratime will disables atime updates on directory system. By adding noatime and nodiratime will greatly reduce ssd load means performance gains.

    Edit fstab file
    # nano /etc/fstab

    Add noatime,nodiratime to your ssd drives or partitions, after ext4
    UUID=bef10b86-494d-41c6-aa46-af72cfba90fd / ext4 discard,noatime,nodiratime,errors=remount-ro 0 1
    Disable hibernation

    Hibernate and suspend sometimes don’t work depends on the hardware you have for your system. Sometimes they make your system crash and unstable. Plus hibernation will put a lot of writes to your SSD which will shorten your SSD life.

    # nano /usr/share/polkit-1/actions/org.freedesktop.upower.policy

    Look for

    Change from “yes” to “no”, there are two, one for hibernation, and another one for suspend. If you have to disable them both, make sure to replace them both from yes to no.

  6. Henrik says:

    Nice blog, thanks for your “inputs” to SSD setup

  7. Professor B says:

    I put in an SSD for the OS and it made an old machine run much faster. I am using OpenSuse Linux Leap. It did make an old machine new. I did put in noatime, nodiratime, and discard in etc/fstab.

    I had the HDD that used to have the OS, so I put /tmp /var/ /opt and /usr/local on it as an HDD is fine with writes.

    I went to an IEEE seminar on SSD and learned that the RTOS moves stuff around the SSD to prevent wear out. So, I formatted 60 GB of the SSD and left the other 60GB unallocated for the RTOS to swap into. The presenter explained that this will prolong the life. He also said that the longer the warranty period, the more extra memory will be included in the drive for this swapping.

    Currently under development is a new SSD that repairs itself and does not have this wear out from writing.

Leave a Reply to Brian Cancel reply

Your email address will not be published. Required fields are marked *