SSD: How to Optimize Your Solid State Drive for Linux
sites.google.com
sites.google.com
People Who Know in the industry know that any non-bottom-of-the-barrel SSD bought in the last -like- five years or so will endure many tens of TBs of writes.
If we look at Tech Report's SSD Torture Test [0], we know with some confidence that consumer-level SSDs will endure hundreds of TBs of writes before failing.
To provide some perspective for those numbers: My Linux laptop has encrypted swap, btrfs root partiton, and encrypted btrfs /home all on the SSD, and sees frequent compiles-from-source (I run Gentoo Linux.). Other than mounting my filesystems with the "discard" option, I've performed no SSD-specific configuration step or fiddled with any VM tunables.
Under this workload and configuration, I have written 20.4TB and read 66.8TB over 3.9 years. SMART indicates that zero blocks have been reallocated and that the drive is in perfect health.
In short, if you've a consumer or developer's workload, don't worry about SSD media longevity. Regardless of who you are, strongly consider benchmarking any configuration tweaks that folks claim will improve performance.
[0] http://techreport.com/review/27909/the-ssd-endurance-experim... (But make sure to also check out the intro article: http://techreport.com/review/24841/introducing-the-ssd-endur... )
The page may look like there are many steps involved, but actually many do not apply to recent distributions. It's more or less a 4-5 steps for a recent distro. hardly what I would call "a lot of fiddly work".
The thing is, the linked article is a grab bag of outdated (mount filesystems with noatime [0]) or just plain wrong (btrfs is bad for SSDs) factoids and bits of advice. It's clear that the author hasn't gone to the trouble to fact or efficacy check most of his assertions. We need fewer top-ten lists of cargo-cult suggestions to extend the life of your PC, not more. :)
What's more, you're going to pains -however small- to extend the life of something that will easily last for far more than five years. Five years is a long time in the SSD market. My ~five year old 100GB SSD is still going strong. It cost ~$400 when I purchased it. Today I can spend ~$400 and get a 1TB drive that's substantially faster than and at least as reliable as this one.
There's something to be said for frugality. I know: I've been using the same laptop for the past eight years. There's also something to be said about not worrying about wear when using highly durable tools that are designed to last for a decade or more. [1]
[0] relatime has been available since ~2007 and was made a part of the defaults mount option since ~2009.
[1] After all, if a tool lasts for ten years, you'll only ever buy ten of them in your lifetime.
Was the SSD made by OCZ or had a Sandforce controller by any chance?
Also anecdotal, but my 160GB Intel X25-M 'G2' has been working perfectly for the past 5 years and 10 months. So far I have written 16.92 TBs to it [1] and until I moved the drive into another PC I had been running games and VMs from it.
If one wants to “get his money back” the best way is to utilize the SSD to its fullest instead of trying to preserve it for ten years. Write on it as much as you can. Use it to make your system faster. Use it to hide your setup's shortcomings.
Couple years back, I had only 8GB of RAM on my system. The first thing I did when I got a SSD was to put the swap on it. The zero-seek times (compared to HDDs) made the dreaded swap operations almost imperceptible. What worths more? The SSD or the ability to do my work without hinders?
Other bad advice in the article:
- Use noatime: this is old, use relatime.
- Do not use btrfs: compression, deduplication, COW, snapshots etc are very useful for the small sized SSDs
- Do not enable hibernation: Maybe we should return to windows '98
- Disable browser cache: facepalm, just try browsing like this...
Ommited advice from the article: - Use part of the SSD as a cache for your HDDs (native support by LVM)
In short: do not try to protect your SSD. Try to kill it as fast as possible. :)Is this needed in a modern car, or does it make driving said care more pleasurable, (or, for that matter, safe?) No, in call cases. But, he takes a particular pleasure about taking his vehicle into the dealer (free, once a year), and at 75,000 miles being told that his brakes look like they've got 10,000 miles on them.
So, if you read the advice on SSDs in this (ridiculous to some) vein, then It's a fun read.
A thing I can't understand are screen protectors used by people with an office job. The amount of R&D put into modern phones' screens and oleophobic coating is huge. Your phone's screen is designed to withstand both hits and dirt, to let your fingers slide with minimal friction and to allow you perceive every last pixel of your QHD panel (which has its own huge amount of R&D). Why would you miss all these by gluing a $5 piece of plastic on top of it?
Some of us prefer matte, non-mirror screens.
Disabling the browser cache is a good example. Back then we had many drives based on JMicron's infamous JMF602 controller such as the G.Skill Titan and Apex, Core v2 & Solid from OCZ. Once thing these all had in common were incredibly poor random 4KB write latencies of between 0.5-2 seconds [1][2] which understandably lead to frequent pauses or stuttering in the operating system. The general advice in these cases was to move the browser cache to a HDD or RAM disk in addition to disabling or moving the pagefile. I am not sure why but many people seemed happy with this solution. If I had purchased an SSD that exhibited this problem I would have returned it to the place of purchase for a full refund since they clearly weren't fit for purpose and shouldn't have been sold in the first place!
Item 17 isn't true [3]. Windows 7 onwards will detect solid state drives and will make the necessary adjustments itself (including disabling defrag just for the SSD). What many of these guides fail to mention is that if you completely disable defrag you are also disabling the automatic defragmentation of any HDDs that are connected to the same computer. Also, in Windows 8.x/10 the defrag tool now deals with storage optimization and does a lot more than defragging such as sending TRIM hints to SSDs [2][3] so you definitely don't want to disable that.
If you have cloned a Windows install from a HDD to an SSD you can force Windows to detect the drive as an SSD by running the following from an elevated Command Prompt (although WinSAT will run without any user input eventually):
winsat formal -restart clean
One reason for disabling hibernation was because SSDs were small (< 64GB) and the hiberfil.sys in Windows would take up a non-trivial amount of disk space if you had a PC with 4GB-8GB RAM. These days it's a non-issue since capacities are larger and the as The Tech Report have proven, it takes a lot of effort to wear out an SSD. Also, if you are using Windows 8.0 onwards disabling hibernation will also disable the fast startup feature.Another very recent myth is that SSDs will lose data in as little as 7 days if left in a powered-off state [5]. Thankfully this has been thoroughly debunked [6].
[1] http://www.anandtech.com/show/2738/17
[2] http://www.anandtech.com/show/2614/7
[3] http://www.hanselman.com/blog/TheRealAndCompleteStoryDoesWin...
[4] http://www.ghacks.net/2012/08/19/why-weekly-defrags-are-turn...
[5] http://www.extremetech.com/computing/205382-ssds-can-lose-da...
[6] http://anandtech.com/show/9248/the-truth-about-ssd-data-rete...
Next, you don't have to over-provision unpartitioned space AND preserve 20% of partitioned free space. It's one or another, the point is to have enough free space for proper wear leveling.
Hibernation can stay enabled, it just dumps RAM contents into a file, once. SSDs are much more vulnerable to small frequent writes (log files, browser cache, etc) due to write amplification and minimum write size (http://www.ni.com/product-documentation/10126/en/).
[0] http://www.oszone.net/user_img/vadblog/ssd-defrag-bug-en01_m...
18. Now you'll be able to enjoy your SSD carefree!
This should have been step 1. SSDs have a massive lifetime these days, you don't need to do any of the other steps, some of them will even slow down your computer.
The 850 Pro I've got in my machine has a stated write lifetime of 150TB.
And chances are, it'll do a lot more than that, it's just the number they'll look at for the 10 year warranty.
Personally I just fully wipe a new ssd and put discard in fstab.
I think a copy-on-write filesystem like btrfs would be better on SSDs because they do not change written data but rather write to a new area on the drive, requiring less erases on the SSD's side.
There's also F2FS (Flash-Friendly File System) which has been in the Linux kernel for a while now that specifically targets flash based drives.
Though I agree that most of these optimizations do not seem necessary on modern SSDs.
It should be noted that while an SSD can't write before erasing it will actually not even attempt that. The SSD maintains a mapping from LBA to physical flash chip and offset and will write to a completely different place. It will then mark the old location as unused and erase it when it can spare some time and power.
I also doubt the disk scheduler is of any importance, as long as there are enough IOs in the queue in the disk it will be fast, otherwise it will not. All schedulers will allow multiple IOs in the queue for all I know.
I do the noatime for any system without regard if it is an SSD or HDD. I just don't use atime at all to bother about the extra work needed to maintain it.
Are you taking backups?
So long as you're taking backups you probably should worry about this kind of excessive noodling.
http://forum.crucial.com/t5/Crucial-SSDs/Solution-Crucial-V4...
Copy/paste the following command line into the terminal:
sudo mv -v /etc/cron.weekly/fstrim /fstrim
Uhm. What? That's how this article 'disables' a cron task? Why?You are probably better off with an SSD standalone or with a full blown SSD as a block cache to the HDD in part and as a direct drive in the other part.
In fact, I worked on an enterprise storage that did just that and it significantly improved performance for many workloads. There are open-source solutions for that in Linux that integrate into LVM and do that pretty much without any other interaction by the user. bcache comes to mind but there were a few others as well.
With ~250GB SSDs going for like 100 bucks it's like a no-brainer to add one to a desktop.