I just discovered a way to format a SSD properly in Haiku.
For those who don't know about SSDs, the most basic read/write internal operations work on 4K blocks. This causes two problems.
[Note: this is a simplified version of what really happens inside a SSD and it's controller.]
1) While reads are always really quick no matter how a partition is set-up on a SSD. If a partition is formatted with a sector/block size that is less than 4K in size then every write operation requires the SSD controller to read in the affected internal block, modify it with data to be written, then write out the changed block data. If instead the partition was formatted with 4K or 8K blocks as the sector size then all writes can be done directly for the affected blocks without any read/modify operations being needed. (This is of-course faster.)
However the above only works properly if the start of a partition is in alignment with the 4K blocks of the SSD.
2) So this bring us to the heart of the matter, and that is the MBR that is written to the start of the drive and then has the partitions written afterwards. Testing both Haiku and Windows 7 OSes, I found the MBR to be the standard 512 bytes in size. This means all sectors are offsetted by 512 bytes from being in alignment with 4K blocks. This is easy to see when you try to create your first partition, the dialog block clearly points out the starting offset of the partition is 512 bytes.
In the past where sector sizes of 256 and 512 bytes were in use then any writes would always fall inside a single 4k block, but Haiku uses 1k, 2k, 4k or 8k sectors for it's partitions. This means sectors will cross the 4K boundary (1 in 4 for 1K sectors, 1 in 2 for 2K ones, and every single time for 4K sectors and twice each time an 8K sector is written.)
Why is this so bad? Well, say we format a partition with 4K sectors, if the partition was aligned then every write would be just a single write operation, but since the MBR forces all the partitions to be out of alignment each write requires a read/modify/write operation and since there is still 512 bytes left over the drive needs to do another read/modify/write operation to write out that final chunk of data. See the problem?
The solution: What we need is some way to write out a 4K MBR. This turns out to be easy to do with the Haiku program "DriveSetup".
[Warning: The following procedure will wipe out *ALL DATA* off the drive. Do not do this to your boot drive unless you have another way to boot your system. And remember all data on the drive will be lost.]
First, delete any partitions or mapping that may be already installed on the drive until you have only the single entry for the drive itself in your DriveSetup window.
Select the drive to be partition/formatted.
Choose to format the entire drive as "Be File System".
Choose the sector size as 4K.
Agree to the formatting. Wait until finished.
Now "Initialize" the drive with "Intel partition mapping".
Now if you select the following "" entry and try to "Create" a partition you find that the offset is now at 4096 bytes. And since partitions sizes are multiples of 1 MByte all the following partitions are also aligned.
Good Luck everyone,
Questions?