Windows how to get type (IDE/ATA/SATA/SCSI/USB/Virtual) of physical disk?

Q. On Windows server given the physical disk \\.\PHYSICALDRIVEn identify whether the disk is ATA, SATA. SCSI disk, USB disk or it is a mounted VHD file.

Ans:
There is no straightforward way in C++ to do this. Windows provide SetupDiEnumDeviceInterfaces APIs to get the properties of devices. But I found it bit complex to solve the problem mentioned.

On the other hand diskpart.exe provides simple interface to identify the type of the disk. Use following commands to get the type of disk:

C:\Users\Administrator>diskpart
Microsoft DiskPart version 6.1.7601
 Copyright (C) 1999-2008 Microsoft Corporation.
 On computer: SYSTEMS11
DISKPART> list disk
  Disk ###  Status         Size     Free     Dyn  Gpt
   --------  -------------  -------  -------  ---  ---
   Disk 0    Online          465 GB  1024 KB
   Disk 1    Online          100 GB  2048 KB
   Disk 2    Online         7633 MB      0 B
DISKPART> select disk 0
Disk 0 is now the selected disk.
DISKPART> detail disk
WDC WD5000AAKX-001CA0 ATA Device
 Disk ID: 84BF18DB
 Type   : SATA
 Status : Online
 Path   : 0
 Target : 0
 LUN ID : 0
 Location Path : PCIROOT(0)#PCI(1F02)#ATA(C00T00L00)
 Current Read-only State : No
 Read-only  : No
 Boot Disk  : Yes
 Pagefile Disk  : Yes
 Hibernation File Disk  : No
 Crashdump Disk  : Yes
 Clustered Disk  : No
  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
   ----------  ---  -----------  -----  ----------  -------  ---------  --------
   Volume 0                      NTFS   Partition    100 MB  Healthy    System
   Volume 1     C                NTFS   Partition    165 GB  Healthy    Boot
   Volume 2     S   VM           NTFS   Partition    299 GB  Healthy
DISKPART>

In the information provided by “detail disk” check the entry:
Type   : SATA 

If the physical disk is ATA drive the type entry in “detail disk” appear as:
Type   : ATA

If the physical disk is SCSI drive the type entry in “detail disk” appear as:
Type   : SCSI

If the physical disk is USB drive the type entry in “detail disk” appear as:
Type   : USB

If the physical disk is mounted VHD/VHDX file the type entry in “detail disk” appear as:
Type   : Virtual

Advertisements

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 )

Google+ photo

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

Connecting to %s