How to use an SSD and TRIM

January 5, 2015

Lang: cs en de es

Getting an SSD can improve the performance of your PC and make your work more enjoyable, but first you need to get familiar with SSD technology and usage to use the SSD properly and reap the benefits.

SSD Support and TRIM

You can read what an SSD drive is and how it differs on Wikipedia.

    In order to use TRIM the following conditions must be met:
  • Linux kernel 2.6.33 or later
  • filesystem: ext4, Btrfs, swap
    (support for other filesystems will surely be added over time)
  • SATA controller and SATA drive

Making an SSD work properly

The first thing to do is to choose a file system. For me, the obvious choice is the Btrfs file system. However, for the sake of seamless booting, I needed to have a different file system for the kernel partition, and I chose the EXT4 file system for this partition. I didn't use swap because I don't need it with enough RAM, plus it saves precious space that SSDs don't abound in. It's also a friendlier solution for the SSD drive.

Another basic question is how to partition the disk. As I mentioned above I created a partition for /boot. However, given the size of SSDs, it is advisable not to partition it too much. One of the advantages of the Btrfs filesystem is that snapshots/subvolumes, when used appropriately, don't even need to be partitioned! So I decided to create a large partition across the entire disk, just leaving room for a partition that will be used for installing and testing other distributions.
As with disks with large 4K blocks, partition alignment needs to be careful with SSDs. The disk needs to be aligned by sector! A suitable alignment is, for example, after 1Mb, as is also now customary. But beware that the Magei 4 installer cannot correctly align partitions on an SSD. Alignment can be done with the excellent parted program and its graphical extension GParted. The disk must then be connected to another PC or booted from the live CD that gparted contains before installation.

Optimize system settings for SSD

It is advisable to edit the fstab file and add the following parameters for the SSD: noatime,discard. For example, move the home directory that you want to back up regularly with snapshots to a separate subvolume and then add a parameter called subvolume to fstab:

UUID=195e609d-3daf-427c-a160-a86a1be464b9 /home btrfs subvol=HOME,noatime,discard 0 0
If the root directory, we want to have as subvolume also goes :-) . In addition to fstab, we also need to tell the loader that the root directory is on subvolume. We pass this information to the Grub boot loader in the boot configuration with the parameter:
rootflags=subvol=subvolume-name
As a result, we only have snapshots of each subvolume in the root directory.

To manually trigger the release of empty blocks on the SSD, the program fstrim, which selects empty blocks and then marks them as empty with the TRIM command.

fstrim -v /home
However, releasing blocks of deleted data is done selectively by the filesystem itself, especially if the partition is mounted with the discard parameter.

As a matter of course, even on computers with spinning disks, I take it for granted that the /tmp directory is in RAM. Those with SSD computers who have the /tmp directory on the disk should adjust their system configuration. Just add a line to /etc/fstab:

none /tmp tmpfs defaults 0 0

Praxis

If you follow these guidelines, the drive will give you high performance for a long time. Remember, however, that nothing is eternal and certain, so back up your valuable data! With SSDs, backing up is perhaps even more important.

An excellent source of information on using SSDs Mageia howto - SSD drive

Články na podobné téma

Industrial computer IPO ODYSSEE 18WT
Which mouse to choose for my computer?
Samsung S24H850 monitor
TUXEDO Pulse 15 - Gen2
How to connect a computer to a mobile phone running Android
Data backup
Computer with MSI B85-G43 motherboard and Intel Xeon E3 1226 processor
Using TouchBook in practice
Disassembled computer disk

Newsletter

If you are interested in receiving occasional news by email.
You can register by filling in your email news subscription.


+