fstrim with Buster

If none of the more specific forums is the right place to ask
Message
Author
User avatar
kalle123
Posts: 253
Joined: 2015-03-21 11:17
Location: Rhineland - Germany

fstrim with Buster

#1 Post by kalle123 »

On https://wiki.debian.org/SSDOptimization I find this note
Enable weekly trim (not needed on buster)
But on a test installation of Buster on a 120 GB SSD I don't see fstrim active.

Found no further info ....

User avatar
Head_on_a_Stick
Posts: 13760
Joined: 2014-06-01 17:46
Location: /dev/chair
Has thanked: 8 times
Been thanked: 47 times

Re: fstrim with Buster

#2 Post by Head_on_a_Stick »

Code: Select all

# apt install util-linux
# systemctl enable --now fstrim.timer
systemctl list-timers
"It seems that UNIX has become the victim of cancerous growth at the hands of organizations such as UCB. 4.2BSD is an order of magnitude larger than Version 5, but, Pike claims, not ten times better."

— Murray Hill, Bell Laboratories

User avatar
kalle123
Posts: 253
Joined: 2015-03-21 11:17
Location: Rhineland - Germany

Re: fstrim with Buster

#3 Post by kalle123 »

@Head_on_a_Stick, thank you

But that is contrary to what that wiki article says

Enable weekly trim (not needed on buster) :roll:

User avatar
Head_on_a_Stick
Posts: 13760
Joined: 2014-06-01 17:46
Location: /dev/chair
Has thanked: 8 times
Been thanked: 47 times

Re: fstrim with Buster

#4 Post by Head_on_a_Stick »

kalle123 wrote:But that is contrary to what that wiki article says
That wiki page is full of dubious advice. For example, there hasn't been any need to reduce writes to the SSD for a while now because drive longevity is greatly improved compared to the early production models.
"It seems that UNIX has become the victim of cancerous growth at the hands of organizations such as UCB. 4.2BSD is an order of magnitude larger than Version 5, but, Pike claims, not ten times better."

— Murray Hill, Bell Laboratories

User avatar
kalle123
Posts: 253
Joined: 2015-03-21 11:17
Location: Rhineland - Germany

Re: fstrim with Buster

#5 Post by kalle123 »

Head_on_a_Stick wrote:
kalle123 wrote:But that is contrary to what that wiki article says
That wiki page is full of dubious advice. For example, there hasn't been any need to reduce writes to the SSD for a while now because drive longevity is greatly improved compared to the early production models.
Not only that page. Same, when you start looking for advice on the sources.list on Buster.

Different wiki pages give different information ....

User avatar
Head_on_a_Stick
Posts: 13760
Joined: 2014-06-01 17:46
Location: /dev/chair
Has thanked: 8 times
Been thanked: 47 times

Re: fstrim with Buster

#6 Post by Head_on_a_Stick »

kalle123 wrote:Different wiki pages give different information
Yes, that can be a problem with public wiki resources, I grew bored of fighting with the ArchWiki maintainers some time ago but the same problem exists there as well.

FWIW, just treat the SSD as if it were a spinning rust drive, they don't need any special treatment.
"It seems that UNIX has become the victim of cancerous growth at the hands of organizations such as UCB. 4.2BSD is an order of magnitude larger than Version 5, but, Pike claims, not ten times better."

— Murray Hill, Bell Laboratories

p.H
Posts: 2568
Joined: 2017-09-17 07:12
Has thanked: 3 times
Been thanked: 53 times

Re: fstrim with Buster

#7 Post by p.H »

Head_on_a_Stick wrote:FWIW, just treat the SSD as if it were a spinning rust drive, they don't need any special treatment.
What about TRIM, defragmentation and proper alignment ?

User avatar
Head_on_a_Stick
Posts: 13760
Joined: 2014-06-01 17:46
Location: /dev/chair
Has thanked: 8 times
Been thanked: 47 times

Re: fstrim with Buster

#8 Post by Head_on_a_Stick »

p.H wrote:What about TRIM
I think fstrim.timer should be sufficient, check fstrim(8) for more on this.
p.H wrote:defragmentation
Isn't fragmentation a spinning rust "feature"?

I don't think defragmentation is needed for an SSD, am I wrong?
p.H wrote:proper alignment
Don't most disk partitioning utilities align to the 4K standard automatically?
"It seems that UNIX has become the victim of cancerous growth at the hands of organizations such as UCB. 4.2BSD is an order of magnitude larger than Version 5, but, Pike claims, not ten times better."

— Murray Hill, Bell Laboratories

User avatar
kalle123
Posts: 253
Joined: 2015-03-21 11:17
Location: Rhineland - Germany

Re: fstrim with Buster

#9 Post by kalle123 »

I do these steps with an SSD.

(Did it with Buster, from my notes ...)

- CHECK alignment

Code: Select all

$ sudo parted /dev/sda align-check opt

Partitionnumber? 1                                                       
1 aligned
- ADD noatime

Code: Select all

- Add the "noatime"

(or "relatime") mount option in /etc/fstab, to disable (or significantly reduce) disk writes whenever a file is read. 
- ENABLE weekly trim

Code: Select all

$ sudo cp /usr/share/doc/util-linux/examples/fstrim.{service,timer} /etc/systemd/system

$ sudo systemctl enable fstrim.timer
- CHECKING trim

Code: Select all

$ systemctl status fstrim.timer

View fstrim.timer status:

$ systemctl status fstrim.timer
● fstrim.timer - Discard unused blocks once a week
   Loaded: loaded (/lib/systemd/system/fstrim.timer; enabled; vendor preset: enabled)
   Active: active (waiting) since Thu 2018-07-05 05:45:11 BST; 4h 42min ago
  Trigger: Mon 2018-07-09 00:00:00 BST; 3 days left
     Docs: man:fstrim
Start/Stop/Restart fstrim.timer:
(immediate activate/deactivate/reactivate, does not change startup status)


$ sudo systemctl [start/stop/restart] fstrim.timer
Enable/Disable fstrim.timer:
(add to/remove from startup, does not change immediate active status)

$ sudo systemctl [enable/disable] fstrim.timer
View fstrim.timer configuration:

$ systemctl cat fstrim.timer
# /lib/systemd/system/fstrim.timer
[Unit]
Description=Discard unused blocks once a week
Documentation=man:fstrim

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

[Install]
WantedBy=timers.target
View fstrim.service configuration:

$ systemctl cat fstrim.service
# /lib/systemd/system/fstrim.service
[Unit]
Description=Discard unused blocks

[Service]
Type=oneshot
ExecStart=/sbin/fstrim -av
View related systemd journal entries: 

$ journalctl -u fstrim.timer
Jul 04 14:18:41 user-laptop systemd[1]: Started Discard unused blocks once a week.
Jul 04 21:59:26 user-laptop systemd[1]: Stopped Discard unused blocks once a week.
etc...

$ journalctl -u fstrim.service
Jun 25 10:59:44 user-laptop systemd[1]: Starting Discard unused blocks...
Jun 25 10:59:48 user-laptop fstrim[955]: /: 92.5 GiB (99335237632 bytes) trimmed
Jun 25 10:59:48 user-laptop systemd[1]: Started Discard unused blocks.
-- Reboot --
Jul 02 04:27:41 user-laptop systemd[1]: Starting Discard unused blocks...
Jul 02 04:27:46 user-laptop fstrim[1032]: /: 92.3 GiB (99150807040 bytes) trimmed
Jul 02 04:27:46 user-laptop systemd[1]: Started Discard unused blocks.
etc...
- CHECK Low-Latency IO-Scheduler

Code: Select all

$ grep . /sys/block/sd?/queue/rotational

/sys/block/sda/queue/rotational:1
/sys/block/sdb/queue/rotational:1
/sys/block/sdc/queue/rotational:0   <=== Only this is SSD!
- CHANGE Low-Latency IO-Scheduler

Code: Select all

# echo deadline > /sys/block/$YOURDRIVE/queue/scheduler
- TEST Low-Latency IO-Scheduler

Code: Select all

$ grep . /sys/block/sd?/queue/scheduler
/sys/block/sda/queue/scheduler:noop deadline [cfq]
/sys/block/sdb/queue/scheduler:noop deadline [cfq]
/sys/block/sdc/queue/scheduler:noop [deadline] cfq  <== That is!

User avatar
Head_on_a_Stick
Posts: 13760
Joined: 2014-06-01 17:46
Location: /dev/chair
Has thanked: 8 times
Been thanked: 47 times

Re: fstrim with Buster

#10 Post by Head_on_a_Stick »

