Not taking advantage of 4Kn? You will be soon.

November 11, 2014 | MBX Systems | Post

In the storage world, 4Kn, or “4K native” (also referred to as ‘Advanced Format’ or simply ‘AF’) refers to the next generation in default media allocation size. In everyday terms, data on a disk has historically been relegated to a standard 512 bytes of data per sector. With the ever-increasing demand for higher density storage and with file sizes ever increasing, the groundwork for a larger, higher performance and capability default size was needed. 4Kn fills this role to allow hard disk vendors to improve density (bigger capacity hard drives) and to more efficiently use the precious I/O we have available using our current and future interfaces.

All drives today are 4Kn, and if you aren’t taking advantage of that, you are killing your server’s performance. However, to ease the transition from 512n to 4Kn allocation, drive makers introduced 512e, allowing 4kn drives to emulate 512n. Interestingly, 512e will be around for a long time, but there will start to be a demarcation line between the 4Kn and the 512e drives where you can’t always count on 512e to be there. They will coexist for at least the next 5 years or so, but most don’t realize the implications it has. Going forward, for high-density storage, 4Kn will be your only option.

There have been a number of extremely detailed and helpful articles and data sheets written on this topic, so I won’t rehash them (example: Dell’s white paper on 512e and 4Kn disk formats).

Brief description of the issue:

Up until recently, our ‘Advanced Format’ 4Kn drives have always been equipped in a way where the drive, though 4Kn, would actually present 512 byte blocks to the operating system using a method called ‘512e’ or ‘512 byte emulation’. The drive itself would manage the ‘translation’ of 512 byte blocks from the OS to the native 4K sector sizes on the drive, allowing us all to carry on with ‘business as usual’ (though this isn’t 100% correct, but I’ll elaborate further down).

If we do a little math, we will notice that 512B goes into 4K exactly 8 times. This means that as long as we are lined up, or ‘aligned’ in storage parlance, we minimize the amount of unnecessary disk activity. What do I mean by that? Remember that 512e drives will translate the 512e sector that you are reading or writing (we’ll focus on writing for the sake of this discussion) to the actual 4K (8*512b) sector on the drive. If we request, say, 4K of data from the drive in 512e mode, and those 8*512B sectors we requested start and end within that single 4K sector on the drive, we’re only looking at a single read or write operation as far as the drive is concerned. What happens if we have our data/partitions aligned in such a way where 4*512B of the 8 (of the 4K sector) are on one 4K sector and the other 4 are on the next sector? The drive will be forced to do two separate operations. With a read, this simply doubles the work of the drive. With a write, however, the drive will need to read the contents of the two 4K sectors, find the 512e sectors that apply to our 4K request, copy the two 4K sectors to DRAM, write in our changes, then rewrite both our changes and the existing data from the other 4*512B in each 4K sector.

Whew! That is a lot of extra work no matter how you cut it. Remember, this is for TODAY’S 4Kn/512e drives that we use every single day!

So let me ask you, are you aligned in such a way that a 4K write will only be 4K?

If you aren’t sure, that’s ok, but understand you are leaving performance on the table. A quick fix that will not only set you up for optimal performance today but also have you ready for the day when 4Kn is your only option is to set your partitions to 4K friendly locations. For example, when creating a RAID volume, you must partition the array for use with a file system. When you do, what is your starting sector? 0? 1? 63? Do any of those actually make sense given the boot block and 4K sectors? Not really. Not at all, in fact.

A good rule of thumb that will always work and have you ready for next gen is 2048. This sector corresponds with the 1MiB mark, which is neatly divisible by 4K. With how large today’s drives are, a missing single MiB is not going to impact anyone in any measurable way, allows plenty of room for the boot block to be enhanced over time, and is compatible with every partition table available today (by a wide margin).

tl;dr: Align your partitions to 2048 sectors.

When stepping up to a truly 4Kn drive without any 512e emulation, the 2048 will still work fine and align you correctly. (In fact, there isn’t much of a way to misalign a 4Kn only drive since it only understands 4K sector sizes.) In this case though, it may make more sense to simply align to 1 MiB mark instead, since 2048s will yield you 8x more disk usage for the beginning, unused section of the drive. Either way, we aren’t talking about a significant amount of capacity, so the method you use isn’t terribly important, only that it is done to ensure best alignment on transitional 4Kn/512e drives.

The bigger issue when stepping up to truly 4Kn drives is today’s current software regiment. Though most recent operating systems have 4Kn support (Linux >=2.6.31, Windows >=8/8.1/2012), there are other considerations to think about when making the move. To boot from a 4Kn disk, you’ll need a UEFI rather than a BIOS, and you’ll need a compatible OS. Simply using 4Kn drives for storage has less of an implication on the above (requirements drop to Windows Vista/7, for example), but there is still the issue of software compatibility.

Make Sure Your Application is 4Kn Ready

For software that expects a 512b sector, you’ll end up with scenarios where what is intended and what actually occurs are mismatched. The most critical are applications like databases. Please check with your software vendor or project to ensure the application is 4Kn ready before taking the plunge.

Request a Demo

See the secret sauce behind our high-tech tech manufacturing and supply chain management. Weirdly, it doesn’t involve mayo.