Caviar Green, Advanced Formatting and 4k HDD Clusters

Hi,

I’ve just bought a WD Caviar Green HDD, which uses ‘advanced formatting’. Basically, it writes data in sections of 4 kilobytes instead of the standard 512 bytes. Typically, a problem is only known to persist with Windows, but I’d like to know if anyone else had used an advanced format drive in Haiku. Can Haiku write data in 4k sectors, or does it emulate them?

Thanks.

The default is to initialize with 2k blocks, but it can be changed to 4k. This should work just fine on the new disks.

The most important thing, especially in the short term is how any disk partitioning or formatting tools included in Haiku cope.

All SATA drives will be backwards compatible, but at a cost of significant performance degradation for unaligned access (like the x86 CPU family). The performance cost applies to any OS, no matter how cleverly designed, if it finds itself writing data which is not aligned with the new 4kbyte hardware disk blocks.

This means that it’s much more important for your OS to include tools that align new partitions correctly and lay out new filesystems correctly than to check that it is always doing aligned block access when writing files. A subsequent software update can easily fix the latter, but it’s tricky (and dangerous in the sense of potential data loss) to fix the former.

Does Haiku have representation on the relevant standards committees? Does it have someone in touch with manufacturers to get preview hardware? I’d guess the answers are “No”. So, some volunteer will have to buy a few types of new disk (there are several options and manufacturers haven’t all chosen the same) and check how the existing Haiku tools perform, then update those tools accordingly.

You must make sure the partition is aligned. Read this to understand:
http://www.osnews.com/story/22872/Linux_Not_Fully_Prepared_for_4096-Byte_Sector_Hard_Drives

One method is to use Linux to create the partition with fdisk. To select the starting (very important) & ending sectors. Then initialize it to 4K bfs with Haiku.

Haiku has 4K block size which should work. Can’t say for sure until someone tests Haiku with these newer drives.

Okay, I didn’t really understand the article, but I have read some more about this on another site, and here’s what I’ve gathered. Please correct me if I’m wrong:

So-called advanced format drives are hard drives that are designed to have data written on them in 2K, or more likely 4K sectors, as it extends the usable space on the drive, and requires less error checking information. Operating systems like MAC OSX, Windows Vista and 7, some Linux distributions and Haiku can handle many sector sizes ‘out-of-the-box’. Windows XP can only handle sectors of a size of 512 bytes. It looks for the first partition at this 63 place, which is the first usable 512 bytes of the partition. However, it is not a multiple of 4K, so the first sector must start after, at 64. So, a windows XP partition must be moved forwards by a kilobyte, ‘aligned’, so that the partition is not read incorrectly.

I don’t unserstand how the performance degradation works yet.

I have cloned XP to the Caviar drive, and once my controller will boot it, I will use the alignment tool to move the partition. Then, if I create all of the other partitions in Haiku, or create and align them in XP, there should be no problem, in theory, of course.

The article was saying there is a difference between logical & physical sectors. Logical are 512 bytes and physical, in these drives, are 4096 bytes - no longer 512 to 512. You want to align the logical with the physical to avoid performance issues. You do this by going with multiple of 8 ( eight times another number ). 512 (logical) bytes * 8 = 4096 (physical) bytes = 1 sector. So, 8 * 8 = 64 - start of 1st partition = 64 logical sectors and 8 physical. You’ll want every partition to start on a multiple of 8 to remove performance problem ( like 230% loss ). Starting at 63 does not align the logical & physical sectors causing massive slow down; ie: from recalculating which sector to write to on drive.

These drives write in 4K sectors. Going from 63 to 64 is one logical sector, so 512 bytes ( half kilobyte ). Old drives use 512 byte sectors, these use 4096 byte sectors. Data that took 64 sectors to write on old drive is now written in 8 sectors.

Linux & Windows XP are affected and probably other OSes too but you can manually fix the problem by creating partitions in expert mode and using multiple of 8 for partition starts. Should use block size of 4K or multiple of 4 when formatting.

The link to the article I provided shows that Linux suffers the same result. Partition tools are not ready to handle 4096 byte drives automatically.

The new drives are 100% compatible with old drives. To achieve this, the new drives continue to be able to read and write 512 byte logical sectors. But, since there are no longer 512 byte physical sectors on the disk, writing a 512 byte sector can only be achieved by reading the 4096 bytes, altering 512 of them, and then waiting for the disk to get back where it started and writing the updated 4096 byes.

Of course this “updating” process is much slower than an ordinary write, so if your disk layout forces the OS to make lots of unaligned writes the performance of the drive will be much worse than usual.

Okay, thanks. I didn’t know that sectors were both logical and physical. I should have checkeed wikipedia, or the massive computer encyclopaedia that I bought for exactly this reason. Duhhhyy! Anyway, thanks. I get it now. So, as I can’t clone my Windows NTFS partition in 4k sectors, I’ll align it on bootup, and then create new partitions in 4k sectors. If, for example, I wanted to make a partition specifically for videos, then I could make a partition with even larger logical sector sizes, as the files will nearly always be very big. Will this effect the speed that the drive reads and writes data?

Bigger block size ( or cluster size ) will improve I/O performance on large files. Use bigger block size if you intend to have mostly large files on that partition. Large block sizes waste disk space with small files.

This should explain it a little:

Hi, guys, Me, and my friend tested an HDD WD10EARS 4k clusters, formatted bfs with indexing, 4096k sector size, works well

But did you align it correctly? It would still work even if it wasn’t aligned but at a proformance loss which you might not notice soo much on such a fast drive untill you do some IO intensive things like building Haiku etc…