usbdrivedetector icon indicating copy to clipboard operation
usbdrivedetector copied to clipboard

> The file system shouldn't mater. It should work with FAT32

Open sashi2k opened this issue 4 years ago • 10 comments

The file system shouldn't mater. It should work with FAT32

It is not detecting. I have an external hard disk with NTFS partition. I created one FAT32 partition. When I plugin the hard disk and run the Java program, it does not show the external hard disk.

Originally posted by @sashi2k in https://github.com/samuelcampos/usbdrivedetector/issues/36#issuecomment-712981156

sashi2k avatar Oct 20 '20 16:10 sashi2k

It works with your NTFS partition? What is your OS version?

samuelcampos avatar Oct 20 '20 16:10 samuelcampos

It works with your NTFS partition? What is your OS version?

I am using Windows 10 operating system. The java program successfully detects USB Pen drive or a Memory Card.

sashi2k avatar Oct 20 '20 16:10 sashi2k

In windows you are querying with drivetype 2 which is for removable disks, however, windows are classifying external hard disk as drivetype 3 (as a regular hard disk). I guess that's the reason your program isn't detecting external hard disk connected to windows. However, I checked on OSX, it is able to detect as removable disk.

sashi2k avatar Oct 20 '20 17:10 sashi2k

Are you planning to fix this for Windows?

sashi2k avatar Oct 21 '20 07:10 sashi2k

yes, I'll try

samuelcampos avatar Oct 21 '20 09:10 samuelcampos

Because it is classifying your external hard disk as a regular hard disk, I don't know exactly how should we distinguish between this external disk and the computer's default hard disk.

Do you have any idea how to do it?

If we don't find a way to distinguish in those cases, I guess I can find a way to configure which types we want to look for.

samuelcampos avatar Oct 21 '20 17:10 samuelcampos

@sashi2k Did you test this with the latest Win10? Because i just tried this with my fat32 formatted usb stick and wmic.exe reports it as DriveType 2.

C:\Users\wlfbck>wmic logicaldisk get Caption, DriveType
Caption  DriveType
C:       3
D:       3
E:       3
F:       3
G:       2
H:       2

(C-F are normal NTFS drives, G is a NTFS formatted USB stick, H is a FAT32 formatted USB stick)

wlfbck avatar Feb 10 '21 11:02 wlfbck

I was looking at using the library for a pet project and ran into the same issue. Running Windows 10 Version 10.0.19043 Build 19043

Here is my wmic output:

wmic:root\cli>logicaldisk
Access  Availability  BlockSize  Caption  Compressed  ConfigManagerErrorCode  ConfigManagerUserConfig  CreationClassName  Description       DeviceID  DriveType  ErrorCleared  ErrorDescription  ErrorMethodology  FileSystem  FreeSpace
0                                C:       FALSE                                                        Win32_LogicalDisk  Local Fixed Disk  C:        3                                                            NTFS        943218184
0                                D:       FALSE                                                        Win32_LogicalDisk  Local Fixed Disk  D:        3                                                            NTFS        173841717
0                                E:       FALSE                                                        Win32_LogicalDisk  Local Fixed Disk  E:        3                                                            NTFS        224854936
0                                F:       FALSE                                                        Win32_LogicalDisk  Local Fixed Disk  F:        3                                                            NTFS        536329011
0                                G:       FALSE                                                        Win32_LogicalDisk  Removable Disk    G:        2                                                            FAT         455360512

wmic:root\cli>diskdrive
Availability  BytesPerSector  Capabilities  CapabilityDescriptions                                             Caption                         CompressionMethod  ConfigManagerErrorCode  ConfigManagerUserConfig  CreationClassName  De
              512             {3, 4}        {"Random Access", "Supports Writing"}                              SABRENT  SCSI Disk Device                          0                       FALSE                    Win32_DiskDrive      
              512             {3, 4}        {"Random Access", "Supports Writing"}                              WDC WD40EZRZ-22GXCB0                               0                       FALSE                    Win32_DiskDrive      
              512             {3, 4}        {"Random Access", "Supports Writing"}                              Samsung SSD 870 QVO 1TB                            0                       FALSE                    Win32_DiskDrive      
              4096            {3, 4}        {"Random Access", "Supports Writing"}                              Microsoft Storage Space Device                     0                       FALSE                    Win32_DiskDrive      
              512             {3, 4, 7}     {"Random Access", "Supports Writing", "Supports Removable Media"}  2.0 USB Device                                     0                       FALSE                    Win32_DiskDrive      

"F:" ie "SABRENT SCSI Disk Device" is the removable drive. It is mounted in a USB external enclosure. Did a little digging in the code and online to see if I could find a solution.

According to This superuser post:

...As for where this information is from - the disks themselves should have that information...

I tried to find a primary source from windows for how type detection is done but turned up empty-handed. The best I could find is the overview docs from Microsoft. LogicalDisk,DriveType,RealDriveType

So I think either the drive self identifies or windows decides based on whatever internal factors the devs over there thought were good enough.

I don't see any way to (using these utilities) detect an external hard drive. At least not if Windows itself is not identifying the drive as such. I am going to adopt a different solution for my project but I thought this dive might be useful. Cheers!

droidkfx avatar Dec 21 '21 19:12 droidkfx

My NTFS hard disk DriveType 3 is not picked up. We use USB external hard disk to transfer stuff. However while doing some testing the api picks up USB memory sticks (DriveType 2) just fine. Our NTFS formatted USB harddisk however (DriveType 3) is not picked up at all.

Is DriveType 3 not supported?

Avec112 avatar Feb 24 '23 08:02 Avec112

Testing the same code on a Linux it picks up the external Hard drive just fine. So Windows is the problem here it seems.

Avec112 avatar Feb 24 '23 08:02 Avec112