Optimize SSD on Linux

After installing the SSD on your laptop, there are some adjustments that need to be done so that it is optimal. I'm using Fedora 30


File system

My Partition is:

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 860
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: DF4E716F-F00A-40F3-8176-C97A52F36998

Device      Start       End   Sectors   Size Type
/dev/sda1    2048    253951    251904   123M EFI System
/dev/sda2  253952 976773119 976519168 465.7G Linux LVM


And logical volume are: Root, Home, Archive, VM, Games

Format as ext4 with default block size (4096 best for SSD), and set reserved block to 1%

# mkfs.ext4 -L Home -m 1 /dev/VG/YourHome


Copying

I did not reinstall linux but only made partitions and copied files from the old disk.
Hard links and sparse files may cause disk usage larger on target, use -S and -H. And for ACL and extended attributes use option -A -X

# rsync -avAXSHx /source /target


Grub config

Mount EFI and update grub config:

# mount /dev/sdb1 /mnt/boot/efi
# grub2-mkconfig -o /mnt/boot/efi/EFI/fedora/grub.cfg

Update grub config and initramfs again after you successfully boot using new disk

Disable swap

Edit /etc/fstab and remark line contains swap

# swapoff -a

Enable zram swap

# dnf install zram
# systemctl enable zram-swap.service

Edit /etc/zram.conf to tune up, i use this setting to avoid thrashing:

FACTOR=10

# reboot

Set vm swappiness

# vim /etc/sysctl.d/80-custom.conf
vm.swappiness = 1

# sysctl -p /etc/sysctl.d/80-custom.conf

Edit mount option in fstab

add to / and /home mount option: noatime but don't add discard

Use tmpfs

Fedora use tmpfs by default, to check: mount | grep tmpfs



Use weekly trim

# systemctl enable fstrim.timer


LVM


Set "issue_discards" option in /etc/lvm/lvm.conf for LVM if you want LVM to discard on lvremove

Change io scheduler


I use tlp, so I edit /etc/default/tlp

DISK_IOSCHED="deadline deadline"


Dirty page values


Also edit in tlp setting:

MAX_LOST_WORK_SECS_ON_AC=600
MAX_LOST_WORK_SECS_ON_BAT=600



Disable coredump


Edit /etc/systemd/coredump.conf

[Coredump]
Storage=none


Firefox config

Open URL about:config
Then Accept the Risk

Change sessionstore.interval to 1500000

 

Update, this really lower disk writes:

dnf install profile-sync-daemon

As user run:

psd p

#edit config if necessary  

systemctl --user start psd

systemctl --user enable psd



Chrome cache


...

Virtual Machine

Use qcow2 image, SCSI disk, virtio-scsi controller and enable TRIM


MISC


Find remaining life

# sudo smartctl -a /dev/sda

Find Remaining_Lifetime_Perc or Media_Wearout_Indicator or Wear_Leveling_Count

Find out which process write too much


# sudo iotop -aP

Press left cursor twice to sort Disk Write

Or using gnome system monitor:





Samsung DC Tool


Download Samsung DC Toolkit for Linux from here


# sudo ./Samsung_SSD_DC_Toolkit_for_Linux_V2.1 -L
================================================================================================
Samsung DC Toolkit Version 2.1.L.Q.0
Copyright (C) 2017 SAMSUNG Electronics Co. Ltd. All rights reserved.
================================================================================================
Bad argument "name", expected an absolute path in /dev/ or /sys or a unit name: Invalid argument
----------------------------------------------------------------------------------------------------------------------------------------
| Disk   | Path     | Model                     | Serial          | Firmware | Optionrom | Capacity | Drive  | Total Bytes | NVMe Driver |
| Number |          |                           | Number          |          | Version   |          | Health | Written     |             |
----------------------------------------------------------------------------------------------------------------------------------------
| *0     | /dev/sda | Samsung SSD 860 EVO 500GB | 012345678901234 | RVT03B6Q | N/A       |   465 GB | GOOD   | 0.17 TB     | N/A         |
----------------------------------------------------------------------------------------------------------------------------------------





Comments

Jared Chu said…
Nice post bro!

Popular posts from this blog

Ports to allow for whatsapp call

Manually clean up zimbra zmcat/zmcpustat exploit

Keychron K2 in Linux