You are not logged in.

#1 2019-04-23 22:06:45

JimDeadlock
Member
From: London
Registered: 2019-03-20
Posts: 83

[SOLVED] Should I TRIM M.2 RAID0?

I have a pair of Samsung 970 EVO Plus 1 TB NVMe M.2 SSD drives in software RAID0 which I set up with mdadm. I've been googling to see if I can (or should) run TRIM on this or not, but the information is sparse and mostly very dated, and there's no mention of TRIM in the mdadm manpages either. My gut feeling is that since I'm likely to have tons of free space for the foreseeable future I'll just leave it alone and not bother with TRIM at all. Thoughts?

Last edited by JimDeadlock (2019-05-22 13:48:42)

Offline

#2 2019-04-24 07:55:26

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,567

Re: [SOLVED] Should I TRIM M.2 RAID0?

It seems periodic TRIM is the preferred option in Linux.

Offline

#3 2019-04-24 09:18:10

JimDeadlock
Member
From: London
Registered: 2019-03-20
Posts: 83

Re: [SOLVED] Should I TRIM M.2 RAID0?

Yes but this is a RAID0 array, I'm not sure how mdadm handles it or if it might mess with the RAID setup. I've also read an article that says TRIM is no longer necessary with modern SSDs, especially if you have plenty of free space on the drive.

Offline

#4 2019-04-24 13:17:12

Ropid
Member
Registered: 2015-03-09
Posts: 1,069

Re: [SOLVED] Should I TRIM M.2 RAID0?

All involved modules should correctly wire things through to your two drives and TRIM should work.

What you hear about "TRIM is no longer necessary" is probably a misunderstanding because of news articles intended for Windows users. When SSD's first came out, people had to do special work to make sure that TRIM worked. Today Windows users don't have to think about it, it'll be working with the default Windows drivers. Windows has both something like the "discard" mount option of Linux and it also has something like the weekly "fstrim" systemd timer. That's then perhaps where the idea that it's no longer necessary came from.

Thinking about what "free space" means is a bit confusing because what's free in the filesystem is not the same as what the SSD's controller thinks is free... unless you use TRIM. TRIM does help with all SSDs. Without it, after you've used the filesystem long enough it will have touched each sector of the visible drive once and the SSD's controller will think the drive is 100% full.

The SSD's controller always needs a bunch of free space available because it can't actually overwrite data in the drive's chips. It always has to create a copy of the data when "overwriting". It then later does an expensive operation to get rid of the old copy and get that space back. To make this whole thing always work, the real drive is larger than the visible drive. The invisible extra space of the drive is not large enough to keep the performance at normal when the drive is full. This is the case with the more expensive consumer drives, not just with the cheapest drives, so you still need TRIM.

Something you can do if you do not want to use TRIM is, you can leave a bunch of space left over when creating your partitions. This then makes sure that the filesystems will never touch that area of the drive. In benchmarks, it seems the good drives will reach their full performance at about 20% free space. To make this empty space partitioning idea work like intended, you would ideally do this by first wiping the drive with 'blkdiscard'. Alternatively you could also create a partition for that 20% space, then run the "blkdiscard" command on that partition, then delete the partition.

Last edited by Ropid (2019-04-24 13:23:33)

Offline

#5 2019-04-24 14:08:22

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

Re: [SOLVED] Should I TRIM M.2 RAID0?

TRIM is, strictly speaking, not necessary. If you never TRIM, the SSD would probably be a little slower when writing (significant amounts of data). There would also be more write activity in general (write amplification reducing SSD lifetime writes).

TRIM is a remnant of when SSD were prohibitively expensive and suspected of a very short lifetime. Prices have dropped and SSD endurance tests have shown that lifetime is usually much better than expected.

So in regular desktop use scenario, it doesn't really matter if you use TRIM or not. Most people don't know/care and would never notice any difference either way because there likely is none.

TRIM also carries risks - TRIM discards data after all, so you can't photorec deleted files after TRIM. On a regular hard drive you are sometimes lucky to find years-old deleted stuff, on SSD with TRIM that'll never happen, deleted data is really gone. Whether that is a good or bad thing depends...

In theory it's also possible for TRIM to corrupt data ( if not implemented correctly - and such bugs happen - https://www.spinics.net/lists/raid/msg49440.html ).

Unfortunately trim is everywhere (if you mkfs, you already used it...) so very difficult to avoid if you don't want it.

Some time ago I summarized my view on discard/fstrim over here https://unix.stackexchange.com/a/218083/30851

Offline

Board footer

Powered by FluxBB