mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
translaed
This commit is contained in:
parent
0f432a4b15
commit
552d6b2fe5
@ -1,58 +0,0 @@
|
|||||||
translating---geekpi
|
|
||||||
|
|
||||||
Solid state drives in Linux: Enabling TRIM for SSDs
|
|
||||||
============================================================
|
|
||||||
|
|
||||||
![Solid state drives in Linux: Enabling TRIM for SSDs](https://opensource.com/sites/default/files/styles/image-full-size/public/images/business/BUSINESS_robots.png?itok=6eqf2Wjv "Solid state drives in Linux: Enabling TRIM for SSDs")
|
|
||||||
Image by : opensource.com
|
|
||||||
|
|
||||||
After installing my first solid state drive (SSD) in a computer that was running Linux, I have begun to explore how to take care of them. Solid state drives are different than traditional magnetic drives in the way that they operate, and they require different care from the software side in order to function optimally.
|
|
||||||
|
|
||||||
On traditional magnetic drives, deleted files are not completely removed from the disk at the time of deletion. This is why you can recover deleted files. Essentially, the filesystem just references the location of a file on the disk, and when a file is deleted, that reference is erased, allowing you to write new data over old data in these blank spaces. However, with SSDs, new data can only be written on completely new or erased cells of the drive. Because the space must be cleared prior to a write, if enough free space is not already available at the time a file is being written, it must be erased first. This can negatively affect performance.
|
|
||||||
|
|
||||||
If the operating system were to erase unused space before writing new data, at a time when the device is not simultaneously trying to write, file saving performance could be improved. Enter [TRIM][1]. A TRIM command essentially allows your operating system to tell the drive which areas of data are no longer being used so that it come wipe them, speeding up the drive for future writes, and providing users of SSDs with a more optimum experience.
|
|
||||||
|
|
||||||
In Linux, **fstrim** provides this functionality, readying the drive for new data to be written and extends the life of the drive over the long term. Since trimming SSDs is not automatic on the Linux distributions that I have used, it is imperative that it be scheduled or the performance of the SSD will degrade over time.
|
|
||||||
|
|
||||||
In order to run fstrim on a drive, the drive itself, as well as the file system sitting on top of it, must support TRIM. Enabling TRIM can be done during the filesystem mounting process. For example, in order to mount the device **/dev/sda2** to **/mnt** with TRIM enabled, you would run:
|
|
||||||
|
|
||||||
```
|
|
||||||
mount -t ext4 -o discard /dev/sda2 /mnt
|
|
||||||
```
|
|
||||||
|
|
||||||
TOnce enabled, the TRIM process itself is rather simple. Trimming your SSD can also be accomplished manually on the command line or in a cron job. As a super user (using su or sudo), run **fstrim / -v** to accomplish manual trimming, or set up a cron job to run this command for you on a regular basis when your computer is not in use. And for a complete list of fstrim, options refer to its [man page][3].
|
|
||||||
|
|
||||||
Hardware support varies depending on the type of drive interface used whether PCI, [ATA][4], [SCSI][5] or [SD/MMC][6]. It's also worth consulting with your Linux vendor to learn more about how your particular distribution may support TRIM.
|
|
||||||
|
|
||||||
For example, Red Hat offers the following the [SSD disk guidelines][7]. "Performance degrades as the number of used blocks approaches the disk capacity. The degree of performance impact varies greatly by vendor. However, all devices experience some degradation. To address the degradation issue, the host system (for example, the Linux kernel) may use discard requests to inform the storage that a given range of blocks is no longer in use."
|
|
||||||
|
|
||||||
The [Debian wiki ][8]offers some basic cautions for SSD use: Use a Linux kernel 3.2 or newer, use the latest firmware for the SSD, use the EXT4 file system, and "have enough DRAM required to operate without swap space under normal workloads."
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
作者简介:
|
|
||||||
|
|
||||||
Don Watkins - Educator, education technology specialist, entrepreneur, open source advocate. M.A. in Educational Psychology, MSED in Educational Leadership, Linux system administrator, CCNA, virtualization using Virtual Box. Follow me at @Don_Watkins .
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://opensource.com/article/17/1/solid-state-drives-linux-enabling-trim-ssds
|
|
||||||
|
|
||||||
作者:[Don Watkins][a]
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]:https://opensource.com/users/don-watkins
|
|
||||||
[1]:https://en.wikipedia.org/wiki/Trim_(computing)
|
|
||||||
[2]:https://opensource.com/article/17/1/solid-state-drives-linux-enabling-trim-ssds?rate=7ZBblixmfl2icbl8HWXjIfzUr3-EUjlgkOGyEhI1DK8
|
|
||||||
[3]:http://man7.org/linux/man-pages/man8/fstrim.8.html
|
|
||||||
[4]:https://en.wikipedia.org/wiki/Trim_(computing)#ATA
|
|
||||||
[5]:https://en.wikipedia.org/wiki/Trim_(computing)#SCSI
|
|
||||||
[6]:https://en.wikipedia.org/wiki/Trim_(computing)#SD.2FMMC
|
|
||||||
[7]:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/ch-ssd.html
|
|
||||||
[8]:https://wiki.debian.org/SSDOptimization
|
|
||||||
[9]:https://opensource.com/user/15542/feed
|
|
||||||
[10]:https://opensource.com/article/17/1/solid-state-drives-linux-enabling-trim-ssds#comments
|
|
||||||
[11]:https://opensource.com/users/don-watkins
|
|
@ -0,0 +1,56 @@
|
|||||||
|
Linux 中固态驱动器:启用 SSD 中的 TRIM
|
||||||
|
============================================================
|
||||||
|
|
||||||
|
![Solid state drives in Linux: Enabling TRIM for SSDs](https://opensource.com/sites/default/files/styles/image-full-size/public/images/business/BUSINESS_robots.png?itok=6eqf2Wjv "Solid state drives in Linux: Enabling TRIM for SSDs")
|
||||||
|
图片提供: opensource.com
|
||||||
|
|
||||||
|
当我在运行 Linux 的计算机上第一次安装固态驱动器(SSD)后,我开始探索如何处理它们。固态驱动器在操作方式上与传统磁性驱动器不同,并且它们需要在软件上不同的照顾以达到功能优化。
|
||||||
|
|
||||||
|
在传统磁盘驱动器上,删除时删除的文件不会从磁盘中完全删除。这就是为什么你可以恢复已删除的文件。基本上,文件系统仅引用磁盘上文件的位置,并且当文件被删除时,该引用被擦除,允许你在这些空间中写入新数据覆盖原来的数据。然而,对于SSD,新数据只能写在驱动器上完全新的或已擦除的单元上。因为必须在写入之前清除空间,如果在写入文件时尚未有足够的可用空间,则必须首先擦除该空间。这可能会对性能产生负面影响。
|
||||||
|
|
||||||
|
如果操作系统在写入新数据之前擦除未使用的空间,则在设备未同时尝试写入时,可以提高文件保存性能。进入 [TRIM][1] 页面。 TRIM 命令本质上允许你的操作系统告诉驱动器哪些区域的数据不再使用,以便擦除它们,加快驱动器以便将来写入,并为 SSD 的用户提供更佳的体验。
|
||||||
|
|
||||||
|
在 Linux 中,**fstrim** 提供此功能,准备写入新数据的驱动器,并延长驱动器的使用寿命。由于在我使用的 Linux 发行版上 trim SSD 不是自动的,所以必须进行调度,否则 SSD 的性能会随着时间的推移而降低。
|
||||||
|
|
||||||
|
为了在驱动器上运行 fstrim,驱动器本身以及坐在其上的文件系统必须支持 TRIM。在文件系统挂载过程中可以启用 TRIM。例如,为了将设备 **/dev/sda2** 带 TRIM 挂载到 **/mnt**,你要运行:
|
||||||
|
|
||||||
|
```
|
||||||
|
mount -t ext4 -o discard /dev/sda2 /mnt
|
||||||
|
```
|
||||||
|
|
||||||
|
一旦启用,TRIM 过程本身就相当简单。TRIM SSD 也可以在命令行或 cron 作业中手动完成。作为超级用户(使用su或sudo),运行 ** fstrim / -v** 以完成手动修剪,或者设置 cron 作业以在计算机未使用时定期为你运行此命令。对于 fstrim 的完整选项列表请参考它的[man 手册][3]。
|
||||||
|
|
||||||
|
硬件支持根据使用的驱动器接口类型如 PCI、[ATA][4]、[SCSI][5] 还是 [SD/MMC][6] 而有所不同。你需要咨询你的 Linux 供应商以了解更多关于你的特定发行版如何支持 TRIM。
|
||||||
|
|
||||||
|
例如,红帽提供以下[ SSD 磁盘准则][7]。“性能随着使用的块数量接近磁盘容量而降低,性能影响程度因供应商而异,但是所有设备都会遇到一些性能降低。为了解决性能降低问题,主机系统(例如 Linux 内核)使用丢弃请求以通知存储器给定范围的块不再使用。”
|
||||||
|
|
||||||
|
[Debian wiki][8] 提供了 SSD 使用的一些基本注意事项:使用 Linux 3.2 或更高版本内核,使用 SSD 的最新固件,使用 EXT4 文件系统,并且“在正常工作负载下有足够的 DRAM 用来操作而不用使用交换空间“。
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
作者简介:
|
||||||
|
|
||||||
|
Don Watkins - 教育家、教育技术专家、企业家、开源倡导者。教育心理学硕士、教育领导硕士、Linux系统管理员、CCNA、使用 Virtual Box 虚拟化。关注我 @Don_Watkins。
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://opensource.com/article/17/1/solid-state-drives-linux-enabling-trim-ssds
|
||||||
|
|
||||||
|
作者:[Don Watkins][a]
|
||||||
|
译者:[geekpi](https://github.com/geekpi)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:https://opensource.com/users/don-watkins
|
||||||
|
[1]:https://en.wikipedia.org/wiki/Trim_(computing)
|
||||||
|
[2]:https://opensource.com/article/17/1/solid-state-drives-linux-enabling-trim-ssds?rate=7ZBblixmfl2icbl8HWXjIfzUr3-EUjlgkOGyEhI1DK8
|
||||||
|
[3]:http://man7.org/linux/man-pages/man8/fstrim.8.html
|
||||||
|
[4]:https://en.wikipedia.org/wiki/Trim_(computing)#ATA
|
||||||
|
[5]:https://en.wikipedia.org/wiki/Trim_(computing)#SCSI
|
||||||
|
[6]:https://en.wikipedia.org/wiki/Trim_(computing)#SD.2FMMC
|
||||||
|
[7]:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/ch-ssd.html
|
||||||
|
[8]:https://wiki.debian.org/SSDOptimization
|
||||||
|
[9]:https://opensource.com/user/15542/feed
|
||||||
|
[10]:https://opensource.com/article/17/1/solid-state-drives-linux-enabling-trim-ssds#comments
|
||||||
|
[11]:https://opensource.com/users/don-watkins
|
Loading…
Reference in New Issue
Block a user