New
#1
How are phyical disks allocated their Disk Numbers?
I think this might be a hardware issue which is why I have posted here, but happy for a mod or admin to move it somewhere else for appropriate if necessary.
First an explanation... I am trying to arrange things so that a specific, permanently connected USB-HDD is not visible in to users during the day, only coming online after-hours to run a backup, then going offline again. For this I am using two batch files to run Diskpart to online or offline the disk as required. These batch files are run using the Task Scheduler with Admin privileges.
DiskOn.bat contains the line... diskpart /s C:\DriveOnOff\diskpart-on.txt and the text file diskpart-on.txt is in the same folder. That text file contains the lines select disk 5 and online disk (off-lining the disk is a similar but reversed process).
The physical disk numbers are almost always...
Disk 0 is C:\ (250GB HDD)
Disk 1 is D:\ (500GB HDD)
Disk 2 is A:\ (500GB HDD)
Disk 3 is F:\ (1TB HDD)
Disk 4 is G:\ (1TB HDD)
Disk 5 is B:\ (4TB USB-HDD)
Most times this works perfectly, but the problem is, while disks 0 to 4 are always the same disks with the same physical disk numbers, sometimes the 4TB HDD comes up as Disk 10, with all the other physical disk numbers between 4 and 9 empty.
Microsoft DiskPart version 10.0.19041.964
Copyright (C) Microsoft Corporation.
On computer: HOME
DISKPART> list disk
Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0....Online..........232 GB 2048 KB
Disk 1....Online..........465 GB 1024 KB
Disk 2....Online..........465 GB 1024 KB
Disk 3....Online..........931 GB.....0 B
Disk 4....Online..........931 GB.....0 B
Disk 5....No Media............0 B.....0 B
Disk 6....No Media............0 B.....0 B
Disk 7....No Media............0 B.....0 B
Disk 8....No Media............0 B.....0 B
Disk 9....No Media............0 B.....0 B
Disk 10..Offline........3726 GB 1024 KB
DISKPART>
I have been unable to replicate this issue. Having another USB stick plugged in on restart doesn't cause the issue, it just comes up as Disk 11.
AIUI the physical disk numbers are are allocated by Windows during boot up - with available fixed disks being numbered first, followed by removable disks, so since I have five fixed disks (0 to 4) the removable disk should always be the sixth disk (Disk 5). I can't understand why it would skip over empty spaces and enumerate the USB-HHD as Disk 10.
Does anyone have any clues as to what might be happening?
Does anyone have a better way of trying to do what I am attempting?