Optimizing SSD (Solid State Drive) Configuration Methods in Linux
当我在运行 Linux 的计算机上安装我的第一块固态驱动器(SSD)后,我开始探索如何用好它们。SSD 在操作方式上与传统磁性驱动器不同,并且它们需要在软件上另行处理以达到功能优化。
传统磁盘驱动与ssd的不同在传统磁盘驱动器上,删除时所删除的文件不会从磁盘中完全删除。这就是为什么你可以恢复已删除的文件的原因。基本上,文件系统仅引用磁盘上文件的位置,并且当文件被删除时,该引用被擦除,以允许你在这些空间中写入新数据覆盖原来的数据。然而,对于 SSD,新数据只能写在驱动器上完全新的或已擦除的单元上。因为必须在写入之前清除空间,如果在写入文件时尚未有足够的可用空间,则必须首先擦除该空间。这可能会对性能产生负面影响。
如果操作系统在写入新数据之前就擦除了未使用的空间,而不是在写入时同时进行擦除,则可以提高文件保存性能。这种做法就是 TRIM。 TRIM 命令本质上允许你的操作系统告诉驱动器哪些区域的数据不再使用,以便擦除它们,加快驱动器将来的写入,可以 SSD 的用户提供更佳的体验。
配置ssd参数在 Linux 中,fstrim 提供此功能,它可以为写入新数据而准备驱动器,并延长驱动器的使用寿命。由于在我使用的 Linux 发行版上 SSD 的 trim 不是自动的,所以必须去调度该操作,否则 SSD 的性能会随着时间的推移而降低。
为了在驱动器上运行 fstrim,驱动器本身以及其上的文件系统必须支持 TRIM。在文件系统挂载过程中可以启用 TRIM。例如,为了将设备 /dev/sda2 启用 TRIM 挂载到/mnt ,你要运行:
mount -t ext4 -o discard /dev/sda2 /mnt
一旦启用,TRIM 过程本身就相当简单。TRIM SSD 也可以在命令行或 cron 任务中手动完成。作为超级用户(使用 su 或 sudo),运行fstrim / -v 以完成手动 trim,或者设置 cron 任务以在计算机未使用时定期为你运行此命令。对于fstrim 的完整选项列表请参考它的 man 手册。
硬件支持根据使用的驱动器接口类型如 PCI、ATA、SCSI 还是 SD/MMC 而有所不同。你需要咨询你的 Linux 供应商以了解你的特定发行版是如何支持 TRIM 的。
例如,红帽提供以下 SSD 磁盘指南。“性能随着所使用的块数接近磁盘容量而降低,性能影响程度因供应商而异,但是所有设备都会遇到一些性能降低。为了解决性能降低问题,主机系统(例如 Linux 内核)使用丢弃请求以通知存储器给定范围的块不再使用。”
Debian wiki 提供了 SSD 使用的一些基本注意事项:使用 Linux 3.2 或更高版本内核,使用 SSD 的最新固件,使用 EXT4 文件系统,并且“在正常工作负载下有足够的 DRAM 用来操作而不用使用交换空间“。
The above is the detailed content of Optimizing SSD (Solid State Drive) Configuration Methods in Linux. For more information, please follow other related articles on the PHP Chinese website!

This guide details how to configure automatic service restarts in Linux using systemd, enhancing system reliability and minimizing downtime. System administrators often rely on this functionality to ensure critical services, such as web servers (Apa

As Linux users, we often rely on commonly used commands ls, grep, awk, sed and find to complete the work. But Linux has a large number of lesser-known commands that can save time, automate tasks and simplify workflows. This article will explore some underrated but powerful Linux commands that deserve more attention. rename – efficient batch rename files The rename command is the savior when you need to rename multiple files at once. Without using loops containing mv, rename allows you to easily apply complex renaming patterns. Change all .txt files to .log. rename 's/\.txt$/\.log/' *

Linux systems provide various system services (such as process management, login, syslog, cron, etc.) and network services (such as remote login, email, printer, web hosting, data storage, file transfer, domain name resolution (using DNS), dynamic IP address allocation (using DHCP), and so on). Technically, a service is a process or group of process (usually known as a daemon) that runs continuously in the background, waiting for incoming requests (especially from the client). Linux supports different ways to manage services (start, stop, restart, enable automatic startup at system startup, etc.), usually through a process or service manager. Almost all modern Linux distributions now use the same

Run Windows Software and Games on Linux with CrossOver 25 Running Windows applications and games on Linux is now easier than ever, thanks to CrossOver 25 from CodeWeavers. This commercial software solution lets Linux users run a wide variety of Wind
![pCloud - The Most Secure Cloud Storage [50% Off Offer]](https://img.php.cn/upload/article/001/242/473/174580357418126.jpg?x-oss-process=image/resize,p_40)
Secure Your Data with pCloud: A Comprehensive Guide to Linux Installation pCloud, a leading secure cloud storage service, provides a robust platform for managing your files and data. This guide details the installation process on Linux systems. About

MangoHud: A powerful tool for real-time monitoring of Linux gaming performance MangoHud is a powerful and lightweight tool designed for gamers, developers, and anyone who wants to monitor system performance in real time. It acts as an overlay for Vulkan and OpenGL applications, displaying important information such as FPS, CPU and GPU usage, temperature, etc. This article will explore the functions, working principles and usage of MangoHud, and provide step-by-step instructions for installing and configuring MangoHud on Linux systems. What is MangoHud? MangoHud is an open source project available on GitHub and aims to provide a simple and customizable way to monitor

Managing archived files is a common task in Linux. This article, the first of a two-part series, explores five powerful command-line archive tools, detailing their features and usage with examples. 1. The tar Command: A Versatile Archiving Utility t

This guide explores various methods for comparing text files in Linux, a crucial task for system administrators and developers. We'll cover command-line tools and visual diff tools, highlighting their strengths and appropriate use cases. Let's assum


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 English version
Recommended: Win version, supports code prompts!
