72

How can I determine the Physical Sector Size (e.g. if i have an Advanced Format drive with 4,096 byte sectors rather than the legacy 512 byte sectors) in Windows 7?

I know that by clicking on a file and get properties we can find out the NTFS Cluster Size, but that's not the same as the hard-drive's sector size.

Note: We ask about Windows 7 because it (and Windows Vista SP1) understand the existence of 4096 Advanced Format hard drives.

peterh
  • 11,875
  • 18
  • 85
  • 108
Mojtaba Kamyabi
  • 3,440
  • 3
  • 29
  • 50
  • 1
    I'm going to update this for Windows 10, since this is the first article that comes up in my search: Use Powershell, "Get-Disk | Format-List" (however, it doesn't show all of my disks...) – MikeP Jun 10 '18 at 22:41
  • 2
    Better update for Windows 10, "Get-PhysicalDisk | select physicalsectorsize, friendlyname". Shows all my physical disks and their sector size properly. – MikeP Jun 10 '18 at 22:48

9 Answers9

82

You want fsutil. Make sure you run Command Prompt as Admin.

C:\Windows\system32>fsutil fsinfo ntfsinfo c:
NTFS Volume Serial Number :       0xf4ca5d7cca5d3c54
Version :                         3.1
Number Sectors :                  0x00000000378fd7ff
Total Clusters :                  0x0000000006f1faff
Free Clusters  :                  0x00000000000e8821
Total Reserved :                  0x0000000000000910
Bytes Per Sector  :               512
Bytes Per Physical Sector :       512
Bytes Per Cluster :               4096
Bytes Per FileRecord Segment    : 1024
Clusters Per FileRecord Segment : 0
Mft Valid Data Length :           0x00000000196c0000
Mft Start Lcn  :                  0x00000000000c0000
Mft2 Start Lcn :                  0x000000000097ffff
Mft Zone Start :                  0x000000000051f920
Mft Zone End   :                  0x000000000051f9a0
RM Identifier:        0652C3D3-7AA9-11DA-ACAC-C80AA9F2FF32
Chris Gessler
  • 22,727
  • 7
  • 57
  • 83
43

Windows 10 update:

There is now a sectorInfo sub-command which may provide better information:

C:\>fsutil fsinfo sectorInfo C:

LogicalBytesPerSector :                                 512
PhysicalBytesPerSectorForAtomicity :                    4096
PhysicalBytesPerSectorForPerformance :                  4096
FileSystemEffectivePhysicalBytesPerSectorForAtomicity : 4096
Device Alignment :                                      Aligned (0x000)
Partition alignment on device :                         Aligned (0x000)
Performs Normal Seeks
Trim Not Supported
Gregor
  • 1,205
  • 11
  • 20
32

i wanted to expand on Chris Gessler's answer, and note that there is no known way to get the Physical sector of a drive using Windows Management Instrumentation (WMI), e.g. wmic.

Given that i have an Advanced Format drive (i.e. it uses 4,096 bytes per sector rather than 512):

C:\Windows\system32>fsutil fsinfo ntfsinfo d:
NTFS Volume Serial Number :       0xa016d8a616d87eaa
Version :                         3.1
Number Sectors :                  0x00000000747057ff
Total Clusters :                  0x000000000e8e0aff
Free Clusters  :                  0x000000000e7b2813
Total Reserved :                  0x0000000000000000
Bytes Per Sector  :               512
Bytes Per Physical Sector :       4096

Neither WMI's DiskDrive:

wmic:root\cli>diskdrive
Availability  BytesPerSector  Capabilities  CapabilityDescriptions                                       Caption
              512             {3, 4, 10}    {"Random Access", "Supports Writing", "SMART Notification"}  ST1000DM003-9YN162 ATA Device

 

nor Partition:

wmic:root\cli>partition get BlockSize, StartingOffset, Name, Index
BlockSize  Index  Name                   StartingOffset
512        0      Disk #0, Partition #0  1048576

can report the underlying physical sector size. It makes sense when you realize they both report the sector size that Windows is using. It is 512 bytes per sector - the drive just happens to be different inside.

