From ArchWiki
Revision as of 07:24, 27 June 2010 by Graysky (talk | contribs) (added TRIM support to /etc/fstab)
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): SSD Relapse (refresher and more up to date: 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: aligning the SSD to block boundaries when using LVM:

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 which mount flags to use in the entries for your partitions in /etc/fstab (see the reasons in the link below):

/dev/sda1 / ext4 defaults,noatime,discard 0 1
Note: Omitting the discard option will leave the partition ignoring the TRIM command!

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: