
A colleague has asked if there is any utility, application, or command to show a disks physical block size. He's particularly interested in interrogating a drive to see if it's an Advanced Format drive i.e. with native 4096 byte sectors or 512e sectors etc. -- Colin Fee tfeccles@gmail.com

On 24/07/12 16:51, Colin Fee wrote:
A colleague has asked if there is any utility, application, or command to show a disks physical block size. He's particularly interested in interrogating a drive to see if it's an Advanced Format drive i.e. with native 4096 byte sectors or 512e sectors etc.
hdparm -I /dev/sda

On 24 July 2012 16:56, Toby Corkindale <toby.corkindale@strategicdata.com.au
wrote:
On 24/07/12 16:51, Colin Fee wrote:
A colleague has asked if there is any utility, application, or command to show a disks physical block size. He's particularly interested in interrogating a drive to see if it's an Advanced Format drive i.e. with native 4096 byte sectors or 512e sectors etc.
hdparm -I /dev/sda
Hmmmmm. On my laptop here that command produces the following: Configuration: Logical max current cylinders 16383 16383 heads 16 16 sectors/track 63 63 -- CHS current addressable sectors: 16514064 LBA user addressable sectors: 268435455 LBA48 user addressable sectors: 976773168 Logical Sector size: 512 bytes Physical Sector size: 4096 bytes Logical Sector-0 offset: 0 bytes device size with M = 1024*1024: 476940 MBytes device size with M = 1000*1000: 500107 MBytes (500 GB) cache/buffer size = 16384 KBytes Nominal Media Rotation Rate: 7200 Yet a look at the spec sheet from seagate shows, for all drives in this family,: Bytes per sector = 512 -- Colin Fee tfeccles@gmail.com

On Tue, 24 Jul 2012, Colin Fee <tfeccles@gmail.com> wrote:
Logical Sector size: 512 bytes Physical Sector size: 4096 bytes
So if you have a drive like that (as some of my drives return the same numbers) then how do you make sure that the partitions are correctly aligned? Or does parted just do the right thing? -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/

On 24/07/12 17:25, Russell Coker wrote:
On Tue, 24 Jul 2012, Colin Fee <tfeccles@gmail.com> wrote:
Logical Sector size: 512 bytes Physical Sector size: 4096 bytes
So if you have a drive like that (as some of my drives return the same numbers) then how do you make sure that the partitions are correctly aligned? Or does parted just do the right thing?
If you align your sectors as if it were a 4k drive operating in 512-emulation mode, then it'll still work fine on a drive that is actually 512-byte sectors. I gather that recent Linux disk tools, and MS Windows, defaults to setting up disks with partitions/filesystems aligned to 4k boundaries by default. You lose, like, a megabyte, so its not a problem. However there do seem to be a lot of disks that mis-report their physical sector size. Why would that be? One of my disks does, and I'm aware that Samsung have a firmware update that corrects it, but it seems like an odd thing to get wrong in the first place.

On Tue, Jul 24, 2012 at 05:31:50PM +1000, Toby Corkindale wrote:
However there do seem to be a lot of disks that mis-report their physical sector size. Why would that be?
Windows. specifically Windows XP. Lots of 4K sector drives lie to the operating system in order to remain compatible with WinXP. This is less common than it used to be but hasn't vanished entirely yet. This is why it's best (as you mention) to always align partitions as if it were a 4K drive - 4096 bytes is a multiple of 512 bytes so it works for both. this is also why it's a good idea to use '-o ashift=12' when creating a ZFS vdev, in case you have a lying 4K sector drive *or* you may want to replace the drives with 4K sector drives in future. craig -- craig sanders <cas@taz.net.au>

Russell Coker wrote:
On Tue, 24 Jul 2012, Colin Fee <tfeccles@gmail.com> wrote:
Logical Sector size: 512 bytes Physical Sector size: 4096 bytes
So if you have a drive like that (as some of my drives return the same numbers) then how do you make sure that the partitions are correctly aligned? Or does parted just do the right thing?
Current generation parted has options which amount to "none", "some" and "lots" of alignment. The manual has the actual details. Also, using e.g. "0%" instead of "0" or "0b" seems to result in parted interpreting your request more loosely, i.e. with better alignment. Anything 2TiB or higher (note: this does not include 2*TB*) will not have 512b blocks. Anything below 2TiB might, but usually doesn't. The FTLs on SSDs (and SD/MMC readers) tend to hide the underlying block size, so parted's built-in optimagic doesn't know about it. In these cases you have to do it by hand, which is... tedious. Especially when the FTL vendor targets Windows and silently shifts everything a sector to the right, so that windows' default 63-sector (?) alignment will line up with the erase blocks. ...dunno if 3TiB HDDs have that issue. I have deployed a couple of 3TiB disks but my main concern was getting BIOS/GPT hybrid booting working under extlinux, not block alignment. I can't remember if I solved the latter. Re. doing it by hand, Ty Tso had a blog post about it on Intel SSDs with LVM and ext4, which may be applicable. I can't find it just now.
participants (5)
-
Colin Fee
-
Craig Sanders
-
Russell Coker
-
Toby Corkindale
-
Trent W. Buck