http://linux-wiki.cn/index.php?title=SSD_(%E5%9B%BA%E6%80%81%E7%A1%AC%E7%9B%98)&feed=atom&action=history
SSD (固态硬盘) - 修订历史
2024-03-29T02:04:24Z
本站上此页的修订历史
MediaWiki 1.17.0
http://linux-wiki.cn/index.php?title=SSD_(%E5%9B%BA%E6%80%81%E7%A1%AC%E7%9B%98)&diff=2183&oldid=prev
Zzjzzpgg12: /* 挂载选项 */
2023-11-04T09:10:09Z
<p><span class="autocomment">挂载选项</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←上一修订</td>
<td colspan='2' style="background-color: white; color:black;">在2023年11月4日 (六) 09:10所做的修订版本</td>
</tr><tr><td colspan="2" class="diff-lineno">第46行:</td>
<td colspan="2" class="diff-lineno">第46行:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>===挂载选项===</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>===挂载选项===</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{Hint|修改挂载选项的具体方法可参见[[fstab]]。}}</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{Hint|修改挂载选项的具体方法可参见[[fstab]]。}}</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">F2FS (Flash Friendly File System) 是专门为基于 NAND 的存储设备设计的新型开源 flash 文件系统。特别针对NAND 闪存存储介质做了友好设计。F2FS 于2012年12月进入Linux 3.8 内核。</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> 开发中的[[wpcn:btrfs|btrfs]]正在试图对 SSD 硬盘做专门的优化,用户可以通过<tt>-o ssd</tt>[[:Category:Mount|挂载]]选项启用<ref name="btrfs">[https://btrfs.wiki.kernel.org/index.php/FAQ#Is_Btrfs_optimized_for_SSD.3F btrfs Wiki: FAQ]</ref>。</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> 开发中的[[wpcn:btrfs|btrfs]]正在试图对 SSD 硬盘做专门的优化,用户可以通过<tt>-o ssd</tt>[[:Category:Mount|挂载]]选项启用<ref name="btrfs">[https://btrfs.wiki.kernel.org/index.php/FAQ#Is_Btrfs_optimized_for_SSD.3F btrfs Wiki: FAQ]</ref>。</div></td></tr>
</table>
Zzjzzpgg12
http://linux-wiki.cn/index.php?title=SSD_(%E5%9B%BA%E6%80%81%E7%A1%AC%E7%9B%98)&diff=2139&oldid=prev
刀尖红叶: /* 原理分析 */
2014-02-23T02:02:21Z
<p><span class="autocomment">原理分析</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←上一修订</td>
<td colspan='2' style="background-color: white; color:black;">在2014年2月23日 (日) 02:02所做的修订版本</td>
</tr><tr><td colspan="2" class="diff-lineno">第7行:</td>
<td colspan="2" class="diff-lineno">第7行:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>==原理分析==</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>==原理分析==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>SSD硬盘之所以需要特别优化系统配置,主要是由其特性决定的:</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>SSD硬盘之所以需要特别优化系统配置,主要是由其特性决定的:</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>;写入方式:向SSD硬盘写入数据时,不能像写入普通硬盘那样直接覆盖,而是要先擦除、再写入。不幸的是,由于设计的原因,虽然写入操作可以以'''页'''(page,常为 4KB)为单位,擦除操作的最小单位一般是'''块'''(block,常为 512KB)。<ref name="wp_TRIM">[[wpen:TRIM|Wikipedia: TRIM]]</ref>如果想保留块中的其它数据,需要在擦除前要先读出该块的数据,并在修改后写回。所以每一次写操作实际写到硬盘上的数据很可能原来计划比要写的数据多,这就是所谓的 [[wpen:Write amplification|Write amplification]] 效应。这是SSD的读取比写入快得多的原因之一。</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>;写入方式:向SSD硬盘写入数据时,不能像写入普通硬盘那样直接覆盖,而是要先擦除、再写入。不幸的是,由于设计的原因,虽然写入操作可以以'''页'''(page,常为 4KB)为单位,擦除操作的最小单位一般是'''块'''(block,常为 512KB)。<ref name="wp_TRIM">[[wpen:TRIM|Wikipedia: TRIM]]</ref>如果想保留块中的其它数据,需要在擦除前要先读出该块的数据 <ins class="diffchange diffchange-inline">到SSD缓存中(这也是SSD缓存一般较传统磁盘大很多的原因之一) </ins>,并在修改后写回。所以每一次写操作实际写到硬盘上的数据很可能原来计划比要写的数据多,这就是所谓的 [[wpen:Write amplification|Write amplification]] 效应。这是SSD的读取比写入快得多的原因之一。</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>;存储单元损耗 (Wearing):SSD的每一个存储单元被擦除、写入的次数是有限的。市面上常见的使用 [[wpen:Multi-level cell|MLC (Multi-Level Cell)]] 技术的SSD,单个存储单元只能被擦除、重写几千次,而采用相对昂贵的 [[wpen:Multi-level_cell#Single-level_cell|SLC (Single-Level Cell)]] 的SSD也有几万到几十万次的擦除寿命<ref name="write_amp">[[wpen:Write_amplification|Wikipedia: Write Amplification]]</ref>。这是很多人对 SSD 硬盘不放心的因素之一,但实际上得益于[[wpcn:耗损平均技术|耗损平均技术]],该问题对普通用户的影响并不显著。</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>;存储单元损耗 (Wearing):SSD的每一个存储单元被擦除、写入的次数是有限的。市面上常见的使用 [[wpen:Multi-level cell|MLC (Multi-Level Cell)]] 技术的SSD,单个存储单元只能被擦除、重写几千次,而采用相对昂贵的 [[wpen:Multi-level_cell#Single-level_cell|SLC (Single-Level Cell)]] 的SSD也有几万到几十万次的擦除寿命<ref name="write_amp">[[wpen:Write_amplification|Wikipedia: Write Amplification]]</ref>。这是很多人对 SSD 硬盘不放心的因素之一,但实际上得益于[[wpcn:耗损平均技术|耗损平均技术]],该问题对普通用户的影响并不显著。</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>;耗损平均技术 (Wear Leveling): 虽然每个存储单元的寿命有限,但每个物理存储单元对应的逻辑地址没必要是一成不变的。通过将要写入的数据动态地映射到不同的物理存储单元,SSD的寿命可以得到明显的提升<ref>[[wpen:Wear_leveling|Wikipedia: Wear leveling]]</ref>。如一个 64GB 的 SSD 设备,如果每个单元可被擦除、重写3000次,而某桌面用户每天写入 10GB 的数据,该设备出现有存储单元报废需要约 <tt>64 * 3000 / 10 / 365 = 52年 </tt>。 由于一般来讲桌面应用的写入并没有这么多,所以因为擦除、写入次数过多而导致SSD丢失数据的顾虑是没有什么必要的。一些评测数据<ref>[http://www.xtremesystems.org/forums/showthread.php?271063-SSD-Write-Endurance-25nm-Vs-34nm SSD Write Endurance 25nm Vs 34nm]</ref>和分析文章<ref>[http://www.storagesearch.com/ssdmyths-endurance.html SSD Myths and Legends - "write endurance"]</ref>都支持了这一点。</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>;耗损平均技术 (Wear Leveling): 虽然每个存储单元的寿命有限,但每个物理存储单元对应的逻辑地址没必要是一成不变的。通过将要写入的数据动态地映射到不同的物理存储单元,SSD的寿命可以得到明显的提升<ref>[[wpen:Wear_leveling|Wikipedia: Wear leveling]]</ref>。如一个 64GB 的 SSD 设备,如果每个单元可被擦除、重写3000次,而某桌面用户每天写入 10GB 的数据,该设备出现有存储单元报废需要约 <tt>64 * 3000 / 10 / 365 = 52年 </tt>。 由于一般来讲桌面应用的写入并没有这么多,所以因为擦除、写入次数过多而导致SSD丢失数据的顾虑是没有什么必要的。一些评测数据<ref>[http://www.xtremesystems.org/forums/showthread.php?271063-SSD-Write-Endurance-25nm-Vs-34nm SSD Write Endurance 25nm Vs 34nm]</ref>和分析文章<ref>[http://www.storagesearch.com/ssdmyths-endurance.html SSD Myths and Legends - "write endurance"]</ref>都支持了这一点。</div></td></tr>
</table>
刀尖红叶
http://linux-wiki.cn/index.php?title=SSD_(%E5%9B%BA%E6%80%81%E7%A1%AC%E7%9B%98)&diff=2092&oldid=prev
Biergaizi: /* 挂载选项 */ noatime 和 relatime 的说明
2013-05-01T07:21:54Z
<p><span class="autocomment">挂载选项: </span> noatime 和 relatime 的说明</p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←上一修订</td>
<td colspan='2' style="background-color: white; color:black;">在2013年5月1日 (三) 07:21所做的修订版本</td>
</tr><tr><td colspan="2" class="diff-lineno">第51行:</td>
<td colspan="2" class="diff-lineno">第51行:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> 另一个在很多教程中出现的选项是<tt>-o discard</tt><ref name="arch" /><ref name="apc">[http://apcmag.com/how-to-maximise-ssd-performance-with-linux.htm How to maximise SSD performance with Linux]</ref><ref name="oschina">[http://www.oschina.net/question/28_44835 开源中国社区:Linux 系统下使用 ssd 固态硬盘]</ref>,该选项可用于 [[ext4]] 和 [[btrfs]] 文件系统,作用是在删除文件时实时发出 TRIM 指令,以期加快以后写数据的速度。值得注意的是,该指令的效果是受到严重怀疑的<ref>[http://opensuse.14.n6.nabble.com/SSD-detection-when-creating-first-time-fstab-td3313048.html OpenSUSE Forum: SSD detection when creating first time fstab ?] </ref>。2011年中旬的数据<ref name="discard">[http://en.opensuse.org/SDB:SSD_discard_%28trim%29_support OpenSUSE:  SDB:SSD discard (trim) support]</ref>表明, '''discard 选项非但没有提升 SSD 的效率,反而使其变慢了'''。Btrfs的<tt>-o ssd</tt>选项也不会启用<tt>discard</tt><ref name="btrfs"/>。 相比之下,定时发送 TRIM 指令可能是更好的选择(见后文)。</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> 另一个在很多教程中出现的选项是<tt>-o discard</tt><ref name="arch" /><ref name="apc">[http://apcmag.com/how-to-maximise-ssd-performance-with-linux.htm How to maximise SSD performance with Linux]</ref><ref name="oschina">[http://www.oschina.net/question/28_44835 开源中国社区:Linux 系统下使用 ssd 固态硬盘]</ref>,该选项可用于 [[ext4]] 和 [[btrfs]] 文件系统,作用是在删除文件时实时发出 TRIM 指令,以期加快以后写数据的速度。值得注意的是,该指令的效果是受到严重怀疑的<ref>[http://opensuse.14.n6.nabble.com/SSD-detection-when-creating-first-time-fstab-td3313048.html OpenSUSE Forum: SSD detection when creating first time fstab ?] </ref>。2011年中旬的数据<ref name="discard">[http://en.opensuse.org/SDB:SSD_discard_%28trim%29_support OpenSUSE:  SDB:SSD discard (trim) support]</ref>表明, '''discard 选项非但没有提升 SSD 的效率,反而使其变慢了'''。Btrfs的<tt>-o ssd</tt>选项也不会启用<tt>discard</tt><ref name="btrfs"/>。 相比之下,定时发送 TRIM 指令可能是更好的选择(见后文)。</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><tt>noatime</tt>(或<tt>relatime</tt>), <tt>nodiratime</tt>是另外两个可以考虑的挂载选项,它们防止在读文件时更改文件的“最近访问”时间戳,减少写入硬盘的次数。<ref name="arch"/><ref name="apc"/>数据显示,采用<tt>noatime</tt>选项后,在编译Linux内核的过程中,硬盘写入量比没使用时少了约 13% 。<ref name="ted">[http://tytso.livejournal.com/61830.html SSD’s, Journaling, and noatime/relatime]</ref> 请依照数据自行权衡利弊。</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><tt>noatime</tt>(或<tt>relatime</tt>), <tt>nodiratime</tt>是另外两个可以考虑的挂载选项,它们防止在读文件时更改文件的“最近访问”时间戳,减少写入硬盘的次数。<ref name="arch"/><ref name="apc"/>数据显示,采用<tt>noatime</tt>选项后,在编译Linux内核的过程中,硬盘写入量比没使用时少了约 13% 。<ref name="ted">[http://tytso.livejournal.com/61830.html SSD’s, Journaling, and noatime/relatime]</ref> 请依照数据自行权衡利弊 <ins class="diffchange diffchange-inline">。值得注意的是,<tt>noatime</tt>可能会导致某些依赖时间戳的程序产生问题,因此现在通常<tt>relatime</tt>代替 </ins>。</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>===I/O 调度方案===</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>===I/O 调度方案===</div></td></tr>
</table>
Biergaizi
http://linux-wiki.cn/index.php?title=SSD_(%E5%9B%BA%E6%80%81%E7%A1%AC%E7%9B%98)&diff=2091&oldid=prev
Biergaizi: /* 状态检查 */ 改用我的 Intel SSD 输出结果以便体现上文所说的 Intel 参数。
2013-05-01T07:19:10Z
<p><span class="autocomment">状态检查: </span> 改用我的 Intel SSD 输出结果以便体现上文所说的 Intel 参数。</p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←上一修订</td>
<td colspan='2' style="background-color: white; color:black;">在2013年5月1日 (三) 07:19所做的修订版本</td>
</tr><tr><td colspan="2" class="diff-lineno">第104行:</td>
<td colspan="2" class="diff-lineno">第104行:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> 如果对自己的SSD使用方式不放心,可以使用[http://gsmartcontrol.berlios.de gsmartcontrol]等工具,通过[[wpcn:S.M.A.R.T.|S.M.A.R.T.]]查看硬盘的状况。一般ID 5 对应的 ''Retired Block Count'' (或作 Reallocated Sector Count)<ref>http://media.kingston.com/support/downloads/MKP_306_SMART_attribute.pdf</ref> 反映了SSD已损坏的存储介质的情况。 Intel的SSD还提供''233 Media_Wearout_Indicator'',用一个整数来直观反映SSD的老化状况;以及''225 Host_Writes_32MiB'',反映已经向盘中写入了多少数据。 <ref>[http://serverfault.com/questions/316150/how-to-determine-number-of-write-cycles-or-expected-life-for-ssd-under-linux ServerFault: How to determine number of write cycles or expected life for SSD under Linux?]</ref></div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> 如果对自己的SSD使用方式不放心,可以使用[http://gsmartcontrol.berlios.de gsmartcontrol]等工具,通过[[wpcn:S.M.A.R.T.|S.M.A.R.T.]]查看硬盘的状况。一般ID 5 对应的 ''Retired Block Count'' (或作 Reallocated Sector Count)<ref>http://media.kingston.com/support/downloads/MKP_306_SMART_attribute.pdf</ref> 反映了SSD已损坏的存储介质的情况。 Intel的SSD还提供''233 Media_Wearout_Indicator'',用一个整数来直观反映SSD的老化状况;以及''225 Host_Writes_32MiB'',反映已经向盘中写入了多少数据。 <ref>[http://serverfault.com/questions/316150/how-to-determine-number-of-write-cycles-or-expected-life-for-ssd-under-linux ServerFault: How to determine number of write cycles or expected life for SSD under Linux?]</ref></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del># smartctl -data -A /dev/sda</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins># smartctl -data -A /dev/sda</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del>smartctl <del class="diffchange diffchange-inline">5</del>.<del class="diffchange diffchange-inline">40 2010</del>-10-<del class="diffchange diffchange-inline">16 r3189 </del>[x86_64<del class="diffchange diffchange-inline">-redhat</del>-linux-<del class="diffchange diffchange-inline">gnu</del>] (local build)</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>smartctl <ins class="diffchange diffchange-inline">6</ins>.<ins class="diffchange diffchange-inline">0 2012</ins>-10-<ins class="diffchange diffchange-inline">10 r3643 </ins>[x86_64-linux-<ins class="diffchange diffchange-inline">3.9.0-e-nvidia</ins>] (local build)</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del>Copyright (C) 2002-<del class="diffchange diffchange-inline">10 by </del>Bruce Allen, <del class="diffchange diffchange-inline">http://</del>smartmontools.<del class="diffchange diffchange-inline">sourceforge.net</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>Copyright (C) 2002-<ins class="diffchange diffchange-inline">12, </ins>Bruce Allen, <ins class="diffchange diffchange-inline">Christian Franke, www.</ins>smartmontools.<ins class="diffchange diffchange-inline">org</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del>=== START OF READ SMART DATA SECTION ===</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>=== START OF READ SMART DATA SECTION ===</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del>SMART Attributes Data Structure revision number: 5</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>SMART Attributes Data Structure revision number: 5</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del>Vendor Specific SMART Attributes with Thresholds:</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>Vendor Specific SMART Attributes with Thresholds:</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del>ID# ATTRIBUTE_NAME          FLAG    VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>ID# ATTRIBUTE_NAME          FLAG    VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">  </del>3 Spin_Up_Time            0x0020  100  100  000    Old_age  Offline      -      0</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">    </ins>3 Spin_Up_Time            0x0020  100  100  000    Old_age  Offline      -      0</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">  </del>4 Start_Stop_Count        0x0030  100  100  000    Old_age  Offline      -      0</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">    </ins>4 Start_Stop_Count        0x0030  100  100  000    Old_age  Offline      -      0</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">  </del>5 Reallocated_Sector_Ct  0x0032  100  100  000    Old_age  Always      -      <del class="diffchange diffchange-inline">1</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">    </ins>5 Reallocated_Sector_Ct  0x0032  100  100  000    Old_age  Always      -      <ins class="diffchange diffchange-inline">0</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">  </del>9 Power_On_Hours          0x0032  100  100  000    Old_age  Always      -      <del class="diffchange diffchange-inline">6855</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">    </ins>9 Power_On_Hours          0x0032  100  100  000    Old_age  Always      -      <ins class="diffchange diffchange-inline">4109</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline">  </del>12 Power_Cycle_Count      0x0032  100  100  000    Old_age  Always      -      <del class="diffchange diffchange-inline">68</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>12 Power_Cycle_Count      0x0032  100  100  000    Old_age  Always      -      <ins class="diffchange diffchange-inline">422</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>  192 Unsafe_Shutdown_Count  0x0032  100  100  000    Old_age  Always      -      <del class="diffchange diffchange-inline">30</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  170 Reserve_Block_Count    0x0033  100  100  010    Pre-fail </ins> <ins class="diffchange diffchange-inline">Always      -      0</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> 225 Host_Writes_32MiB      </del>0x0030  <del class="diffchange diffchange-inline">200 </del>  <del class="diffchange diffchange-inline">200 </del>  000    Old_age  Offline      -      <del class="diffchange diffchange-inline">148487</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  171 Program_Fail_Count      0x0032  100  100  000    Old_age  Always      -      0</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del>226 Workld_Media_Wear_Indic 0x0032  100  100  000    Old_age  Always      -      <del class="diffchange diffchange-inline">3168</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  172 Erase_Fail_Count        0x0032  100  100  000    Old_age  Always      -      0</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del>227 Workld_Host_Reads_Perc  0x0032  100  100  000    Old_age  Always      -      <del class="diffchange diffchange-inline">1</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  183 Runtime_Bad_Block      0x0030  100  100  000    Old_age  Offline      -      21</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del>228 Workload_Minutes        0x0032  100  100  000    Old_age  Always      -      <del class="diffchange diffchange-inline">1950295543</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  184 End-to-End_Error        0x0032  100  100  090    Old_age  Always      -      0</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del>232 Available_Reservd_Space 0x0033  <del class="diffchange diffchange-inline">099 </del>  <del class="diffchange diffchange-inline">099 </del>  010    Pre-fail  Always      -      0</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  187 Reported_Uncorrect      0x0032  100  100  000    Old_age  Always      -      0</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> </del>233 Media_Wearout_Indicator 0x0032  <del class="diffchange diffchange-inline">098 </del>  <del class="diffchange diffchange-inline">098 </del>  000    Old_age  Always      -      0</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>192 Unsafe_Shutdown_Count  0x0032  100  100  000    Old_age  Always      -      <ins class="diffchange diffchange-inline">216</ins></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div><del class="diffchange diffchange-inline"> 184 End</del>-<del class="diffchange diffchange-inline">to-End_Error </del>      <del class="diffchange diffchange-inline">0x0033 </del>  100  100  <del class="diffchange diffchange-inline">099 </del>  <del class="diffchange diffchange-inline">Pre-fail  </del>Always      -      <del class="diffchange diffchange-inline">0</del></div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  199 UDMA_CRC_Error_Count    </ins>0x0030  <ins class="diffchange diffchange-inline">100 </ins>  <ins class="diffchange diffchange-inline">100 </ins>  000    Old_age  Offline      -      <ins class="diffchange diffchange-inline">0</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  225 Host_Writes_32MiB      0x0032  100  100  000    Old_age  Always      -      203817</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>226 Workld_Media_Wear_Indic 0x0032  100  100  000    Old_age  Always      -      <ins class="diffchange diffchange-inline">1424</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>227 Workld_Host_Reads_Perc  0x0032  100  100  000    Old_age  Always      -      <ins class="diffchange diffchange-inline">60</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>228 Workload_Minutes        0x0032  100  100  000    Old_age  Always      -      <ins class="diffchange diffchange-inline">246549</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>232 Available_Reservd_Space 0x0033  <ins class="diffchange diffchange-inline">100 </ins>  <ins class="diffchange diffchange-inline">100 </ins>  010    Pre-fail  Always      -      0</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  </ins>233 Media_Wearout_Indicator 0x0032  <ins class="diffchange diffchange-inline">099 </ins>  <ins class="diffchange diffchange-inline">099 </ins>  000    Old_age  Always      -      0</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  241 Host_Writes_32MiB      0x0032  100  100  000    Old_age  Always      </ins>- <ins class="diffchange diffchange-inline">      203817</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins class="diffchange diffchange-inline">  242 Host_Reads_32MiB </ins>      <ins class="diffchange diffchange-inline">0x0032 </ins>  100  100  <ins class="diffchange diffchange-inline">000 </ins>  <ins class="diffchange diffchange-inline">Old_age  </ins>Always      -      <ins class="diffchange diffchange-inline">314998</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>==参考资料==</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>==参考资料==</div></td></tr>
</table>
Biergaizi
http://linux-wiki.cn/index.php?title=SSD_(%E5%9B%BA%E6%80%81%E7%A1%AC%E7%9B%98)&diff=1940&oldid=prev
Funicorn: /* 将浏览器缓存移入内存 */
2012-09-26T22:32:27Z
<p><span class="autocomment">将浏览器缓存移入内存</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←上一修订</td>
<td colspan='2' style="background-color: white; color:black;">在2012年9月26日 (三) 22:32所做的修订版本</td>
</tr><tr><td colspan="2" class="diff-lineno">第96行:</td>
<td colspan="2" class="diff-lineno">第96行:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> 原则上,将浏览器的profile移入tmpfs是一件很简单的任务,只需要先建立一个tmpfs分区,然后将浏览器的profile拷贝到tmpfs分区即可。然而tmpfs中的文件只驻留在内存中,系统断电后这些文件就会被清空。很显然,如果要保留对浏览器profile所做的修改,就必须适时对这些文件进行备份。挂载一个tmpfs、让profile在tmpfs中工作、适时备份profile,这三个步骤就可以完美实现上面的计划。而这三个步骤在一个很有名的脚本中已经完成了,这个脚本叫做profile-sync-daemon(psd)。</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div> 原则上,将浏览器的profile移入tmpfs是一件很简单的任务,只需要先建立一个tmpfs分区,然后将浏览器的profile拷贝到tmpfs分区即可。然而tmpfs中的文件只驻留在内存中,系统断电后这些文件就会被清空。很显然,如果要保留对浏览器profile所做的修改,就必须适时对这些文件进行备份。挂载一个tmpfs、让profile在tmpfs中工作、适时备份profile,这三个步骤就可以完美实现上面的计划。而这三个步骤在一个很有名的脚本中已经完成了,这个脚本叫做profile-sync-daemon(psd)。</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="background: #ffa; color:black; font-size: smaller;"><div>psd是一段让多种浏览器的profile自动工作在tmpfs中并且定期备份的bash脚本。psd的配置非常简单,它需要一个运行脚本(profile-sync-daemon),一个启动服务文件(psd)和一个服务配置文件(psd.conf)。此外,psd在archlinux和gentoo中被扩充我为完整的软件包,并且也存在debian和其衍生发行版的deb包。psd支持firefox、chrome和opera等主流的浏览器,安装启动后自动在后台运行,每隔一小时对profile进行备份,daemon运行方式可以保证在关机或重启电脑之前完成备份(daemon脚本的优点之一)。</div></td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div>psd是一段让多种浏览器的profile自动工作在tmpfs中并且定期备份的bash脚本。psd的配置非常简单,它需要一个运行脚本(profile-sync-daemon),一个启动服务文件(psd)和一个服务配置文件(psd.conf)。此外,psd在archlinux和gentoo中被扩充我为完整的软件包,并且也存在debian和其衍生发行版的deb包。psd支持firefox、chrome和opera等主流的浏览器,安装启动后自动在后台运行,每隔一小时对profile进行备份,daemon运行方式可以保证在关机或重启电脑之前完成备份(daemon脚本的优点之一) <ins class="diffchange diffchange-inline">。事实上psd并非只适合固态硬盘,由于可以加快浏览器运行速度,psd也运行于很多非SSD的linux桌面 </ins>。</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{TODO|普通桌面环境每天浏览器写入的缓存大概几何?是否值得将其移入内存?}}</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{TODO|普通桌面环境每天浏览器写入的缓存大概几何?是否值得将其移入内存?}}</div></td></tr>
</table>
Funicorn
http://linux-wiki.cn/index.php?title=SSD_(%E5%9B%BA%E6%80%81%E7%A1%AC%E7%9B%98)&diff=1939&oldid=prev
Funicorn: /* 将浏览器缓存移入内存 */
2012-09-26T22:27:17Z
<p><span class="autocomment">将浏览器缓存移入内存</span></p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←上一修订</td>
<td colspan='2' style="background-color: white; color:black;">在2012年9月26日 (三) 22:27所做的修订版本</td>
</tr><tr><td colspan="2" class="diff-lineno">第90行:</td>
<td colspan="2" class="diff-lineno">第90行:</td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>===将浏览器缓存移入内存===</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>===将浏览器缓存移入内存===</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">由于大量小文件频繁读写会损害SSD硬盘寿命,因此当tmpfs在当前的linux桌面上变得简单易用时,将这些需要频繁读写的文件挂载到一个tmpfs上进行日常操作,既加快了I/O速度,又可以大大降低硬盘读写次数,因此tmpfs成为了固态硬盘的绝佳助手。所谓tmpfs就是被挂载到当前根文件系统下的一段内存空间,它具有特定的访问路径和大小,可以读写,在系统断电后会自动清空。tmpfs在win下有个不错的中文翻译,叫做“内存盘”(ramdisk)。</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">在一个普通用户的linux桌面上,有一类应用软件几乎每天都要工作很长时间、并且有频繁读写大量小文件的习惯,这种软件被称为浏览器。任何一种浏览器(例如Firefox、Chrome或Opera)都保留了一种工作特性,它会在硬盘的某个路径下建立一份“档案”(profile),然后在运行过程中频繁而不间断的读写档案中的文件,这样的文件大多与浏览器访问过的网页有关,这些文件被称为浏览器缓存。在SSD上运行的浏览器,可能会因为大量读写缓存出现卡顿现象,并且可能影响SSD寿命。因此,如果能够将浏览器的“档案”移入一个tmpfs,让浏览器在内存中读写档案文件和缓存,就可以大大减轻SSD的负担。</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">原则上,将浏览器的profile移入tmpfs是一件很简单的任务,只需要先建立一个tmpfs分区,然后将浏览器的profile拷贝到tmpfs分区即可。然而tmpfs中的文件只驻留在内存中,系统断电后这些文件就会被清空。很显然,如果要保留对浏览器profile所做的修改,就必须适时对这些文件进行备份。挂载一个tmpfs、让profile在tmpfs中工作、适时备份profile,这三个步骤就可以完美实现上面的计划。而这三个步骤在一个很有名的脚本中已经完成了,这个脚本叫做profile-sync-daemon(psd)。</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">psd是一段让多种浏览器的profile自动工作在tmpfs中并且定期备份的bash脚本。psd的配置非常简单,它需要一个运行脚本(profile-sync-daemon),一个启动服务文件(psd)和一个服务配置文件(psd.conf)。此外,psd在archlinux和gentoo中被扩充我为完整的软件包,并且也存在debian和其衍生发行版的deb包。psd支持firefox、chrome和opera等主流的浏览器,安装启动后自动在后台运行,每隔一小时对profile进行备份,daemon运行方式可以保证在关机或重启电脑之前完成备份(daemon脚本的优点之一)。</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{TODO|普通桌面环境每天浏览器写入的缓存大概几何?是否值得将其移入内存?}}</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>{{TODO|普通桌面环境每天浏览器写入的缓存大概几何?是否值得将其移入内存?}}</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">{{TODO|参考文献,命令行示例}}</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>==状态检查==</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>==状态检查==</div></td></tr>
</table>
Funicorn
http://linux-wiki.cn/index.php?title=SSD_(%E5%9B%BA%E6%80%81%E7%A1%AC%E7%9B%98)&diff=1904&oldid=prev
Chenxing: 谨慎转载
2012-07-01T19:25:44Z
<p>谨慎转载</p>
<table style="background-color: white; color:black;">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr valign='top'>
<td colspan='2' style="background-color: white; color:black;">←上一修订</td>
<td colspan='2' style="background-color: white; color:black;">在2012年7月1日 (日) 19:25所做的修订版本</td>
</tr><tr><td colspan="2" class="diff-lineno">第1行:</td>
<td colspan="2" class="diff-lineno">第1行:</td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;">{{谨慎转载}}</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="background: #cfc; color:black; font-size: smaller;"><div><ins style="color: red; font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>SSD(Solid State Drive,[[wpcn:固态硬盘|固态硬盘]])以其读写速度快、寻址快、无机械移动部件、无噪声等突出优点日益受到人们的青睐。由于其工作原理与传统的磁盘完全不同,故在操作系统和应用程序层面都有对其做专门优化的空间。</div></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"><div>SSD(Solid State Drive,[[wpcn:固态硬盘|固态硬盘]])以其读写速度快、寻址快、无机械移动部件、无噪声等突出优点日益受到人们的青睐。由于其工作原理与传统的磁盘完全不同,故在操作系统和应用程序层面都有对其做专门优化的空间。</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td><td class='diff-marker'> </td><td style="background: #eee; color:black; font-size: smaller;"></td></tr>
</table>
Chenxing
http://linux-wiki.cn/index.php?title=SSD_(%E5%9B%BA%E6%80%81%E7%A1%AC%E7%9B%98)&diff=1902&oldid=prev
Chenxing: 以内容“SSD(Solid State Drive,wpcn:固态硬盘|)以其读写速度快、寻址快、无机械移动部件、无噪声等突出优点日益受到人们的青睐。由...”创建新页面
2012-07-01T19:10:53Z
<p>以内容“SSD(Solid State Drive,<a href="http://zh.wikipedia.org/wiki/%E5%9B%BA%E6%80%81%E7%A1%AC%E7%9B%98" class="extiw" title="wpcn:固态硬盘">wpcn:固态硬盘</a>)以其读写速度快、寻址快、无机械移动部件、无噪声等突出优点日益受到人们的青睐。由...”创建新页面</p>
<p><b>新建页面</b></p><div>SSD(Solid State Drive,[[wpcn:固态硬盘|固态硬盘]])以其读写速度快、寻址快、无机械移动部件、无噪声等突出优点日益受到人们的青睐。由于其工作原理与传统的磁盘完全不同,故在操作系统和应用程序层面都有对其做专门优化的空间。<br />
<br />
值得一提的是,SSD硬盘无需任何特殊配置就可很好地应用在桌面环境上。本文介绍的配置可以改善SSD的性能和使用时间,但未必十分必须。<br />
<br />
==原理分析==<br />
SSD硬盘之所以需要特别优化系统配置,主要是由其特性决定的:<br />
;写入方式:向SSD硬盘写入数据时,不能像写入普通硬盘那样直接覆盖,而是要先擦除、再写入。不幸的是,由于设计的原因,虽然写入操作可以以'''页'''(page,常为 4KB)为单位,擦除操作的最小单位一般是'''块'''(block,常为 512KB)。<ref name="wp_TRIM">[[wpen:TRIM|Wikipedia: TRIM]]</ref>如果想保留块中的其它数据,需要在擦除前要先读出该块的数据,并在修改后写回。所以每一次写操作实际写到硬盘上的数据很可能原来计划比要写的数据多,这就是所谓的 [[wpen:Write amplification|Write amplification]] 效应。这是SSD的读取比写入快得多的原因之一。<br />
;存储单元损耗 (Wearing):SSD的每一个存储单元被擦除、写入的次数是有限的。市面上常见的使用 [[wpen:Multi-level cell|MLC (Multi-Level Cell)]] 技术的SSD,单个存储单元只能被擦除、重写几千次,而采用相对昂贵的 [[wpen:Multi-level_cell#Single-level_cell|SLC (Single-Level Cell)]] 的SSD也有几万到几十万次的擦除寿命<ref name="write_amp">[[wpen:Write_amplification|Wikipedia: Write Amplification]]</ref>。这是很多人对 SSD 硬盘不放心的因素之一,但实际上得益于[[wpcn:耗损平均技术|耗损平均技术]],该问题对普通用户的影响并不显著。<br />
;耗损平均技术 (Wear Leveling): 虽然每个存储单元的寿命有限,但每个物理存储单元对应的逻辑地址没必要是一成不变的。通过将要写入的数据动态地映射到不同的物理存储单元,SSD的寿命可以得到明显的提升<ref>[[wpen:Wear_leveling|Wikipedia: Wear leveling]]</ref>。如一个 64GB 的 SSD 设备,如果每个单元可被擦除、重写3000次,而某桌面用户每天写入 10GB 的数据,该设备出现有存储单元报废需要约 <tt>64 * 3000 / 10 / 365 = 52年 </tt>。 由于一般来讲桌面应用的写入并没有这么多,所以因为擦除、写入次数过多而导致SSD丢失数据的顾虑是没有什么必要的。一些评测数据<ref>[http://www.xtremesystems.org/forums/showthread.php?271063-SSD-Write-Endurance-25nm-Vs-34nm SSD Write Endurance 25nm Vs 34nm]</ref>和分析文章<ref>[http://www.storagesearch.com/ssdmyths-endurance.html SSD Myths and Legends - "write endurance"]</ref>都支持了这一点。<br />
<br />
针对以上特性,在软件方面优化SSD的性能应主要集中在以下几个方面:<br />
* 提高物理写入的效率,减缓[[wpen:Write amplification|Write amplification]]。<br />
* 充分利用SSD随机访问快的特性。<br />
* 减少不必要的硬盘写操作。<br />
<br />
与此相关的,涉及到如下两个术语:<br />
;分区对齐 (Partition Alignment):由于SSD向一个块写入数据前要先擦除整个块,如果要写入的一个逻辑块分布在两个物理块中,那么涉及到的两个物理块都要被擦除重写。而如果将分区表和文件系统向物理块对齐,就可以减少这种情况,延长硬盘的寿命。一般SSD的块大小都能整除 512KiB <ref name="arch">[https://wiki.archlinux.org/index.php/Solid_State_Drives ArchWiki: Solid State Drives]</ref>,所以将分区的启始逻辑位置设为 512KiB 或 1MiB 的整数倍通常是比较合理的。<br />
;TRIM: TRIM 本身是一个 SATA 指令。在删除文件时,文件系统一般只做必要的标记而不真正抹去存储介质上的数据。对于普通磁盘,这就足够了,被标记的部分以后在需要时会被覆盖。而对于 SSD 硬盘,告知硬盘有些块不再被需要是很有意义的,硬盘可以据此优化其垃圾回收过程,加快以后写入数据的速度。<ref name="wp_TRIM" />。<br />
<br />
==Linux环境配置==<br />
由于生产环境的需求通常各不相同,配置难以一概而论,这里主要讨论使用SSD的桌面Linux环境配置。<br />
<br />
===分区对齐===<br />
使用多数现代分区工具分区的硬盘,一般是已经对齐的。如在较新的[[wpen:GParted|GParted]]中<ref>[http://gparted.sourceforge.net/display-doc.php?name=help-manual#gparted-specify-partition-alignment GParted Manual: Specifying Partition Alignment]</ref>,新建分区的默认对齐方式就是 MiB(有些版本的GParted翻译作“排序”)。<br />
<br />
检验是否分区已正确对齐,可以通过 <tt>fdisk -l</tt> 命令(仅适用于使用[[wpcn:主引导记录|MBR]]格式分区表)或 GParted 获取分区的首扇区,由于逻辑扇区的大小一般是 512 字节,如果首扇区的扇区号是 1024 的倍数,则分区已向 512KiB 对齐,如果首扇区号是 2048 的倍数,则分区已向 1MiB 对齐。如:<br />
$ sudo fdisk -l<br />
Disk /dev/sdb: 96.0 GB, 96029466624 bytes<br />
255 heads, 63 sectors/track, 11674 cylinders, total 187557552 sectors<br />
'''Units = 扇区 of 1 * 512 = 512 bytes'''<br />
Sector size (logical/physical): 512 bytes / 512 bytes<br />
I/O size (minimum/optimal): 512 bytes / 512 bytes<br />
Disk identifier: 0x00018744<br />
<br />
设备 Boot Start End Blocks Id System<br />
/dev/sdb1 '''2048''' 62629887 31313920 83 Linux<br />
/dev/sdb2 '''62629888''' 103606271 20488192 83 Linux<br />
/dev/sdb3 '''103606272''' 144742399 20568064 83 Linux<br />
/dev/sdb4 '''144742400''' 167077887 11167744 83 Linux<br />
上例中,加粗部分均为 2048 的倍数,说明分区已对齐。如果发现分区不幸未对齐,则可能需要删除分区重新来过了。<br />
<br />
如果使用较新的[[wpcn:全局唯一标识分区表|GPT]]格式的分区表,则需要用<tt>gdisk</tt>查看。<br />
<br />
===挂载选项===<br />
{{Hint|修改挂载选项的具体方法可参见[[fstab]]。}}<br />
<br />
开发中的[[wpcn:btrfs|btrfs]]正在试图对 SSD 硬盘做专门的优化,用户可以通过<tt>-o ssd</tt>[[:Category:Mount|挂载]]选项启用<ref name="btrfs">[https://btrfs.wiki.kernel.org/index.php/FAQ#Is_Btrfs_optimized_for_SSD.3F btrfs Wiki: FAQ]</ref>。<br />
<br />
另一个在很多教程中出现的选项是<tt>-o discard</tt><ref name="arch" /><ref name="apc">[http://apcmag.com/how-to-maximise-ssd-performance-with-linux.htm How to maximise SSD performance with Linux]</ref><ref name="oschina">[http://www.oschina.net/question/28_44835 开源中国社区:Linux 系统下使用 ssd 固态硬盘]</ref>,该选项可用于 [[ext4]] 和 [[btrfs]] 文件系统,作用是在删除文件时实时发出 TRIM 指令,以期加快以后写数据的速度。值得注意的是,该指令的效果是受到严重怀疑的<ref>[http://opensuse.14.n6.nabble.com/SSD-detection-when-creating-first-time-fstab-td3313048.html OpenSUSE Forum: SSD detection when creating first time fstab ?] </ref>。2011年中旬的数据<ref name="discard">[http://en.opensuse.org/SDB:SSD_discard_%28trim%29_support OpenSUSE: SDB:SSD discard (trim) support]</ref>表明, '''discard 选项非但没有提升 SSD 的效率,反而使其变慢了'''。Btrfs的<tt>-o ssd</tt>选项也不会启用<tt>discard</tt><ref name="btrfs"/>。 相比之下,定时发送 TRIM 指令可能是更好的选择(见后文)。<br />
<br />
<tt>noatime</tt>(或<tt>relatime</tt>), <tt>nodiratime</tt>是另外两个可以考虑的挂载选项,它们防止在读文件时更改文件的“最近访问”时间戳,减少写入硬盘的次数。<ref name="arch"/><ref name="apc"/>数据显示,采用<tt>noatime</tt>选项后,在编译Linux内核的过程中,硬盘写入量比没使用时少了约 13% 。<ref name="ted">[http://tytso.livejournal.com/61830.html SSD’s, Journaling, and noatime/relatime]</ref> 请依照数据自行权衡利弊。<br />
<br />
===I/O 调度方案===<br />
默认的I/O调度一般针对磁盘寻址慢的特性做了专门优化,但对于SSD而言,由于访问磁盘不同逻辑扇区的时间几乎是一样的,这个优化就没有什么作用了,反而耗费了CPU时间。<ref name="arch" /><ref>[http://www.ab9il.net/linux/solid-state-drives1.html Linux on Solid State Drives]</ref>具体到 Linux 系统中,就是用 [[wpen:Noop scheduler|Noop 调度器]] (直接把所有 I/O 请求送到一个队列中)代替内核默认的 [[wpen:CFQ|CFQ]] 调度器。<br />
<br />
查看某设备当前使用的调度器的方法是:<br />
$ cat /sys/block/'''sdX'''/queue/scheduler<br />
noop deadline [cfq]<br />
<br />
而下面的命令可以设置<tt>sdX</tt>的调度器为<tt>noop</tt>。<br />
<source lang="bash"><br />
echo noop > /sys/block/sdX/queue/scheduler<br />
</source><br />
<br />
如想让此成为默认设置,则需要将上面的命令[[添加开机自动运行程序|加到自动启动程序]]的列表中。<br />
<br />
===定时 TRIM===<br />
虽然实时TRIM选项<tt>-o discard</tt>效果并不好,但定期对已删除的文件做TRIM还是有意义的<ref name="discard" />,如:<br />
<source lang="bash"><br />
# 告知硬盘分区"/"中的哪些块已不再被使用<br />
fstrim -v /<br />
</source><br />
推荐使用crontab[[定时执行程序|定时执行]]该命令。<br />
<br />
==其它减少SSD写入的方案==<br />
减少写入固然可以延长SSD的寿命,但依前述分析,SSD 可写入次数对于桌面用户而言一般是足够的。所以,在考虑采用减少 SSD 写入方案时,要慎重分析其潜在的后果,再做决定。<br />
<br />
===在tmpfs里编译===<br />
有些需要编译安装的软件,在''/tmp''(通常挂载在内存上)中编译通常是个不错的选择。<br />
<br />
===挂载需要频繁写入的分区到普通磁盘===<br />
有人建议将''/var''、交换分区等挂载到普通磁盘以减少对 SSD 的写入,但这些操作也会同时导致系统性能的下降。对于桌面用户而言,SSD上的''/var''一般会大幅包管理工具的性能,而SSD上的交换分区会让系统休眠、唤醒的速度大大加快。<br />
<br />
===取消文件系统日志===<br />
[[wpcn:日志文件系统|日志文件系统]]是现代的文件系统的重要特征,在内核崩溃或突然停电等突发事件发生后,有日志的文件系统恢复起来要快得多。取消文件系统日志固然会减少硬盘写入,但也使文件系统的可靠性下降。有实验结果显示<ref name="ted"/>,关闭了日志的文件系统在编译内核的过程中硬盘写入比未关闭日志的大约少 3% - 6%,在删除文件时少约 40% - 50% (删除文件的写入操作相对而言基数很小)。<br />
<br />
所以对于有些教程提议的取消SSD的文件系统日志以减少写入以加快速度<ref name="oschina"/>的方案,一定要在谨慎分析后决定是否采用。<br />
<br />
===将浏览器缓存移入内存===<br />
{{TODO|普通桌面环境每天浏览器写入的缓存大概几何?是否值得将其移入内存?}}<br />
<br />
==状态检查==<br />
如果对自己的SSD使用方式不放心,可以使用[http://gsmartcontrol.berlios.de gsmartcontrol]等工具,通过[[wpcn:S.M.A.R.T.|S.M.A.R.T.]]查看硬盘的状况。一般ID 5 对应的 ''Retired Block Count'' (或作 Reallocated Sector Count)<ref>http://media.kingston.com/support/downloads/MKP_306_SMART_attribute.pdf</ref> 反映了SSD已损坏的存储介质的情况。 Intel的SSD还提供''233 Media_Wearout_Indicator'',用一个整数来直观反映SSD的老化状况;以及''225 Host_Writes_32MiB'',反映已经向盘中写入了多少数据。 <ref>[http://serverfault.com/questions/316150/how-to-determine-number-of-write-cycles-or-expected-life-for-ssd-under-linux ServerFault: How to determine number of write cycles or expected life for SSD under Linux?]</ref><br />
<br />
# smartctl -data -A /dev/sda<br />
smartctl 5.40 2010-10-16 r3189 [x86_64-redhat-linux-gnu] (local build)<br />
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net<br />
<br />
=== START OF READ SMART DATA SECTION ===<br />
SMART Attributes Data Structure revision number: 5<br />
Vendor Specific SMART Attributes with Thresholds:<br />
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE<br />
3 Spin_Up_Time 0x0020 100 100 000 Old_age Offline - 0<br />
4 Start_Stop_Count 0x0030 100 100 000 Old_age Offline - 0<br />
5 Reallocated_Sector_Ct 0x0032 100 100 000 Old_age Always - 1<br />
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 6855<br />
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 68<br />
192 Unsafe_Shutdown_Count 0x0032 100 100 000 Old_age Always - 30<br />
225 Host_Writes_32MiB 0x0030 200 200 000 Old_age Offline - 148487<br />
226 Workld_Media_Wear_Indic 0x0032 100 100 000 Old_age Always - 3168<br />
227 Workld_Host_Reads_Perc 0x0032 100 100 000 Old_age Always - 1<br />
228 Workload_Minutes 0x0032 100 100 000 Old_age Always - 1950295543<br />
232 Available_Reservd_Space 0x0033 099 099 010 Pre-fail Always - 0<br />
233 Media_Wearout_Indicator 0x0032 098 098 000 Old_age Always - 0<br />
184 End-to-End_Error 0x0033 100 100 099 Pre-fail Always - 0<br />
<br />
==参考资料==<br />
<references /><br />
<br />
[[Category: 系统设置]] [[Category: 硬件的驱动与使用]]</div>
Chenxing