jump to navigation

4096 physical block size drives April 30, 2010

Posted by claudio in Uncategorized.
Tags: , ,
trackback

If you buy a new hard drive today, there is a big chance that the disk has the new format of 4KB physical block size instead of the classic 512-byte. The drive will work, however, you may experience some performance issues. I realized this when my usb2 external drive would pause -without errors or warnings- when there was heavy IO or something new was attached to the usb bus. You can query the drive to see what type of block size it has, but beware, some drives … lie.

An honest example:

$ sudo hdparm -I /dev/sde |grep size
Logical  Sector size:                   512 bytes
Physical Sector size:                  4096 bytes
device size with M = 1024*1024:     1430799 MBytes
device size with M = 1000*1000:     1500301 MBytes (1500 GB)
cache/buffer size  = unknown

Some drives may report 512 while being of the 4096 bytes type. To enhance the performance of the drive, you should align your partitions. In short, this means than when creating partitions, these need to start at a cylinder that is a factor of 8. If you only have one partition, let it start at cylinder 64.

For further reference, these are the model numbers of the Western Digital (the pioneer in 4096 byte block size) I have:

$ sudo hdparm -I /dev/sde |grep Model
Model Number:       WDC WD15EADS-11P8B1
$ sudo hdparm -I /dev/sdc |grep Model
Model Number:       WDC WD10EADS-00M2B0

(The last drive does not print having a 4096 byte block size. Because of the identical performance problem as the other one, I am sure it has that type of block size.)

The quickest solution -if you are not installing Windows XP and previous on the disk- is to format the drive without the DOS compatibility setting. E.g. (replace ‘x’ by the correct device name of your drive).

sudo fdisk -uc /dev/sdx

Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-2930277167, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2930277167, default 2930277167):
Using default value 2930277167

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 83

Command (m for help): p

Disk /dev/sdx: 1500.3 GB, 1500301910016 bytes
81 heads, 63 sectors/track, 574226 cylinders, total 2930277168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4fabbfc4

Device Boot      Start         End      Blocks   Id  System
/dev/sdx1            2048  2930277167  1465137560   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Use mkfs.ext4 or gparted (gui) to create a filesystem on the newly formatted drive.

http://www.ibm.com/developerworks/linux/library/l-4kb-sector-disks/index.html?ca=dgr-lnxw074KB-Disksdth-LX

Comments»

1. Drive User - May 17, 2010

The WD EADS drives do not have 4k sectors, the EARS drives do.

claudio - May 17, 2010

That’s what I thought. However, one of my drives actually *reports* 4k sectors and the performance difference is huge after the new formatting. I think that WD is really pushing the new type on lower model as well (again, without telling so).

2. runlevel0 - June 18, 2010

I can confirm this. EADS is a 3.5″ Caviar 5400 RPM / 32 bit cache SATA 3 Gb/s drive, a “Caviar Green” with the normal block size.

3. goldfinch - July 8, 2010

Hi, I have a WD EADS with:
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

I divided it in 2 partitions:1) primary ntfs 2) extended + ext3, with gparted of karmic and everything was ok. Then i upgraded the OS (to lucid lynx) and fdisk changed output, sayng that both partitions didn’t end on cylinder boundary.
So I used fdisk as suggested in this how-to. It created the first partition, for ntfs filesystem, after a MiB (2048 byte) of unallocated space. Ok, now the first partition is aligned.
But I can’t create the second one without having the problem with the end on cylinder boundary.

About your how-to, I don’t understand why the output of fdisk says that your WD has:
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

when before hdparm said:
Logical Sector size: 512 bytes
Physical Sector size: 4096 bytes

Can you give me some help?
ps: sorry for my very bad english, it’s not my language.
Thank you any way.

4. goldfinch - July 8, 2010

why did you delete my post?

claudio - July 17, 2010

No, I just was on holiday :)

5. Dag-Erling - August 11, 2010

As previously mentioned, only EARS and AARS disks have 4096-byte sectors. EADS and other Green models have 512-byte sectors. In your case, it’s probably not the drive that reports 4096-byte sectors, but the USB enclosure.

Since you didn’t provide any numbers, I’m going to assume that you didn’t actually measure the drive’s performance, neither before nor after you realigned your partitions. The sad truth is that regardless of sector size, WD Green disks *suck*, performance-wise. They’re not just slow, they’re extremely unpredictable. I ran a random-write benchmark on a WD Green and a Hitachi Deskstar, both 2 TB. With staggered 8k writes (I tried both aligned and unaligned), I get a constant 26 MBps from the Hitachi, while the WD drive varies wildly from run to run, between 3 MBps and 7 MBps. That’s why you got hangs under heavy I/O. The hangs you got “something new was attached to the usb bus” are most likely ascribable to your USB hardware or drivers, not to the drive.

