I recently purchased a new solid state drive (SSD) to replace my current hard drive (HDD). Since SSDs work so much differently than HDDs, it’s worth while to make some optimizations in Ubuntu for them. SSDs are much faster than HDDs, but have a limited number of writes before they wear out. This makes balancing performance with the life of your SSD also a big concern for how you tune your system.
I’ve written a post on this topic before for the older SSD in my netbook.
Partitioning and bind mounts
I partitioned my 60 GB SSD into a 10 GB
/ partition, and a 50 GB
partition, both using the default ext4 filesystem. I kept my old HDD home
partition mounted at
I wanted to put some of my large and infrequently accessed files, like virtual machines and videos, on the more spacious HDD. I also wanted to make accessing these files from my home directory seamless. One way to do this would be to symlink folders from the SSD to the HDD. However, I found that this wouldn’t be fully seamless for some applications that don’t follow symlinks.
Bind mounts are a better solution. They allow a directory in a filesystem to be mounted in additional locations, similarly to symlinks but fully transparent to applications. To test bind mounting my videos directory, I ran mount with the bind option, and specified the source directory (on the HDD), and the mount point (which must already exist):
mount --bind /media/oldhome/tom/Videos /home/tom/Videos
To make my bind mounts permanent, I added them to my
/etc/fstab file in this
/media/oldhome/tom/Videos /home/tom/Videos none bind 0 0
If you need to add a path with a space in it, replace the space with
escape it. If you make a mistake and one of the bind mounts fails, Ubuntu will
allow you to skip it and continue booting. So far the bind mount approach seems
to work perfectly.
Mount options for SSDs
Any recent SSD should have the TRIM command
available, which prevents performance degradation by allowing the OS to notify
the SSD of which blocks are unused. The ext4 filesystem uses TRIM when the
discard option is set.
noatime option reduces writes to the SSD by not writing access time
updates whenever a file is read. This improves performance and increases the
life of the SSD.
I set these two mount options though
/etc/fstab for both my SSD partitions by
noatime to the list of options for
UUID=193af662-d7a0-47fb-b3f7-141ae3d19227 / ext4 errors=remount-ro,noatime,discard 0 1
Disk head scheduler for SSDs
A disk scheduler optimizes the order of disk requests by considering the position of the hard drive’s read/write head. An SSD needs no such optimization, so it’s best to use the noop (no-operation) scheduler.
I switched to the noop scheduler for my SSD by adding the to following line to
sdb with your own SSD’s device node name):
echo noop > /sys/block/sdb/queue/scheduler
Swap and swappiness
I kept my swap partition on the old HDD. Swap on the SSD would be faster, but would also shorten the SSD’s life.
My system has plenty of memory, so I also reduced the swappiness
to 0 to tell Ubuntu to only swap when absolutely necessary. I did this by adding
There are many more ways to tune Ubuntu for SSDs. A few things I haven’t done
are: partition alignment (Ubuntu’s partitioner now seems to take care of this
automatically), disabling journalling (I’d prefer reliability over slightly
reduced SSD life), and mounting
/tmp or browser cache in memory (I’d prefer to
save the memory). The Arch Linux Wiki has a comprehensive page on
SSDs, and here’s
that goes more in-depth in some of the things I mentioned here.