You are not logged in.

#1 2020-03-27 19:12:08

archdom
Member
Registered: 2018-09-12
Posts: 96

[SOLVED]Fstrim 'Lvm on luks'

Hi guys,
below my partitions table:

NAME           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
nvme0n1        259:0    0   477G  0 disk  
├─nvme0n1p1    259:1    0   650M  0 part  /boot
├─nvme0n1p2    259:2    0   128M  0 part  
├─nvme0n1p3    259:3    0   150G  0 part  
└─nvme0n1p4    259:4    0 326,2G  0 part  
  └─cryptlvm   254:0    0 326,2G  0 crypt 
    ├─vg0-swap 254:1    0     8G  0 lvm   [SWAP]
    ├─vg0-root 254:2    0    70G  0 lvm   /
    └─vg0-home 254:3    0   150G  0 lvm   /home

fstab

# /dev/mapper/vg0-root
UUID=61228216-105c-436a-9420-bea870fd0eb2	/         	ext4      	rw,relatime	0 1

# /dev/mapper/vg0-home
UUID=1718d48a-00f5-401b-af73-02ea21c5d74c	/home     	ext4      	rw,relatime	0 2

# /dev/nvme0n1p1 LABEL=ESP
UUID=8652-2079      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro	0 2

# /dev/mapper/vg0-swap
UUID=5cef1695-3ea1-4628-b0dd-a5fb41be16f7	none      	swap      	defaults,discard  	0 0

fstrim.service

# /usr/lib/systemd/system/fstrim.service
[Unit]
Description=Discard unused blocks on filesystems from /etc/fstab
Documentation=man:fstrim(8)
ConditionVirtualization=!container

[Service]
Type=oneshot
ExecStart=/usr/bin/fstrim --fstab --verbose --quiet
ProtectSystem=strict
ProtectHome=read-only
PrivateDevices=no
PrivateNetwork=yes
PrivateUsers=no
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
MemoryDenyWriteExecute=yes
SystemCallFilter=@default @file-system @basic-io @system-service

If I manually execute the command set on the property "ExecStart=/usr/bin/fstrim --fstab --verbose --quiet"
on the command line, I get:

/boot: 476 MiB (499064832 bytes) trimmed on /dev /nvme0n1p1
/home: 136 GiB (146067415040 bytes) trimmed on /dev/mapper/vg0-home
/: 59 GiB (63310139392 bytes) trimmed on /dev/mapper/vg0-root

If I run the same command but from the service via command "systemctl start fstrim.service"
in the journal I see this:

Tue 27 19:49:25 Arch systemd [1]: Starting Discard unused blocks on filesystems from /etc/fstab ...
Tue 27 19:49:25 Arch systemd [1]: fstrim.service: Succeeded.
Tue 27 19:49:25 Arch systemd [1]: Finished Discard unused blocks on filesystems from /etc/fstab.

I don't undestand if has trimmed something.
I expect see in the journal a output as :

Tue 27 19:49:25 Arch systemd [1]: Starting Discard unused blocks on filesystems from /etc/fstab ...
Tue 27 19:49:25 Arch systemd [1]: /boot: 476 MiB (499064832 bytes) trimmed on /dev /nvme0n1p1
Tue 27 19:49:25 Arch systemd [1]: /home: 136 GiB (146067415040 bytes) trimmed on /dev/mapper/vg0-home
Tue 27 19:49:25 Arch systemd [1]: /: 59 GiB (63310139392 bytes) trimmed on /dev/mapper/vg0-root
Tue 27 19:49:25 Arch systemd [1]: fstrim.service: Succeeded.
Tue 27 19:49:25 Arch systemd [1]: Finished Discard unused blocks on filesystems from /etc/fstab.

Why doesn't it discard?
regards

Last edited by archdom (2020-03-28 18:43:33)

Offline

#2 2020-03-28 18:43:08

archdom
Member
Registered: 2018-09-12
Posts: 96

Re: [SOLVED]Fstrim 'Lvm on luks'

I resolved by commenting in fstrim.service the below lines:

#ProtectSystem=strict
#ProtectHome=read-only

Mark as solved

Offline

#3 2020-03-29 06:19:11

Lupo Alberto
Member
From: Gomel, Belarus
Registered: 2013-11-25
Posts: 84

Re: [SOLVED]Fstrim 'Lvm on luks'

archdom wrote:

I resolved by commenting in fstrim.service the below lines:

#ProtectSystem=strict
#ProtectHome=read-only

Mark as solved

In next util-linux update you can lose this settings so do this changes with

 sudo systemctl edit fstrim.service

by editing /etc/systemd/system/fstrim.service.d/override.conf

[Service]
ProtectSystem=no
ProtectHome=no

P.S. I doubt. Can someone explain to me right way of using PermitSystem option?

Last edited by Lupo Alberto (2020-03-29 06:22:06)

Offline

#4 2020-04-11 18:43:45

archdom
Member
Registered: 2018-09-12
Posts: 96

Re: [SOLVED]Fstrim 'Lvm on luks'

Lupo Alberto wrote:
archdom wrote:

I resolved by commenting in fstrim.service the below lines:

#ProtectSystem=strict
#ProtectHome=read-only

Mark as solved

In next util-linux update you can lose this settings so do this changes with

 sudo systemctl edit fstrim.service

by editing /etc/systemd/system/fstrim.service.d/override.conf

[Service]
ProtectSystem=no
ProtectHome=no

P.S. I doubt. Can someone explain to me right way of using PermitSystem option?

Thank you for advice. wink

Offline

Board footer

Powered by FluxBB