@goldfinch: forget about cylinder boundaries, they don’t exist on modern drives (and by “modern” I mean “anything manufactured in the last 15 years”). They’re fictional numbers that the disk makes up for compatibility reasons. They don’t matter one whit unless your BIOS is set to CHS mode instead of LBA, and I don’t think modern BIOSes (and by “modern” I mean “anything manufactured in the last 10 years”) even support CHS mode.

claudio - August 11, 2010

Hi Dag,

I get up to 33 MBps on my 1,5TB drive (after a bios upgrade, true). The drives are however unpredictable as they can be slower and as well freeze the transfer a few seconds.

6. Dag-Erling - August 11, 2010

You get 33 MBps *sequential* access. Try random access – I dare you :)

7. claudio - August 11, 2010

Hehe, good point.

8. goldfinch - September 3, 2010

Dag-Erling, you’re right! Before I installed the WD EADS in my pc, it was a “My Book Essential” and I perfectly remember that, before the first format (in two partitions), it had an unallocated space of 1024 byte, the rest was pre-formatted in NTFS.
But when fdisk of lucid told me that partitions were misaligned, the hard disk was not anymore in the USB enclosure, it was inside the case of pc.
Then I solved my problem, anyway. I was able to align both partition (ntfs & ext3) with “fdisk -uc” in two times. At last, it created an unallocated space of 1 MiB (1024 byte) at the beginning of each partition, totally 2 Mib of empty space.
I don’t have anymore warning using fdisk or palimpsest. Also, windows xp recognize perfectly the NTFS partition, even if it start at 2048 sector instead 63.
This is the output (italian) of “fdis -lu” now:

Disco /dev/sdb: 1000.2 GB, 1000204886016 byte
255 testine, 63 settori/tracce, 121601 cilindri, totale 1953525168 settori
Unità = settori di 1 * 512 = 512 byte
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Dispositivo Boot Start End Blocks Id System
/dev/sdb1 2048 976751999 488374976 7 HPFS/NTFS
/dev/sdb2 976752000 1953520064 488384032+ f W95 Esteso (LBA)
/dev/sdb5 976754048 1953520064 488383008+ 83 Linux

Thank you so much, Claudio, for your illuminating post. Thank Dag Erling too. Bye. :)

9. Dag-Erling - September 3, 2010

Once again, EADS disks have 512-byte physical sectors. What Lucid was telling you was that the partition was not aligned on a *cylinder boundary*, which is a completely fictitious number. Aligning your partition on a 4096-byte boundary makes *absolutely* no difference.

http://maycontaintracesofbolts.blogspot.com/2010/08/exploring-wd-advanced-format-drives.html

http://maycontaintracesofbolts.blogspot.com/2010/08/benchmarking-advanced-format-drives.html

http://maycontaintracesofbolts.blogspot.com/2010/08/disks-and-equipment.html

10. claudio - September 13, 2010

A summary could be: “these drives suck”.

I am not buying them any more as they *are* indeed slow.

11. Jaap - June 6, 2011

I’ve got the WD20EARS with Advanced Formatting; sudo fdisk -lu tells me:

Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

And that’s absolute perfect!!!
Why? The OS (Linux Ubuntu 10.10) uses 512bytes, old-skool but knows that the way the hdd is physical=4096bytes (hence: 512 / 4096, first sentence)
The way it uses the I/O on that particulair drive is 4K logical / 4K physical, hence the second sentence: 4096 / 4096 bytes.

Copied 111.4GB in 19 minutes=average 100MB/sec. Not bad at all! :D
(Starts with 119MB/sec and lowers slowly to 93MB/sec at the end.)
That’s what I call performance and normally my 7200rpm drives at sata300 could not push the barrier above 60-70M/sec, but this is a Green Caviar at 5400rpm, so I’m really impressed!!! So, “slow drives”??? Not at all!!! :D

I used Ubuntu 10.10 (installed first!) and updated everything, then put Gparted on it and formatted the 2TB WD20EARS. It starts on sector 2048.
I let it that way (instead of re-partitioning it to sector 64), because the OS did it this way- it should be probably for the best and if I want to use WinXP in a VM, then it can (I think in advance know) probably use the hdd as well, after applying the WD Advanced Format XP tool inside the VM. I will test that later, when I’ve installed that VM.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 49 other followers