Difference between revisions of "SSD"

From ArchWiki
Jump to: navigation, search
m (I/O Scheduler)
m (fix double redirect)
(14 intermediate revisions by one other user not shown)
Line 1: Line 1:
=Solid State Drives - Best Practices=
#REDIRECT [[Solid State Drives]]
{{Note| Readers are encouraged to contribute to enhance the quality of this article.}}
As most Archers know, Solid State Drives (SSDs) are not PnP devices.  Special considerations such as partition alignment, choice of file system, TRIM support, etc. are needed to setup SSDs for optimal performance.  This article attempts to capture referenced, key learnings to enable users to get the most out of SSDs under Arch (Linux in general).
=Pre-Purchase Considerations=
There are several key features to look for prior to purchasing a contemporary SSD.
==Key Features==
*Native [http://en.wikipedia.org/wiki/TRIM TRIM] support is a vital feature that both prolongs SSD lifetime and reduces the loss of performance over time.
*Buying the right size SSD is also key.  It goes without saying that purchasing the right about of capacity is important.  Like all file systems, target <75 % occupancy for all SSD partitions to ensure efficient use by Linux.
==On-line Reviews==
This section is not meant to be all-inclusive, but does capture some key reviews.
*[http://www.anandtech.com/show/2738 SSD Anthology (history lesson, a bit dated)]
*[http://www.anandtech.com/show/2829 SSD Relapse (refresher and more up to date]
*[http://forums.anandtech.com/showthread.php?t=2069761 One user's recommendations]
=Partitioning and Alignment=
Proper partition alignment is key for optimal performance and longevity.  The community seems to be in agreement on the use of fdisk as the utility of choice for partitioning SSDs (although one can also find guides whose authors advocate using parted).  Consensus opinion on the best settings for number of heads and cylinders is tough to find.  There seem to be two different camps on this issue:
Ted Tso and others recommend using [http://ldn.linuxfoundation.org/blog-entry/aligning-filesystems-ssd%E2%80%99s-erase-block-size 244/56] option:
# fdisk -H 224 -S 56 /dev/sdX
While others advocate the [http://www.nuclex.org/blog/personal/80-aligning-an-ssd-on-linux 32/32] option:
# fdisk -H 32 -S 32 /dev/sdX
==Additional Links on Alignment==
*[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 Another blog entry by Ted Tso]
=File Systems=
Many options exist for file systems including ext2, ext3, ext4, XFS, and btrfs.  Initially, ext2 was thought to be a good choice as it lacks journaling which would avoid extraneous read/write cycles.  Ext4 can also be used without a journal and is thought to be superior to ext2 in a number of areas.  The obvious drawback of using a non-journaling file system is data loss as a result of an ungraceful dismount (i.e. post power failure).  With modern SSDs, [http://thunk.org/tytso/blog/2009/03/01/ssds-journaling-and-noatimerelatime Ted Tso] advocates that journaling can be enabled with minimal extraneous read/write cycles.
--Placeholder for key data from aforementioned article--
[http://en.wikipedia.org/wiki/Btrfs Btrfs] support has been included with the mainline 2.6.29 release of the Linux kernel.  Some feel that it is not mature enough for production use while there are also early adopters of this potential successor to ext4.  It should be noted that at the time this article was written (27-June-2010), a stable version of btrfs does not exist.  See [http://www.madeo.co.uk/?p=346 this] blog entry for more on btrfs.
=Mount Flags in /etc/fstab=
There are several key mount flags to use in one's {{filename|/etc/fstab}} entries for SSD partitions.
*noatime - Reading accesses to the file system will no longer result in an update to the atime information associated with the file. The importance of the noatime setting is that it eliminates the need by the system to make writes to the file system for files which are simply being read. Since writes can be somewhat expensive, this can result in measurable performance gains. Note that the write time information to a file will continue to be updated anytime the file is written to with this option enabled.
*discard - The discard flag will enable the benefits of the TRIM command so long as one is using kernel version >=2.6.33.
/dev/sda1 / ext4 defaults,noatime,discard 0 1
{{Warning|Users need to be certain that kernel version 2.6.33 or above is being used AND that their SSD supports TRIM before attempting to mount a partition with the discard flag. Data loss can occur!}}
=I/O Scheduler=
Consider switching from the cfq scheduler to the noop or deadline scheduler.  Using the noop scheduler for example simplifies requests in the order they are received, without giving any consideration to where the data physically resides on the disk.  This option is thought to be advantageous SSDs since seek times are identical for all sectors on the SSD.  For more on schedulers, see [http://www.linux-mag.com/id/7564/1 this] Linux-mag article.
The cfq scheduler is enabled by default on Arch.  Verify this by viewing the contents /sys/block/sda/queue/scheduler:
$ cat /sys/block/sda/queue/scheduler
noop deadline [cfq]
The scheduler currently in use is denoted from the available schedulers by the brackets.  To switch to the noop scheduler, one can add the following line in {{Filename|/etc/rc.local}}:
# echo noop > /sys/block/sda/queue/scheduler
= Swap Space on SSDs =
One can place a swap partition on an SSD.  Note that most modern desktops with an excess of 2 Gigs of memory rarely use swap at all.  The notable exception is systems which make use of the hibernate feature.  The following is recommended tweak for SSDs using a swap partition that will reduce the "swapiness" of the system thus avoiding writes to swap.
# echo 1 > /proc/sys/vm/swapiness
Or one can simply modify {{Filename|/etc/sysctl.conf}} as recommended in the [http://wiki.archlinux.org/index.php/Maximizing_performance#Swappiness Maximizing Performance] wiki article.

Revision as of 20:48, 1 July 2010

Redirect to: