FreeBSD, SSD's and partition alignment

Koen Smits kgysmits at gmail.com
Mon Jan 5 12:46:31 PST 2009


Hello all,

I'm building a new NAS for home use and want to use a CompactFlash card for
initial boot, ZFS for the rest. While doing some research on Flash based
media performance, i stumbled on the following.

Flash based media uses cells which are very often bigger than the usual HDD
512 Byte sector. When you change even one bit in a cell, you have to read,
modify, write the whole cell. Just like with RAID5. When using the normal
MBR disk layout one could easily mess up the fs alignment when starting the
first primary partition on the default 63th sector. In this situation, when
a fs block occupies a part of two flash cells, and both have to be read and
written. This is bad for performance and for flash cell wear.

On almost all flash based media (and also many RAID controllers) performance
suffers greatly if the fs blocks are misaligned with the media stripe/cells.
Some CF cards for example compensate internally for this by starting the
second cell on sector #63, but this is not common practice and standards
don't exist. Some SSD's like the OCZ Core series and other jMicron JMF602
based SSD's don't like misaligned writes and choke up because writes not
aligned to the flash cells ups the write time latency.

In my limited testing I created an MBR partition layout on a Kingston
Ultimate 266x 2GB CF card, using a starting sector of 2048 instead of the
default 63. I accomplished this by using the free MS Vista recovery disk, as
Vista and Win2008 Server use a default alignment of 1MB when creating a new
primary partition. There really doesn't seem to be a lot of tools out there
that can create and/or resize a partition while allowing you to set the
starting sector exactly. I must admit I used the first solution that worked
though.
When installing i changed the partition type and added the default BootMgr,
installed, etc. fdisk warned about the partition not starting on a cylinder
boundary, this was to be expected. Upon rebooting after finishing the
install, the FreeBSD BootMgr fails to boot and beeps when trying. Looks like
a problem.

I'd like to discuss this subject a bit if anyone's interested.
- partition alignment seems to be a real problem with some of today's flash
and RAID media. I think people need to know one could easily increase
performance (and media wear!) as no one knows this problem exists.
- Is GPT the only supported way of creating correctly aligned partitions?
- Did I make any mistakes in the above example? I've had to read a lot about
the low-level layout of storage media and it could be I messed something up.
- Should FreeBSD offer the option of aligned partitions in sysinstall, or
offer (easy) GPT partitioning?

Some reading material for the interested:
http://blogs.msdn.com/jimmymay/archive/2008/10/14/disk-partition-alignment-for-sql-server-slide-deck.aspx
Also check out the link to the presentation.


Sincerely,

Koen


More information about the freebsd-fs mailing list