5 crucial optimizations for SSD usage in Ubuntu Linux
I bought my first SSD more than 5 years ago (late 2007), for my white MacBook Core2Duo 2.0 Ghz. It may be needless to say that my MacBook ran faster than many MacBook Pro’s at that time. The look on peoples faces when they saw my MacBook boot faster than their MacBook Pro was unforgettable.
By that time I was also experimenting with running 2 x 8GB CompactFlash with SATA converters in RAID-0 mode in my completely silent (but old and under-clocked) Pentium 3 Linux desktop. When people would visit my home they couldn’t believe my PC was actually turned on: it was dead silent.
Even today I still enjoy building low-power, silent and ultra-fast (Linux) computers with an SSD as the primary drive. Nowadays the new mSATA standard (see picture) is being used. During the past years I learned a thing or two about configuring Linux on a SSD drive. Today I will share those things with you:
1) Buy more than enough RAM
Yep, you should have at least 16GB of RAM. I know you’ll say that you don’t use that, but that is exactly the point. If you would be using it, it would not be enough. And why not? RAM is relatively cheap these days and you don’t want your system to start swapping, since this will wear out your expensive SSD.
2) Use the default partition layout
Contrary to popular belief, the default (guided) partitioning will do. If you partition manually, keep in mind that you do need a swap partition that is bigger than your RAM size.
3) Avoid using swap
You have plenty of RAM, so you could turn off swap or even create a system without swap. I have been running without swap for a year or so and never experienced significant problems (other people say the same). The most annoying side-effect is that the hibernate function is not available, since it uses the swap partition. This is why I recommend to not completely disable swap, but to reduce the swappiness of Linux. This way Linux will use all available RAM before starting to write to your precious SSD, while still allowing you to hibernate. Still, be aware when it comes to using hibernate, because it uses a lot of writes. Run this one-liner to add a permanent swappiness setting:
|
1
|
echo -e "vm.swappiness=0" | sudo tee -a /etc/sysctl.conf |
This will only be effective after reboot.
4) Disable access time logging
Remove the access time logging on the file system. Without the “noatime” flag on your file system every read will cause a write, because the file system will update the access time. This is bad for the life-time of your SSD, since it supports a limited number of writes and this is causing significantly more writes. Edit the “fstab” to add the “noatime” flag:
|
1
|
sudo nano /etc/fstab |
Now change “errors=remount-ro” to “noatime,errors=remount-ro”. Save the file and reboot.
5) Enable TRIM
TRIM will stop your SSD from slowing down after using it for a while. If you do not enable TRIM the writes may become slower due to the erasing of the deleted blocks. By running this one-liner you can add TRIM as a daily cron job:
|
1
|
echo -e "#\x21/bin/sh\\nfstrim -v /" | sudo tee /etc/cron.daily/trim |
You have to make the cron job executable using:
|
1
|
sudo chmod +x /etc/cron.daily/trim |
It will be run every day to avoid slowing down your writes and you will hardly notice it.
More advice: monitor the expected life-time
Your disk will not run forever. It has an expected life-time and you should probably monitor it using:
|
1
|
sudo smartctl -data -A /dev/sda |
This will output something like this:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
maurits@nuc:~$ sudo smartctl -data -A /dev/sdasmartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.8.0-26-generic] (local build)Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net=== START OF READ SMART DATA SECTION ===SMART Attributes Data Structure revision number: 18Vendor Specific SMART Attributes with Thresholds:ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE1 Raw_Read_Error_Rate 0x0000 006 000 000 Old_age Offline - 63 Spin_Up_Time 0x0000 100 100 000 Old_age Offline - 04 Start_Stop_Count 0x0000 100 100 000 Old_age Offline - 05 Reallocated_Sector_Ct 0x0000 100 100 000 Old_age Offline - 09 Power_On_Hours 0x0000 100 100 000 Old_age Offline - 259212 Power_Cycle_Count 0x0000 100 100 000 Old_age Offline - 258232 Available_Reservd_Space 0x0000 100 100 000 Old_age Offline - 4914564640233 Media_Wearout_Indicator 0x0000 100 000 000 Old_age Offline - 100maurits@nuc:~$ |
At ID# 233 you see the MWI. This is a value starting at 100 and when it reaches values below 10 you should start to worry. Note that different manufacturers may have different names and numbers for this indicator.
Final advice: avoid buying TLC drives
Triple Level Cell (TLC) drives are making their entry in the market. These drives have a dramatically lower expected life-time. The life-time of a drive is measured in Program/Erase (PE) cycles or in Peta Bytes Written (PBW). Check the specs carefully to avoid buying a cheap drive, thinking you made a good deal, while actually buying a model with a lower expected life-time.
A swap partition on your SSD will let you wake up faster from hibernation (aka "suspend to disk") as compared to swap on a hard drive. But given the incredibly fast boot time of Ubuntu when booting from SSD a wake up from hibernation may be slower than a reboot.
If you do not hibernate you may never need to swap at all.
Only in case you often have very many RAM intensive applications running in parallel, your system may eventually use swap. Then a swap on SSD will be somewhat faster than a swap on a hard drive. Still there is no need to worry about wearing of your SSD from extensive swapping.
If not used for hibernation you can alway add a swap partition or swap on file later:
5 crucial optimizations for SSD usage in Ubuntu Linux的更多相关文章
- Ubuntu Linux 使用桂电校园网 上网
2016年9月1日 星期四 桂电校园网今天升级新的出校器,旧的出校器已经不能使用,所以本篇博客已经过期,下面的方法已经不能让Ubuntu使用桂电校园网上外网了.详细的原因,请到这个网站查看:校园网计费 ...
- ubuntu linux 下wine的使用
ubuntu linux 下wine的使用 之前写了一篇 ubuntu15.10下编译安装wine1.8rc4 这一篇是来写它的使用的. 1.安装Wine支持包 现在,需要安装非开源(但免费)的支持包 ...
- Ubuntu Linux上安装oracle jdk
说明:由于很多系统不支持使用OpenJDK,因此在ubuntu下会需要安装Oracle JDK.而Oracle JDK的安装貌似没有提供apt方式,因此安装Oracle JDK的方式相对麻烦一些,我经 ...
- ubuntu Linux 测试PHP却提示下载文件的解决办法
ubuntu Linux 测试PHP却提示下载文件的解决办法 一般这种情况都是在刚刚开始配置环境时出现的, 输入 sudo a2enmod php5 看提示如果出现“$ This module ...
- 安装Ubuntu Linux系统时硬盘分区最合理的方法
无论是安装Windows还是Linux操作系统,硬盘分区都是整个系统安装过程中最为棘手的环节,网上的一些Ubuntu Linux安装教程一般都是自动分区,给初学者带来很大的不便,下面我就根据多年来在合 ...
- Shell script for logging cpu and memory usage of a Linux process
Shell script for logging cpu and memory usage of a Linux process http://www.unix.com/shell-programmi ...
- HOWTO install Oracle 11g on Ubuntu Linux 12.04 (Precise Pangolin) 64bits
安装了Ubuntu 12.04 64bit, 想在上面安装Oracle 11gr2,网上找了好多文档都没成功,最后完全参考了MordicusEtCubitus的文章. 成功安装的关键点:install ...
- Ubuntu Linux启用root用户登录
Ubuntu Linux有一个与众不同的特点,那就是初次使用时,你无法作为root来登录系统,为什么会这样?这就要从系统的安装说起.对于其他Linux系统来 说,一般在安装过程就设定root密码,这样 ...
- Ubuntu Linux下如何配置Android开发环境
下载和安装Win7系统Android开发环境中讲了怎样在Win7系统中安装Android开发环境,那么怎样在Linux系统中配置Android开发环境呢?本篇文章就将演示如何使用Eclipse.And ...
随机推荐
- 微信开发之开发环境搭建( visual studio 2015we + IIS express + ngrok)
1. 申请个人测试使用的微信订阅号 https://mp.weixin.qq.com 可注册微信订阅号. 不会?请自行百度. 2. 安装 ngrok 微信开发首先要解决如何让微信链接到本地开发环境.有 ...
- 在图层上使用CATransform3D制做三维动画-b
在UIView上,我们可以使用CGAffineTransform来对视图进行:平移(translation),旋转(Rotation),缩 放(scale),倾斜(Invert)操作,但这些操作是没有 ...
- mongodb 全文检索
MongoDB 全文检索 全文检索对每一个词建立一个索引,指明该词在文章中出现的次数和位置,当用户查询时,检索程序就根据事先建立的索引进行查找,并将查找的结果反馈给用户的检索方式. 这个过程类似于通过 ...
- posix和system v有什么区别/?
posix和system v有什么区别/?现在在应用时应用那一标准浮云484212 | 浏览 243 次 2014-11-06 10:362014-11-19 22:36 最佳答案们是有关信号量的两组 ...
- BZOJ 1733: [Usaco2005 feb]Secret Milking Machine 神秘的挤奶机
Description 约翰正在制造一台新型的挤奶机,但他不希望别人知道.他希望尽可能久地隐藏这个秘密.他把挤奶机藏在他的农场里,使它不被发现.在挤奶机制造的过程中,他需要去挤奶机所在的地方T(1≤T ...
- [转载]C# Random 生成不重复随机数
Random 类 命名空间:System 表示伪随机数生成器,一种能够产生满足某些随机性统计要求的数字序列的设备. 伪随机数是以相同的概率从一组有限的数字中选取的.所选数字并不具有完全的随机性,因为它 ...
- hdu 1423
最长公共上升子序列:O(n*m)的算法: #include<cstdio> #include<cstring> #define maxn 1000 using namespac ...
- join的一对多,去除重复,排序优先的group方法
想将问题列表按照最新回答来排列.但问题和回答是分拆在两张表来存放的.所以,要完成上述需求,需从主表“问题”取显示数据,但是得按照次表(回答)的更新日期来排序. 用join来做,始终无法去除重复,折腾了 ...
- ZOJ 2750 Idiomatic Phrases Game(Dijkstra)
点我看题目 题意 : 给定一本字典,字典里有很多成语,要求从字典里的第一个成语开始,运用字典里的成语变到最后一个成语,变得过程就是成语接龙,后一个成语的第一个字必须有前一个成语的最后一个字相等,给定的 ...
- iOS开发UI篇—UITabBarController生命周期(使用storyoard搭建)
iOS开发UI篇—UITabBarController生命周期(使用storyoard搭建) 一.UITabBarController在storyoard中得搭建 1.新建一个项目,把storyb ...