Is partition alignment to SSD erase block size pointless?
This question is very hard, especially in view of the fact that SSD technology is in constant evolution, and especially since modern operating systems are constantly improving their handling of SSD.
In addition, I'm not sure that your problem is with Wear leveling. It should rather be with SSD optimizations designed to avoid block erases.
Let us first get our terms right :
- An SSD block or Erase block is the unit that the SSD can erase in one atomic operation, which can usually go up to 4MB bytes (but 128KB or 256KB are more common). An SSD cannot write to a block without erasing it first.
- An SSD page is the smallest atomic unit that the SSD software can track. A block usually contains multiple pages, usually up to 4KB in size. The SSD keeps a mapping per page of where the OS thinks it is located on the disk (the SSD writes pages wherever it prefers although the OS will think in terms of a sequential disk).
- A sector is the smallest element that the operating system thinks a hard disk can write in one operation. The OS will also think in terms of disk cylinders and tracks, even if they do not apply to SSD. The OS will usually inform the SSD when a sector becomes free (TRIM). Smart SSD firmware will usually announce to the OS its page-size as the sector-size where possible.
It is clear that the SSD firmware would prefer always writing to empty blocks, as they are already erased. Otherwise, to add a page to a block that contains data will require the sequence of read-block/store-page/erase-block/write-block.
Too liberal application of the above will cause pages to be dispersed all over the SSD and most blocks to become partially empty, so the SSD may soon run out of empty blocks. To avoid that, the SSD will continuously do Garbage collection in the background, consolidating partially-written blocks and ensuring enough empty blocks are available. This operation may look like this:
[
Garbage collection introduces another factor - Write amplification - meaning that one OS write to the SSD may need more than one physical write on the SSD.
As an SSD block can only be erased and written a certain number of times before it dies, Wear leveling is designed to distribute block writes uniformly across the SSD so no block is written much more than others.
The question of partition alignment
From the above, it looks like the mechanism that allows the SSD to map pages to any physical location, keeping wherever the OS thinks they are stored, voids the need for partition alignment. Since the page is not written where the OS thinks it is written, there is no more any importance as to where the OS thinks it writes the data.
However, this ignores the fact that the OS itself attempts to optimize disk accesses. For classical hard disk it will attempt to minimize head movements by allocating data accordingly on different tracks. Clever SSD firmware should manipulate the fictional cylinder and tracks information that it reports to the OS so that track-size will equal block-size, and page-size will equal sector-size.
When the view the OS has of the SSD is in somewhat more in line with reality, the optimizations done by the OS may avoid the need for the SSD to map pages and avoid garbage collection, which will reduce Write amplification and increase the lifetime of the SSD.
It should be noted that too much fragmentation of SSD (meaning too much mapping of pages) increases the amount of work done by the SSD. The 2009 article Long-term performance analysis of Intel Mainstream SSDs indicated that if the drive is abused for too long with a mixture of small and large writes, it can get into a state where the performance degredation is permanent, and that with Wear leveling this condition may extend to more of the drive. This condition is the reason while many SSD owners see performance degrade over time.
My final advice is to align partitions to respect erase-blocks layout. The OS will assume that a partition is well-aligned as regarding the disk, and the decisions taken by it on the placement of files might be more intelligently done. As always, individual idiosyncrasies of OS driver versus SSD firmware may invalidate such concerns, but better to play it safe.
Is partition alignment to SSD erase block size pointless?
Based on the below quoted advice from 2008 it seems that aligning partitions to block size boundaries depend on the make, model, and control chips algorithms within any given SSD device.
For the older generation SSD devices that do not use smart technology and algorithms, doing this may be more important but you should check the SSD manufacture's technical guide.
Aligning Filesystems to an SSD’s Erase Block Size
Aligning your file system on an erase block boundary is critical on first generation SSD’s, but the Intel X25-M is supposed to have smarter algorithms that allow it to reduce the effect of write-amplification. The details are a little bit vague, but presumably there is a mapping table which maps sectors (at some internal sector size — we don’t know for sure whether it’s 512 bytes or some larger size) to individual erase blocks.
Fast forward some to 2014 and based on the below advice from then, it seems that read/writes are aligned on page size and erases are done at SSD idle that this does not matter and is pointless.
Really still need EBS (Erase Block Size) for partitioning a SSD?
Reads/writes are aligned on page size, and erases happen in the background when the SSD is idle. As such, erase block size does not matter. Page size matters, but it's always small so just do MiB-alignment. The filesystem will break it down to something around 4k anyway. It's not possible to align to 1536KiB, not with hundreds of small files in a filesystem. Even if you were to put your partitions on 1536KiB boundaries and set your filesystem up with a 1536KiB raid stride, you would not notice any difference. Reads/writes are done on page level, and redistributed anyway by a flash translation layer. So no matter how much you try to align from the outside, the SSD will mangle it to its own purposes anyway, so what's the point?
Conclusion
I think wear-leveling is one of those [smarter] newer SSD algorithms from the 2008 post that was mentioned, and now that this—and other correlated modern SSDs and partitioning technologies—is more common with SSD devices that would imply such alignments would more likely be pointless.
I think some of the talk around the Internet on this topic may be correct in some cases based on whatever SSD technology those may refer to in such writings, etc. and thus the content may simply not be applicable to others depending on what they use.
This comes down to understanding the specs, features, functions, etc. of your SSD device(s) and whatever partitioning tools you use at the time you perform such operations to ensure optimal configuration in your environment whether or not it is a pointless operation to perform.
Further Resources
- Disk Partition Alignment Is Still Important