SSD

From ArchWiki
Revision as of 07:20, 27 June 2010 by Graysky (Talk | contribs) (Step 1: Aligning the drives partitions)

Jump to: navigation, search

Accumulated info on how to use your SSD drive under linux

under construction, not complete, not nice

So you got yourself one of those precious, blazing fast SSDs and you want to get the most out of it? There are a number of things to worry about, such as alignment, choice of file system, journaling and TRIM.

Before buying

Make sure the SSD you buy has a firmware with TRIM support. This is a vital feature that both prolongs your SSDs lifetime and reduces the loss of performance over time to almost nil. I recommend all of what Anand has ever written about SSDs in general before considering to buy one: SSD Anthology (history lesson, a bit dated): http://www.anandtech.com/show/2738 SSD Relapse (refresher and more up to date: http://www.anandtech.com/show/2829 He also reviewes most of the SSDs so you'll find up-to-date benchmarks on all of them. Brilliant stuff.

Setting up a fresh drive with archlinux

This guide assumes that you want to install archlinux from scratch on your brand new SSD. For different applications (like using them in a RAID, a server or whatever) many things might be different

Step 1: Aligning the drives partitions

Launch the latest archlinux install medium, then go on launching fdisk with fixed head and sector number options. The head and sector options are a safe bet for many drives. Read the links below to find out more about what they do, as some SSDs might require a different setting for maximum performance.

# fdisk -H 32 -S 32 /dev/sda

Now create your partitions.

Warning: When creating the first partition, select cylinder number 2 as the first cylinder, not 1. This ensures that your first partition doesn't get shifted.

You might not want to create a swap partition if you don't really need it.

Background info

aligning the SSD to block boundaries: http://www.ocztechnologyforum.com/forum/showthread.php?54379-Linux-Tips-tweaks-and-alignment&p=373226&viewfull=1#post373226 aligning the SSD to block boundaries when using LVM: http://es.linuxfoundation.org/news-media/blogs/browse/2009/02/aligning-filesystems-ssd%E2%80%99s-erase-block-size

Step 2: Choosing a file system

There's lots of talk about what to use. Some say ext2 should be used because it doesn't have journaling, some say ext4 without journaling is best, and some use btrfs. Since TRIM support, journaling can be enabled without much of a drawback as stated by the guy in the link below. If you disable journaling, you end up with a slightly faster system, but in case of a power failure your data might end up garbled. I decided to go with a regular journaled ext4 because it's a laptop and a low battery could garble me some data. If you plan on using a RAID, there's even more to consider, such as stripe-widths and so on.

$ mkfs.ext4 /dev/sda1

Next, consider setting the noatime mount option for your SSD partitions in /etc/fstab (see the reasons in the link below):

UUID=b0848f0d-5d37-41df-a2c7-5a43f023f420 /home ext3 defaults,noatime 0 2


Background info

Step 3: Install Arch

I don't do anything out of the ordinary. LVM or RAID users might need to insert some info here. However, if you use ext4, add the "noatime" option to disable timestamps and the "discard" option to enable TRIM. If you decided to use a swap partition or file, it's recommended to reduce the "swapiness" of the system to avoid writes to swap. Add this to rc.local: $ echo 1 > /proc/sys/vm/swapiness


Background info

ext4 without journaling and some fstab options: http://cptl.org/wp/index.php/2010/03/30/tuning-solid-state-drives-in-linux/