SparkyLinux Forums

Software & hardware support => Hardware => Topic started by: xendistar on September 08, 2019, 10:42:25 AM

Title: Considering SSD on laptop with sparky
Post by: xendistar on September 08, 2019, 10:42:25 AM

I am considering swapping out the old spinney hard disk and replacing it with a SSD. I keep seeing things about (running) TRIM with an SSD, if that still relevant for today's SSD's or have the SSD got better at managing there own file management and TRIM is no longer required?
Title: Re: Considering SSD on laptop with sparky
Post by: lami07 on September 08, 2019, 02:59:57 PM
Oversimplified answer for you question is '' forget about TRIM and enjoy your life''.  Just keep atleast 20% free space on partitions and built-in logic will do the rest.
Title: Re: Considering SSD on laptop with sparky
Post by: Bill Statler on September 09, 2019, 08:29:09 PM
I have an older SSD (Samsung 850 EVO 500GB purchased in 2015).  I don't know how things stand in 2019, but in case it's useful to someone, I'll list all the SSD-related things I did whan I installed Sparky 5 on this machine a year ago.  (I recommend backing up your drive before you try any of this!)


TRIM:

Verify that TRIM is supported:
sudo hdparm -I /dev/sda | grep TRIM
(Replace /dev/sda with wherever your SSD is.)
This should return a line of info about TRIM, something like:
Data Set Management TRIM supported (limit 8 blocks)

Run TRIM manually to make sure it works without errors:
sudo fstrim -a

Set up an automatic weekly run of fstrim -a:
1. Edit or create /etc/systemd/system/fstrim.service and add the following:
[Unit]
Description=Discard unused blocks

[Service]
Type=oneshot
ExecStart=/sbin/fstrim -a

2. Edit or create /etc/systemd/system/fstrim.timer and add the following:
[Unit]
Description=Discard unused blocks once a week
Documentation=man:fstrim

[Timer]
OnCalendar=weekly
AccuracySec=1h
Persistent=true

[Install]
WantedBy=multi-user.target

3. Enable it:
sudo systemctl enable fstrim.timer


/etc/fstab:

Add noatime to all the partitions on the SSD (unless you're running some rare program that actually uses the access time of files). This prevents an unnecessary write to the SSD every time a file is read.

You may want to delete discard (if it's present) from all partitions on the SSD.  (It's some sort of continuous TRIM and, as of 2015, it did not work well with Samsung SSDs.  I don't know whether this is still true in 2019, but in any case, if you've set up TRIM as above, you shouldn't need discard.)


swappiness:

Check current swappiness (a parameter that determines how often the swap partition gets used):
cat /proc/sys/vm/swappiness
Typically this will be 60.

Create or edit /etc/sysctl.d/local.conf and add:
# Local system settings

# Sharply reduce the inclination to swap
vm.swappiness=1



I/O scheduler:

There's lots of argument about which scheduler is best for an SSD, and it depends somewhat on how you're using the drive, but any of the following ought to be fine:
mq-deadline
cfq
deadline

Don't use bfq because it will be slow.

To see your current I/O scheduler:
cat /sys/block/sda/queue/scheduler
(Replace sda with wherever your SSD is.)
This will return a list of available choices, with [square brackets] indicating the current selection, e.g.:
[mq-deadline] kyber none

I've never needed to change this value, so I can't tell you how to do it!