The answer by Drink is excellent. But I'd like to help explain this further.
If you search for this topic on the internet, you'll find a huge heaping pile of "guides" (even recent ones) based on the old, misguided belief that you can somehow "tell the filesystem to align/stripe its data inside the SSD's erase block boundaries".
That's a very, very, very silly belief.
The fact is that SSDs place each sector wherever it feels like. Each erase block contains lots of sectors. The laymen who wrote those "guides" incorrectly thought SSDs place sectors sequentially (like hard disks do) within those erase blocks and that you therefore benefit by forcing the filesystem to place as much related data as possible in each physical erase block, to make future erase operations get rid of a whole file (therefore a whole erase block) at once, and that future file writes will replace the contents of the entire erase block in-place via a single "erase all of the sectors in this erase block, and then write all of the sectors in this erase block", without having to keep some sectors from the erase blocks and rewriting them elsewhere. Basically, the idea of "stride/stripe" was to hint at the filesystem to group together related data within physical SSD erase blocks.
The idea sounds nice in theory. But that's not how SSDs work anymore.
That's really, really not how any of this works.
SSDs don't care about your "sequential sectors" and will write the data into any physical sector that is empty anywhere on the NAND flash chips.
When you tell a SSD to write to sector 1, it might place the data in physical sector 21349239. But it will pretend to the OS that it's in "sector 1". Furthermore, when your operating system tells the SSD to write sequential sectors (1, 2, 3, 4, ...), the SSD will spread the sectors across its NAND chips anywhere that there are individual empty sectors. It won't place them sequentially across "erase blocks" whatsoever!
That's because the SSD uses wear leveling algorithms to decide which physical sector ANYWHERE ON THE NAND FLASH CHIPS to place the given "virtual sector" in. It then stores a lookup table saying "virtual sector (what the OS thinks it is) = Stored at physical location X". So when you write a "sequential bunch of sectors" from your OS, your data ALWAYS ends up smattered randomly all over the entire SSD due to wear leveling.
Furthermore, whenever a sector dies (is worn out completely and can't reliably hold data anymore), the SSD will move it somewhere else on the flash and remap it too.
You simply cannot know where the SSD will place your sectors. It is NOT sequential whatsoever.
In 2009, back when these "stride" discussions were gaining traction, Ted Tso, one of the primary engineers of the Linux kernel filesystems (particularly ext4), wrote a blog post theorizing that all of this was pointless because the SSD places its data wherever it wants. Unfortunately not enough people listened to him. Here's his outdated blog post about the subject (don't follow any of its advice; it's all very outdated and all tools he's talking about have been updated to do MiB alignment these days): https://tytso.livejournal.com/2009/02/20/
The interesting thing about that blog post is that it tells us the origin for these misguided beliefs about "SSD erase block boundaries". Because it talks about very old, first-generation SSDs that DIDN'T do wear-leveling and DIDN'T map "virtual sectors (what the OS sees)" to random hardware sectors. In early SSDs, the sectors WERE truly sequential, which is why the stride/strip advice was born. Modern SSDs are way more advanced. And anyone following the old "stride/stripe" advice from misguided laymen will just be wasting their time.
The blog post further talked about Intel's SSDs at the time being more advanced and having a virtual sector remapping table but lacking TRIM. He said that this virtual remapping was already on the verge of killing the need for stride/stripe. And he then theorized (correctly) that if TRIM is implemented, there will be ZERO need for "aligning along erase blocks" anymore.
And that's where we are TODAY, with modern SSDs.
Modern SSDs use virtual remapping (sectors are NOT contiguous/sequential on the hardware), and they use TRIM to free up sectors. So there's ZERO BENEFIT to trying to align to "erase blocks" because there is NO SUCH THING on the hardware anymore. As I said, the sectors you write from your OS will end up randomly all over the disk on modern wear-leveling SSDs.
Trying to align filesystem data across a modern SSD's erase blocks is futile and will NEVER work. So don't waste your time.
The ONLY things that matter are:
1. Sector Alignment.
Align your partitions (start offset and size), LUKS payload offset, LVM payload (1st PE) offset, etc, all at 1 MiB boundaries. This ensures that they align perfectly with any physical sector size regardless of whether the SSD uses 512 byte, 4096, 8192, 16384 or any other power-of-2 physical sector sizes.
This is because 1 MiB (1 048 576 bytes) is evenly divisible with all sector sizes used by SSDs. Therefore, as long as you align your partitions and data structures (payloads of LUKS and LVM) on these boundaries, all virtual sectors that the OS operates on will be properly aligned with physical sectors.
The purpose of doing this is to ensure that writes to virtual sectors (what the OS reads/writes from) will be aligned with physical sectors on the SSD so that the data from a single virtual sector only occupies a single physical sector, rather than being spread out across multiple sectors (which would then always require the SSD to read two or more sectors, modify the overlapping portion of them that the OS virtual sector is at, and then write all of the modified sectors to a new location on the SSD).
If you align this at 1 MiB boundaries, your OS sectors always be perfectly aligned with physical sectors regardless of their size. If you don't, then the SSD will slow down massively and get heavy write amplification due to the aforementioned process of always modifying multiple physical sectors per write instead of just a single sector.
Luckily all modern tools (like GParted, cryptsetup and LVM) do 1 MiB alignment by default. That is all you need.
This is extremely important. It's insanely important. It's stupidly important. It's as important as the alignment itself.
TRIM is what tells the SSD which sectors it can discard. If you run without TRIM (such as LUKS and LVM with default settings, which won't forward discards), then your SSD's internal lookup table will fill up completely, thinking that every sector matters and contains "living data". Therefore, the SSD won't be able to "garbage collect" anymore. It will think that it is completely full even if your drive is only partially full. And writes will be an extremely slow operation, if it even works at all anymore. Without TRIM, there will be extreme write-amplification because all of that dead data will continue being kept and juggled around/written to new locations by the SSD as it struggles to write data (involving lots of read-modify-write of all sectors in entire erase blocks), because the SSD thinks that the entire drive is full of important data.
By contrast, with TRIM enabled, your SSD will be told which data is dead. The SSD controller will then take all living SSD sectors from multiple erase blocks, merge them all together into a new block with living data (such as merging three 30% full blocks where the remaining 70% is garbage, into a single 90% full block with 10% empty blocks ready for future writes), and then it erases all of the "garbage blocks", so that their internal sectors are completely empty and ready for fresh writes. This garbage collection goes on continuously (whenever the SSD is idle) in modern SSD controllers, constantly moving and compacting blocks and checking the health of living sectors and optimizing the NAND flash for future writes.
And this goes back to the original point about how pointless it is to believe that you can use "filesystem stride" to align sectors along SSD erase blocks. Remember, SSDs can write into any still-empty sector in any "erase block" anywhere on the physical storage. And SSDs will constantly move those sectors around into new erase blocks to optimize the drive performance.
The only thing you should think about when using TRIM is that you should NOT use "instant discards" (i.e. mounting ext4 with the "discard" flag). Because constantly telling the SSD about dead data instantly whenever sectors become free, will cause it to excessively shuffle/compact/garbage collect small amounts of data all the time. Instead, you should be using a weekly timer that does a big "all at once" TRIM of ALL unused blocks. This is how it's done by default on modern operating systems. For example, Windows uses a weekly timer (you can see it by opening the built-in "Optimize Drives" application), and Linux systemd-based operating systems basically all contain "fstrim.timer", which causes "fstrim.service" to execute weekly. Which in turn executes
/usr/sbin/fstrim --fstab --verbose --quiet. The fstrim command informs storage devices (physical and virtual) about unused blocks. In fact, this doesn't just help the SSD. It also helps things like LVM thin provisioning (where multiple volumes share the same physical pool of space) to return blocks to the free pool. So TRIM is just an overall health boost for every part of your system!
Lastly, a small sidenote regarding encryption. If you're using LUKS (encryption), you may have seen passionate rants saying that you shouldn't use TRIM because it's "insecure". That's not true. The only thing that attackers can derive from seeing empty (zeroed) sectors on an encrypted drive, is that they will know how much data you have on there (such as if it's 50% full), which really doesn't help them at all. It also tells them the virtual locations of the used sectors which lets them pretty accurately guess which filesystem is used if the drive is nearly empty, since things like filesystem metadata storage offsets will be visible. But it won't let them get into your data. And guess what? Unless you're the government, I can assure you that you will be happier with a healthy, fast, TRIM'd drive that lives a long, very healthy life. So enable TRIM for your sake! Besides, do you really think that you as a private person would ever encounter an attacker that tries to analyze free (trimmed) sectors to guess things about your computer? That paranoid threat model makes zero sense for most of us. It's far more important that you use a secure passphrase so that random people don't just type "password" and unlock your system! ;-)
Alright, that's everything you ever wanted to know about the subject. The short executive summary is:
- Aligning by "erase blocks" via stride/stripe is COMPLETELY IMPOSSIBLE on modern SSDs, on anything manufactured since around the year 2010. So don't even attempt it. It's based on ancient information for first-generation SSDs which used to store sectors sequentially and lacked TRIM. None of that is true anymore. All SSDs nowadays use wear leveling to store sectors randomly all over the NAND anywhere that there are empty sectors and uses a virtual mapping table to keep track of where data is truly stored on the disk. And they rely on TRIM to get rid of wasteful storage/write amplification.
- But you MUST align all data containers (such as partition start+size, LUKS payload and LVM's 1st Physical Extent) on 1 MiB boundaries to ensure that your virtual storage layer sectors all line up with physical sectors, to ensure that your writes only occupy single sectors. All modern tools (such as GParted, cryptsetup and LVM) now do this universally perfect 1 MiB alignment by default.
- Enable TRIM. It's extremely important since the SSD requires knowledge about dead/useless sectors for proper garbage collection, performance, and a long and healthy life.
- Bonus: As for filesystem block size (regardless of what filesystem you use), you should be using 4096 bytes regardless of physical sector size, because this strikes the ultimate performance/space efficiency balance for modern filesizes. The larger the filesystem blocks, the less overhead in the Kernel's interrupts (since each block has to go through an interrupt and a queue). But larger than 4096 doesn't make sense because of diminishing returns in the performance, while increasing wastefulness for small files. So this is why all modern filesystems default to 4096 byte blocks.