Score:0

Windows 10: How do I set a hard disk offline by default?

nl flag

I have a disk that I want to keep in an offline state, even across reboots. It's a backup disk that should remain offline until I'm doing a backup. Short of opening the case and pulling the power/data cables, is there a way to force the disk to be offline by default?

This is for Windows 10 Professional RTM. I figure it's probably a registry hack, but I'm not sure where to look. The disk is inside the case of the machine, but it's a dynamic disk because the original intention was to use it with a hot-swap bay.

I know how to do it in Unix/Linix environments with the /etc/fstab file and rc scripts, but Windows is a strange beast when it comes to system stuff.

EDIT: To clarify, I'm running backups manually, not scripted. I would prefer the disk to remain offline after a reboot no matter the previous state.

Jevgenij Martynenko avatar
us flag
Normally, if you put the disk offline manually via Disk Manager it will stay offline after reboot. So your question requires clarification. Do you run backups manually? Or scripted? Do you want to script bringing the disk online/offline between backups? Or your intention is simply "make the disk offline no matter its previous state"?
Zac67 avatar
ru flag
You should note that *offline* mode is no substitute for air gapping - if malware gets the upper hand it can easily *online* your disks at any time. If you want to guard against that there's no safe way other than to unplug or power down. I use `removedrive` by Uwe Sieber to logically eject my backup drive in case I forget powering it down.
Score:3
ru flag

There is no mechanism in Windows to not mount a drive at startup as for Linux fstab. As stated in the comments, if you set it offline, it will stay offline even after a reboot.

However, if you want to ensure that the disk is offline after a computer restart, then you have the following options:

  • Group Policy Shutdown Script (preferred method) (or Logoff Script, if you want to put it offline when logging off your session without computer restart)
  • Scheduled task (multiple possible triggers like startup, logon, event, etc)

Because you are using Dynamic Disks, you cannot use the Powershell cmdlets Get-Disk and Set-Disk to put it offline as they only work for Basic Disks. The other cmdlets that can access your drive are Get-PhysicalDisk and Set-PhysicalDisk but they don't provide the ability to put a Dynamic Disk offline neither.

So the only option left is to use the DISKPART tool. The point here is that you need to reference your disk using the number listed by Diskpart and this is subject to change with the disks configuration (add or remove drive, change SATA port, etc)... so keep this in mind.

Here is a Powershell example on how to use DISKPART (without creating a separate script to be passed as parameter) that you can use in either Group Policy Script or Scheduled task:

$diskpartCommands = @() ;

$diskpartCommands += "select disk X" ; # X being the Disk number as listed by the command 'DISKPART list disk'
$diskpartCommands += "offline disk" ;

$diskpartCommands | DISKPART.EXE

If you were to change the disk back to Basic Disk, then you will be able to use the Get-Disk and Set-Disk cmdlets.

Finally, if simply unmounting the volume instead of putting the Disk offline could address your needs, the 'mountVol' command can be used even on Dynamic Disks.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.