kalle123 wrote:- Add the "noatime"
^ Absolutely not needed, relatime has been the default for ext4 since kernel 2.6.30 and that should be sufficient, even if excess writes were a concern (which they're not with any modern production SSD[1]).

Also, noatime breaks mutt, which is sad.

[1] https://techreport.com/review/27909/the ... e-all-dead ← that's from 2015, I think the drives have improved since then.
"It seems that UNIX has become the victim of cancerous growth at the hands of organizations such as UCB. 4.2BSD is an order of magnitude larger than Version 5, but, Pike claims, not ten times better."

— Murray Hill, Bell Laboratories

User avatar
kalle123
Posts: 253
Joined: 2015-03-21 11:17
Location: Rhineland - Germany

Re: fstrim with Buster

#11 Post by kalle123 »

:wink:

The rest is ok?

User avatar
bw123
Posts: 3936
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 9 times

Re: fstrim with Buster

#12 Post by bw123 »

kalle123 wrote:On https://wiki.debian.org/SSDOptimization I find this note
Enable weekly trim (not needed on buster)
But on a test installation of Buster on a 120 GB SSD I don't see fstrim active.

Found no further info ....
The wiki might be referring to the fact that fstrim.timer does not have to be copied manually from /usr/share/doc/util-linux/examples

starting with buster.
https://packages.debian.org/search?suit ... trim.timer

Did you check the documentation mentioned in the changelog?
https://metadata.ftp-master.debian.org/ ... _changelog
util-linux (2.32.1-0.2) unstable; urgency=medium
... * debian/util-linux.README.Debian: Add information about the fstrim.timer

User avatar
Head_on_a_Stick
Posts: 13760
Joined: 2014-06-01 17:46
Location: /dev/chair
Has thanked: 8 times
Been thanked: 47 times

Re: fstrim with Buster

#13 Post by Head_on_a_Stick »

Try some benchmarks for the I/O schedulers, my buster system defaults to mq-deadline, which is well suited to SSDs (AFAIK).

Also, there is no need to copy fstrim.{timer,service}, my buster system has them in /lib/systemd/system so the .timer just needs to be enabled. There is no /usr/share/doc/util-linux/examples/fstrim.{service,timer} in buster, my guide with the copy command was for jessie & stretch.

EDIT: bw123 beat me to it :)
"It seems that UNIX has become the victim of cancerous growth at the hands of organizations such as UCB. 4.2BSD is an order of magnitude larger than Version 5, but, Pike claims, not ten times better."

— Murray Hill, Bell Laboratories

User avatar
bw123
Posts: 3936
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 9 times

Re: fstrim with Buster

#14 Post by bw123 »

I think there is an active IRC for debian wiki, if OP wants to help clear up the language. Documentation can always be improved.
maybe #debian-www ?

User avatar
kalle123
Posts: 253
Joined: 2015-03-21 11:17
Location: Rhineland - Germany

Re: fstrim with Buster

#15 Post by kalle123 »

bw123 wrote: The wiki might be referring to the fact that fstrim.timer does not have to be copied manually from /usr/share/doc/util-linux/examples
I read it the other way, but English is not my native language.

But I am glad we can discuss those settings and checks.

p.H
Posts: 2568
Joined: 2017-09-17 07:12
Has thanked: 3 times
Been thanked: 53 times

Re: fstrim with Buster

#16 Post by p.H »

Head_on_a_Stick wrote:I think fstrim.timer should be sufficient
IIUC your message #2, fstrim.timer is not enabled by default.
Head_on_a_Stick wrote:Isn't fragmentation a spinning rust "feature"?
Fragmentation is a filesystem feature and also exists on SSDs (and any other kind of random access storage). It just has a lower impact on performance thanks to the much lower access time.
Head_on_a_Stick wrote:I don't think defragmentation is needed for an SSD, am I wrong?
No. Worse, it is undesirable because it causes extra workload and writes for no benefit.
But you wrote "just treat the SSD as if it were a spinning rust drive". Doesn't it imply that if one defragments their hard disk, they should also defragment their SSD ?
Head_on_a_Stick wrote:Don't most disk partitioning utilities align to the 4K standard automatically?
Actually 1 MB. Any hard disk is fine with 4-KiB, but a SSD needs a bigger alignment size depending on its write page and erase block sizes. Watch out if you clone an old disk with cylinder aligment to an SSD.

p.H
Posts: 2568
Joined: 2017-09-17 07:12
Has thanked: 3 times
Been thanked: 53 times

Re: fstrim with Buster

#17 Post by p.H »

