Install Linux on an SSD

From www.ReeltoReel.nl Wiki
Jump to navigation Jump to search

When you want to install Linux to an SSD, there are a lot of things to think about. This wiki post will look at all those things.

1. start your partitons on a 4k boundary

Because SSD's use 'blocks' of 4k in size, you must line up the partition boudaries on a block boudary for the best performance.

In fact, it is even better to start your partitons on a 512k block boundary. To do that, start fdisk with the parameters '-H 32 -C 32 -c' and create a completely new partitiontable.

fdisk -H 32 -C 32 -c

Note: Intel SSD's uses smaller blocks so use a different command:

fdisk -H 16 -S 16 -c

2. Optimize I/O

To adjust the stripe width and stride of an EXT4 filesystem, use this command to create a new filesystem:

mkfs.ext4 -E stride=128,stripe-width=128 /dev/sdaX

where sdaX is of course your ssd partition.

To tune an already existing filesystem, you can use:

tune2fs -E stride=128,stripe-width=128 /dev/sdaX

Intel users should use the value 32 for the stripe width

Use a different scheduler

You can also use a different i/o scheduler, the deadline scheduler, because the one that is used as a standard in the kernel is optimized for magnetic hard drives.

Modify /etc/rc.local (or /etc/rc.d/boot.local on openSUSE) and insert just before 'exit 0'

echo deadline > /sys/block/sda/queue/scheduler

3. Use TRIM

3.1 first, check if your SSD supports the TRIM command

hdparm -I /dev/sda | egrep "Enabled|TRIM"

3.2 second, your kernel needs to be > 2.6.33

uname -r

3.3 without special mount options, TRIM will not be used. To enable TRIM, use the 'discard' mount option in /etc/fstab.

/dev/sdaX    /    ext4    discard,etc. etc. etc.......

Also, you can use the noatime option to minmize the wear on the disk, so that would make the fstab line:

/dev/sdaX    /    ext4    noatime,discard,etc. etc. etc.......

Re-using an SSD

On occasion, users may wish to completely reset an SSD's cells to the same virgin state they were manufactured, thus restoring it to its factory default write performance. Write performance is known to degrade over time even on SSDs with native TRIM support.

When you want to reformat an SSD, it is best to completely wipe the disk. That way the algorithm will also be reset to get the best possible performance in your new configuration. To do that, you can use hdparm XXXX to be added.. XXXXXXX

Further performance enhancements

To increase system performance and to eliminate unnecessary write actions to the SSD, you can use a RAM disk.

Add this line to /etc/fstab:

tmpfs    /tmp    tmpfs    defaults,noatime,mode=1777    0 0