Other languages Deutsch ; English ; Français ; Nederlands ; |
Contents
Introduction
SSD are very fast, silent and are becoming cheaper. So let's use them! The first generations of SSDs had a short lifetime because of increased wear under heavy write/read cycles. Modern SSD won't have this problem in most cases because the manufacturers make use of intelligent control mechanism in their SSD contollers. Also the Kernel support has improved over the last years to match the needs of modern SSD.
Please be aware that if you are using SSD from the first generations or really cheap no-name products the above may not be completely correct.
Firmware
After purchasing and before using a new SSD it's worth checking that the firmware is up to date. Most manufacturers provide tools to update their firmware and since this is a rapidly evolving technology, important updates may already be available for your new drive.
Partitions alignment
Simple test
Until now, partitioning tools were optimized to create partitions in a hard disk with disks, cylinders and heads. On SSDs those no longer exist. Optimizing partitions mean aligning them with the SSD clusters or memory cells. To check if your partitions are aligned with the memory cells try this command in a console with root rights:
(change sdx to your needed drive name, e.g sda, sdb, or nvme0, ...)
# /sbin/blockdev --getalignoff /dev/sdx |
The command outputs the offset of the queried partition, and if it returns a zero, it is perfectly aligned with the memory cells. Only if another number appears, the partition alignment does not match the SSD.
New partitioning
In most cases DrakDisk
, the Mageia partitioning tool, takes care about disk partitioning and will create aligned partitions. If you want to create your partitions (prior installation of Mageia) yourself, GParted is recommended. If you aren't an expert, Live GParted
is more simple (no mounted partitions) :
- Boot on the Live
GParted
CD, accept defaults settings and choose your language - In the main screen, select your disk (in the upper right corner) and click on
New partition
(first icon with a green +) - In the new dialog, check the field "Free space preceding (MiB)" is set to 2 MiB for the first partition on the SSD (place needed for the MBR). For the next partitions it must be set at 0.
- The field "Align to" must be on MiB.
- File system must be on ext4 (for EFI partition FAT32)
Partitioning already existing
Mageia is running and the partitions aren't aligned? It isn't a problem, GParted
can rectify the partitioning.
- Open "Partition Editor" in Live
GParted
- Select the misalligned partition, for example "/dev/sda1", and click on "Resize/Move"
- In the "Previous free space (MiB)" field, type "2", leave "Align to" set to "MiB", and click "Resize". Before the change is made, you need to confirm it and then trigger it by clicking "Apply"
- Once the operation is complete highlight "/dev/sda1" again, go to "Resize/Move" again and now set "Previous free space (MiB)" to "1". After confirming and applying the change, "/dev/sda1" is aligned
The trim command
The trim
command tells the SSD which cells can be erased during idle time, which also allows the drive to organize the remaining cells filled with data and the empty cells for writing to avoid delays when new data are written. Contrary to magnetic drives, flash cells data can not be overwritten, it must first be erased (which takes a relatively long time) and then written. Most manufactures use technologies in their SSD controllers so that you don't have to take care about this as end user. One part of that is extra "invisible" space so there is always room for writing.
The following chapters describes ways how to enable trim if needed or wanted.
Note: With modern big and fast drives, Trim give no noticeable speed advantage except in special cases. |
Note: Trim really erases data of deleted files, so programs for recovering deleted files can't help you! |
Note: Users of LVM, encrypted filesystems or "unusual" filesystems and setups should search the internet for more informations before using trim. Additional steps may be needed that can't be covered here. |
Using the trim command
There are different ways to enable or run trim
:
- adding the discard option in a configuration file (e.g.
/etc/fstab
) will enable trim permanent. It is no longer recommended to use the discard option in/etc/fstab
entries, as it slows down every file delete so this option is not described here! - use the Mageia built in fstrim.timer
- run
fstrim
in a console manually
fstrim.timer
Since several versions systemd manages the trim
command via a timer. In Mageia the timer is set to run the command once a week for all SSD, but is not set to enabled by default.
- Activating the timer.
# systemctl enable fstrim.timer |
- Start timer.
# systemctl start fstrim.timer |
- Make sure the timer is active:
# systemctl status fstrim.timer |
The term "active" appears after this command.
Finally, these stages can be reduced to a single command to activate and launch the timer:
# systemctl enable --now fstrim.timer |
Run fstrim command manually
To launch a trim manually, use the fstrim <filesystem mount point>
command in a console with root rights, for example:
# fstrim /home |
The filesystem must be mounted.