Head_on_a_Stick wrote:relatime has been the default for ext4 since kernel 2.6.30
According to the mount(8) man page, relatime is a filesystem-independant mount option and is the default for any filesystem type, not only ext4.

User avatar
Head_on_a_Stick
Posts: 13760
Joined: 2014-06-01 17:46
Location: /dev/chair
Has thanked: 8 times
Been thanked: 47 times

Re: fstrim with Buster

#18 Post by Head_on_a_Stick »

^ & ^^, thanks!
"It seems that UNIX has become the victim of cancerous growth at the hands of organizations such as UCB. 4.2BSD is an order of magnitude larger than Version 5, but, Pike claims, not ten times better."

— Murray Hill, Bell Laboratories

User avatar
kalle123
Posts: 253
Joined: 2015-03-21 11:17
Location: Rhineland - Germany

Re: fstrim with Buster

#19 Post by kalle123 »

kalle123 wrote: - ENABLE weekly trim

Code: Select all

$ sudo systemctl enable fstrim.timer
- CHECKING trim

Code: Select all

$ systemctl status fstrim.timer

View fstrim.timer status:

$ systemctl status fstrim.timer
● fstrim.timer - Discard unused blocks once a week
   Loaded: loaded (/lib/systemd/system/fstrim.timer; enabled; vendor preset: enabled)
   Active: active (waiting) since Thu 2018-07-05 05:45:11 BST; 4h 42min ago
  Trigger: Mon 2018-07-09 00:00:00 BST; 3 days left
     Docs: man:fstrim
Start/Stop/Restart fstrim.timer:
(immediate activate/deactivate/reactivate, does not change startup status)


$ sudo systemctl [start/stop/restart] fstrim.timer
Enable/Disable fstrim.timer:
(add to/remove from startup, does not change immediate active status)

$ sudo systemctl [enable/disable] fstrim.timer
View fstrim.timer configuration:

$ systemctl cat fstrim.timer
# /lib/systemd/system/fstrim.timer
[Unit]
Description=Discard unused blocks once a week
Documentation=man:fstrim

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

[Install]
WantedBy=timers.target
View fstrim.service configuration:

$ systemctl cat fstrim.service
# /lib/systemd/system/fstrim.service
[Unit]
Description=Discard unused blocks

[Service]
Type=oneshot
ExecStart=/sbin/fstrim -av
View related systemd journal entries: 

$ journalctl -u fstrim.timer
Jul 04 14:18:41 user-laptop systemd[1]: Started Discard unused blocks once a week.
Jul 04 21:59:26 user-laptop systemd[1]: Stopped Discard unused blocks once a week.
etc...

$ journalctl -u fstrim.service
Jun 25 10:59:44 user-laptop systemd[1]: Starting Discard unused blocks...
Jun 25 10:59:48 user-laptop fstrim[955]: /: 92.5 GiB (99335237632 bytes) trimmed
Jun 25 10:59:48 user-laptop systemd[1]: Started Discard unused blocks.
-- Reboot --
Jul 02 04:27:41 user-laptop systemd[1]: Starting Discard unused blocks...
Jul 02 04:27:46 user-laptop fstrim[1032]: /: 92.3 GiB (99150807040 bytes) trimmed
Jul 02 04:27:46 user-laptop systemd[1]: Started Discard unused blocks.
etc...
That reduces my list a bit on Buster :D

I checked Low-Latency IO-Scheduler with 3 SSDs and 1 "spinning rust" here

Code: Select all

~$ grep . /sys/block/sd?/queue/rotational
/sys/block/sda/queue/rotational:0
/sys/block/sdb/queue/rotational:1
/sys/block/sdc/queue/rotational:0
/sys/block/sdd/queue/rotational:0

Code: Select all

$ grep . /sys/block/sd?/queue/scheduler
/sys/block/sda/queue/scheduler:[mq-deadline] none
/sys/block/sdb/queue/scheduler:[mq-deadline] none
/sys/block/sdc/queue/scheduler:[mq-deadline] none
/sys/block/sdd/queue/scheduler:[mq-deadline] none
No need to do settings there .....

shep
Posts: 423
Joined: 2011-03-15 15:22

Re: fstrim with Buster

#20 Post by shep »

I just installed Buster AMD64 to an HP Stream 14. This is my 1st exposure to emmc memory and a quick web search regarding fstrim/emmc did not really provide much guidance as to whether fstrim would be beneficial. Anybody know the answer?

Post Reply