Get exact size in bytes of a disk & partitions in windows

7,514

Solution 1

Have you tried checking WMI for accurate values? You can query common aliases through the wmic command:

C:\>wmic partition get name,bootable,size,type
C:\>wmic diskdrive get size,status,TotalCylinders,TotalSectors,SCSIPort,SCSITargetId,model

Solution 2

wmic diskdrive : for physical size
wmic logicaldisk : for you know

Share:
7,514

Related videos on Youtube

Antonius Bloch
Author by

Antonius Bloch

Hi there. I'd love to share, but "Deny by default". If you can't tie the information I'm spilling on Stack Exchange then you can't use it to triangulate an attack on the systems I'm responsible for. I'm careful with what I post, but you can never be too careful, can you?

Updated on September 17, 2022

Comments

  • Antonius Bloch
    Antonius Bloch almost 2 years

    I'm using dd (under cygwin) to copy a shadow image of a disk in windows. Shadow copy will only give me a partion, so what I am doing is:

    1) using dd to grab the disk header (32k on Win2003)
    2) using dd to copy the shadow partition
    3) using dd to copy the end of of the disk (8 meg reserved on Win2003)
    4) stitch them all together and boot on KVM

    I need the exact size of all the partitions and non partitioned space on this windows drive. Unfortunately most windows disk tools seem to fudge the numbers a bit, or at least give me a different size than Linux does. I could guess like this 32k + partition size + 8M, but I want to double check. If I make a mistake I could lose data.

    This is on a remote & live Windows 2003 server so no offline solutions will be helpful. Latest cygwin is installed.

    • Antonius Bloch
      Antonius Bloch over 13 years
      I've actually solved the original disk imaging problem, but I never did figure out how to get an accurate byte size of a windows disk (the whole disk not partitions). This can't be that difficult ...
    • Antonius Bloch
      Antonius Bloch over 13 years
      I'd also like to add that I don't think the value shown in "My Computer>Disk>Disk Properties" is totally accurate. When I imaged a Windows 2003 machine I got a raw disk image of 73274490880 bytes but disk properties reports 73262534656.
    • Antonius Bloch
      Antonius Bloch over 13 years
      The plot thickens though: disk properties in windows = 73262534656, wmic = 73270794240, disk image on linux (ls -la) = 73274490880, wmic on virtual machine created from disk image = 73270794240. My theory is that Windows doesn't report on the empty space it reserves at the end of the disk.
  • Antonius Bloch
    Antonius Bloch over 13 years
    The problem is that I don't have any local storage. I'm using dd because it tunnels through ssh.
  • Philip
    Philip over 13 years
    Could get creative with iSCSI, but you're probably better off gettind dd working.
  • Antonius Bloch
    Antonius Bloch over 13 years
    Thank you, that's a great command. The plot thickens though: disk properties in windows = 73262534656, wmic = 73270794240, disk image on linux (ls -la) = 73274490880, wmic on virtual machine created from disk image = 73270794240
  • Muhammad Danish
    Muhammad Danish over 13 years
    How are you creating that disk image -- using the process above? Also, there's 'wmic volume get capacity'..
  • tony roth
    tony roth over 13 years
    i was first with the wmic command
  • Antonius Bloch
    Antonius Bloch over 13 years
    True but Ben's answer gave more information. I still don't have what I need to solve this problem, Linux reports one size and Windows another. Not sure which is accurate ...
  • tony roth
    tony roth over 13 years
    yea I was just being a wiener!
  • atroon
    atroon over 13 years
    My gut says that if wmic agrees on the original and restored dd images, then you're in good shape not to lose data.
  • Chloe
    Chloe over 6 years
    ERROR: Description = Not found