Make windows unmount a specific partition when hibernating

6

1

Could I possibly trick windows in to thinking it's a flash drive? I dual boot, this would be really nice to have.

Aido

Posted 2015-08-03T16:40:26.477

Reputation: 239

Answers

2

You could make Windows un-mount a mount point and then hibernate with a simple batch script:

mountvol Path /d
shutdown /h /f /t 0

where Path is the full path to the mount point.

Once the script is created, make a shortcut to it in the Start menu (assuming you use it) and set a keyboard shortcut so that you can run it with a couple of key-presses.

See more on the mountvol and shutdown commands. Note that Windows 8 has deprecated and hidden hibernate, and you may need to enable and fix it.

DrMoishe Pippik

Posted 2015-08-03T16:40:26.477

Reputation: 13 291

2Is there a way to make it happen automatically before fastboot? – Aido – 2015-08-03T18:05:15.903

See shutdown command-line switches. Above. /h is hibernate. – DrMoishe Pippik – 2015-08-03T19:17:40.570

1

@DrMoishe Pippik's answer was almost there, but there was a few things he missed.

To unmount the partition (so you can write to it from another operating system), you must use mountvol.exe's /P tag. This tag Removes the volume mount point from the specified directory, dismounts the volume, and makes the volume not mountable. In @DrMoishe Pippik's answer /D only Removes the mount point from the specified directory, and is why after using his commands, the partition I wanted to unmount was still locked by Windows.

Second of all, you want mountvol.exe to run to completion before hibernation is triggered. To do this we use START /WAIT.

Shortcut properties showing 'Run as administrator' option

Lastly, to unmount a partition, you must have Administrator permissions. You can do this, but creating a shortcut of the batch file below, and tick Advanced > Run as administrator on the Shortcut panel.

So, this is what the hibernate script should look like:

START /WAIT mountvol.exe <DRIVE LETTER> /P
shutdown /h

For hybrid shutdown, you may use:

START /WAIT mountvol.exe <DRIVE LETTER> /P
shutdown -hybrid -f -t 00

In Windows 8 you can access this from your Start Menu by placing this shortcut in your C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs directory, or globally, C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs.

Start menu showing hibernate mount/unmount icons.


To remount the drive after you have come out of hibernation, you will need a Mount shortcut as well. This will look like:

mountvol <DRIVE LETTER> <VOLUME ID>

To find the volume ID of your partition, type mountvol into cmd. This shows a list of the partitions in your computer. If you have already unmounted the drive you are wanting to re-mount, it may say *** NOT MOUNTABLE UNTIL A VOLUME MOUNT POINT IS CREATED *** underneath it (as shown below).

enter image description here

joeeey

Posted 2015-08-03T16:40:26.477

Reputation: 1 396

That's a pretty nice answer! I ended up formatting it to exFAT, which I can access from Ubuntu or Windows, and Windows doesn't giver it hiberfiles. – Aido – 2016-05-20T19:11:33.107