These storage units are a new way to expand our PC’s memory. They allow programs to run more smoothly and quickly. This is clearly evident when turning on the system and when running programs that require more processing power.
Optimizing an SSD drive in a Linux operating system can have several compelling reasons. For example, making your system run faster—whatever your goal, we’ll help you accomplish this quickly and easily.
How to optimize an SSD drive on a Linux operating system – Quick and easy
Index( )
- What is the way to control the amount of temporary files?
- How to reduce SWAP partition usage?
- In what ways is it possible to activate TRIM?
- Scheduled periodically
- In continuous mode
- What is the way to modify IO Schedulers?
- What is done to complete SSD optimization?
What is the way to control the amount of temporary files?
Temporary files often take up a considerable amount of space on our computer’s hard drive. Deleting them guarantees more storage capacity, and this can be done safely and easily . As we know, Linux is a tremendous piece of software that executes functions automatically. It deletes all temporary files stored on the PC every time the system restarts.
It’s worth noting that you can control the amount of temporary files stored on your hard drive by limiting the number of websites you visit. However, you can also manually delete these types of files to avoid having to restart your system every time. To do so, follow the procedure below.
- First, you must become superuser. Next, change the /var/tmp directory to # cd /var/tmp. Caution – …
- Next, in the # rm -r * directory, you’ll delete the files and subdirectories. Then, locate other temporary file directories and repeat this process to free up memory on your PC and ensure your system runs efficiently.
How to reduce SWAP partition usage?
Using Linux system commands, we can incorporate programs or functions into software. For this reason, it’s important to know their purpose. Additionally, we can use them to schedule SWAP partitioning to reduce its usage. This partition plays a very important role in the computer; it begins to work when our PC’s RAM is full. However, reducing its usage allows the computer to run programs faster.
We can do this through the kernel, which decides when to transfer information from RAM to the swap memory. Since Linux is open source, we can configure the kernel to wait until our RAM is almost full before beginning the transfer.
This is achieved by modifying the swappiness value. This ranges from 0 to 100, but we must be careful not to go to either extreme. If we select 100, the swapping process will be constant, while if we select 0, the information exchange will not occur. The recommended parameters in this case would be 5 to 10. We can do this using a terminal by running the following commands.
- cat /proc/sys/vm/swappiness. When running this command, the default value for swappiness is 60. To change this value, type the following:
- sudo sysctl -w vm.swappiness=10. After executing this action, we should use the computer for a reasonable period of time to ensure it works correctly.
- Once we are sure that our PC is performing well with these changes, we can make this configuration permanent using the following codes.
- sudo gedit /etc/sysctl.conf. Then, at the end of the folder, add the following vm.swappiness=10. If you want to confirm this configuration, open the terminal again and check it using this code: cat /proc/sys/vm/swappiness.
In what ways is it possible to activate TRIM?
To enable TRIM, your computer must meet several requirements. Typically, you must have a kernel version equivalent to or later than 2.6.28 to enable the tool. Your SSD must also have firmware. Current SSDs generally support TRIM. Additionally, your file system must be in one of these formats: btrfs, ext3, ext4, gfs2m, jfs, vfat, f2fs, ntfs, ocfs2, or xfs.
Once you’ve verified that your computer meets these requirements, you can activate this tool in two ways: scheduled periodically or continuously. Below, we’ll explain the process for both options.
Scheduled periodically
This function will be executed every time you delete a file from the SSD. Before starting this script, make sure the ‘ util-Linux’ package is available on your system . Now, we’ll provide you with the commands you need to run from systemd.
- sudo systemctl enable fstrim.timer
- sudo systemctl start fstrim.timer
In continuous mode
Laptop-hands_9688.jpg
Enabling this action brings several drawbacks to our disk capacity. To mention a few, it reduces the lifespan of our SSD , and our file system can frequently freeze and become corrupted.
And if you accidentally delete a file, it will be completely impossible to recover. This option is enabled by default in several Linux distributions. If you want to disable it, you can type the following:
- sudo nano /etc/fstab
To ensure that this action was performed efficiently, the following codes should appear on the terminal.
- # <file system> <mount point> <type> <options>
What is the way to modify IO Schedulers?
If you want to modify the IO Schedulers, we just have to execute the following code from the boot drive or terminal of our choice.
- [php]cat /sys/block/sd<strong>X</strong>/queue/scheduler[/php]. This command is used to select the program scheduler. You must replace the X with the drive that corresponds to your system.
What is done to complete SSD optimization?
Because Linux is open-source software, you can add any type of functionality and even create websites using programs like WordPress . Similarly, you can optimize SSD drives by performing very simple configurations. Once each of the tools mentioned above is configured and installed, there’s only one action left to take. Restart your computer so that all the changes you’ve made can begin to fully take effect.

