You are not logged in.

#1 2016-04-28 18:45:02

marmistrz
Member
Registered: 2016-01-05
Posts: 129

Periodic fstrim doesn't work as expected

I've just run

sudo fstrim -v -all

it said that about 40 GB has been trimmed. On the other hand, the journal says fstrim did run 3 days ago:

kwi 25 09:36:42 arch systemd[1]: Starting Discard unused blocks...
kwi 25 09:36:46 arch systemd[1]: Started Discard unused blocks.

What's going on in here?

Offline

#2 2016-04-28 19:07:27

TheChickenMan
Member
From: United States
Registered: 2015-07-25
Posts: 354

Re: Periodic fstrim doesn't work as expected

Fstrim always shows that it trimmed the entire size of the disk's free space. I do not know why but this seems to be the output of the command. Maybe it simply zeros all of the free space on the disk when run?


If quantum mechanics hasn't profoundly shocked you, you haven't understood it yet.
Niels Bohr

Offline

#3 2016-04-28 19:08:34

marmistrz
Member
Registered: 2016-01-05
Posts: 129

Re: Periodic fstrim doesn't work as expected

I ran fstrim once again now, and now "only" 644.6 MB trimmed.

Offline

#4 2016-04-28 19:35:31

TheChickenMan
Member
From: United States
Registered: 2015-07-25
Posts: 354

Re: Periodic fstrim doesn't work as expected

marmistrz wrote:

I ran fstrim once again now, and now "only" 644.6 MB trimmed.

Did you reboot first? I bet if you rebooted and ran it again it would say 40GB.


If quantum mechanics hasn't profoundly shocked you, you haven't understood it yet.
Niels Bohr

Offline

#5 2016-05-01 10:02:25

marmistrz
Member
Registered: 2016-01-05
Posts: 129

Re: Periodic fstrim doesn't work as expected

Well, after a reboot it's something like this.

And does the periodic fstrim trim ALL disks available, or only the mounted ones?

Offline

#6 2016-05-01 10:08:58

frostschutz
Member
Registered: 2013-11-15
Posts: 1,658

Re: Periodic fstrim doesn't work as expected

The -a, --all option will affect all filesystems that are currently mounted.

The amount of data trimmed, as reported by fstrim, depends entirely on the filesystem. Some filesystems remember what they have trimmed before and do not trim it again. Other filesystems always trim the entire free space regardless whether it has been trimmed before. So the values reported can be very different depending on which filesystems you are using, so you should not put too much weight on this message. As long as it does not report an error it should be okay either way.

Online

#7 2016-05-01 10:09:59

marmistrz
Member
Registered: 2016-01-05
Posts: 129

Re: Periodic fstrim doesn't work as expected

Thanks. And is it possible to periodically fstrim all filesystems on the device, not only the ones mounted on boot? And is the swap fstrimmed?

Last edited by marmistrz (2016-05-01 10:10:13)

Offline

#8 2016-05-01 14:28:40

onslow77
Member
Registered: 2014-09-21
Posts: 283

Re: Periodic fstrim doesn't work as expected

marmistrz wrote:

Thanks. And is it possible to periodically fstrim all filesystems on the device, not only the ones mounted on boot? And is the swap fstrimmed?

Hello!

marmistrz - you find answer to the above questions here:
- Arch Wiki: Solid State Drives, section about TRIM
- The "fstrim" manual

 man fstrim 

Regards
Martin

Last edited by onslow77 (2016-05-01 14:31:16)

Offline

#9 2016-05-01 14:39:08

frostschutz
Member
Registered: 2013-11-15
Posts: 1,658

Re: Periodic fstrim doesn't work as expected

fstrim can only operate on mounted filesystems. What filesystems do you have that are not mounted? For fstrim you'll have to mount them in any case...

swap may be trimmed entirely every time you boot (if you have an fstab entry for swap, discard=once as options) - I think this is enabled by default anyhow.

Online

#10 2016-05-01 15:51:02

TheChickenMan
Member
From: United States
Registered: 2015-07-25
Posts: 354

Re: Periodic fstrim doesn't work as expected

frostschutz wrote:

fstrim can only operate on mounted filesystems. What filesystems do you have that are not mounted? For fstrim you'll have to mount them in any case...

swap may be trimmed entirely every time you boot (if you have an fstab entry for swap, discard=once as options) - I think this is enabled by default anyhow.

Is this better than having just 'discard' as a mount option on your swap? I hadn't seen anything about the =once before in documentation.


If quantum mechanics hasn't profoundly shocked you, you haven't understood it yet.
Niels Bohr

Offline

#11 2016-05-01 16:12:40

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: Periodic fstrim doesn't work as expected

See 'man swapon'.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

Board footer

Powered by FluxBB