That's because only Windows 8 supports use of 4k sectors. Windows 7 understands that the drive might be 4k, and works to align it's 4k Clusters with the hard-drive's underlying 4k Sectors.

Update

wmic diskdrive now does show physical bytes per sector in Bytes per Sector:

C:\Windows\system32>wmic
wmic:root\cli>diskdrive
Availability  BytesPerSector  Capabilities  CapabilityDescriptions                                       
              4096            {3, 4}        {"Random Access", "Supports Writing"}                        

While wmic partition continues to be wrong.

Windows 10.0.19041.804

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
  • **This answer is severely outdated.** These utilities now show the logical (emulated, almost always 512) and physical (real, almost always 4096) sector sizes. See the other answers. – Mitch McMabers Feb 26 '21 at 17:25
16
  1. Run msinfo32 in command line that should popup a GUI window called "System Information"
  2. In the left pane select "System Summary->Components->Storage->Disks". This should load info of all drives in the right pane
  3. Find your desired drive and check the value for "Bytes/Sector". it should say "Bytes/Sector 4096"
AK S
  • 174
  • 1
  • 5
9

If you want to have it programmatically, you need to send IOCTL_DISK_GET_DRIVE_GEOMETRY_EX and use Geometry.BytesPerSector from DISK_GEOMETRY_EX structure

LaurentG
  • 11,128
  • 9
  • 51
  • 66
Anton Kukoba
  • 265
  • 2
  • 12
  • 7
    That reports only the logical sector size. Getting a `STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR` struct from passing `IOCTL_STORAGE_QUERY_PROPERTY` to `DeviceIoControl` will get both the logical and physical sector sizes. The only shortcoming is that it doesn't work for external hard drisks - `DeviceIoControl` returns `ERROR_INVALID_FUNCTION` (at least, I haven't found a way to make it work for external hard disks). – Doug Cuthbertson Sep 18 '15 at 13:11
6

You can use wmic from the command line:

C:\Windows\System32\wmic partition get BlockSize, StartingOffset, Name, Index

BlockSize  Index  Name                   StartingOffset
512        0      Disk #0, Partition #0  32256
512        1      Disk #0, Partition #1  370195176960

The BlockSize is the sector size of the drive.

Cyclonecode
  • 29,115
  • 11
  • 72
  • 93
  • 7
    That `BlockSize` is the *logical* sector size, and not the *physical size* that `fsutil fsinfo ntfsinfo c:` reports. Source: i have a 4,096 AF drive that fsutil reports as 4096 and `BlockSize` reports as 512. – Ian Boyd Nov 22 '12 at 18:58
  • Second the above, this only reports logical sector size. `fsutil` reports correctly. – Hashim Aziz Apr 23 '18 at 22:11
5

Powershell:

$wql = "SELECT Label, Blocksize, Name FROM Win32_Volume WHERE FileSystem='NTFS'"
Get-WmiObject -Query $wql -ComputerName '.' | Select-Object Label, Blocksize, Name

Output example:

Label            Blocksize Name
-----            --------- ----
OSDisk                4096 C:\
Windows RE Tools      4096 \\?\Volume{b042c778-cd66-4381-9312-3f4311321675}\
PS C:\>
NSNoob
  • 5,548
  • 6
  • 41
  • 54
The Stig
  • 61
  • 1
  • 1
  • Explain this... msinfo32 reports all as 512, this reports all as 4096, I KNOW I have both, as I can't set up a mirror, but I don't know which disk is which... Also, this only shows the drive letter, not the disk. – MikeP Jun 10 '18 at 22:35
3

Recent powershell versions have a Get-Volume

Get-Volume  | Format-Table DriveLetter, FileSystemLabel, AllocationUnitSize
Preben Huybrechts
  • 5,853
  • 2
  • 27
  • 63
1

If you really want to have it programmatically, you need to send IOCTL_STORAGE_QUERY_PROPERTY providing STORAGE_PROPERTY_QUERY with PropertyId set to StorageAccessAlignmentProperty. This gives both physical and logical sector sizes.

Note: this only works on Windows Vista and higher.