Automatically attach Virtual Hard Disk (VHD) on system startup

VHD can be used for many different purposes. For example, in this article I explained how to expand Windows 8 tablet or ultrabook storage by adding folders on a removable Micro SD cards to Windows Libraries.

One limitation of Windows VHD implementation is that there is no option to automatically mount VHD image on system startup. Luckily this can be easily achieved via vdisk utility and Scheduled Tasks.

  1. Create a plain text file with following text:
    select vdisk file="D:\VirtualDisk.vhd"
    attach vdisk
    assign letter=E
    Create attach VHD file
    Where:
    D:\Virtual Disk.vhd - path to your VHD disk image
    E - drive letter you want to your VHD drive to be mounted to.
  2. Save the file somewhere on your system. i.e. C:\cripts\Attach VHD.txt
  3. Launch Windows Task Scheduler > Actions >  Create Task
    Windows Task Scheduler - New Task
  4. Configurre the new task:
    • General Tab
      • Provide Name and optionally Description
      • Check -¬†Run whether user is logged on or not
      • Check - Run with highest privileges
    • Triggers Tab
      • Add new trigger "At Startup". Leave other options as they are.
    • Actions Tab
      • Add New action
        • Action: Start a program
        • Program/script: diskpart
        • Add arguments: /s "C:\Scripts\Attach VHD.txt"
          Where: "C:\Scripts\Attach VHD.txt" - path to the text file you saved in step 2.
    • Conditions Tab
      • Remove checkbox from "Start the task only if the computer is on AC power"
    • If required modify other options and click OK.
    • Provide your Windows credentials if prompted.

Now your VHD disk should be mounted automatically every time the computer boots. You can test if mounting works by un-mounting your VHD image and running the task manually.

Windows 8

Comments  

Brian
# Brian 2015-09-07 04:25
Please help me on this. Neither of these suggestions work. My vhd is a vhdx and it is on a micro SD card on my surface pro 3. It needs to mount before onedrive opens and says it doesn't exist (big pain to reconnect)
kevin
+1 # kevin 2013-12-03 04:40
I have found so many different methods of accomplishing this task and read more "That didn't work when I tried it" comments than I can count.
Having tried multiple times I finally came across a post that had it RIGHT...and almost as important - SIMPLE. Not saying above won't work - it didn't for me but I am not exactly a pro! I wish I had made a note of the site but I was using a friends Ultrabook -so my apologies (and thanks) to the original creator.

Set up automatic mounting on system startup. -Win+W, type Schedule Tasks, enter. In the tree on the left side,click on "Task Scheduler Library"
-From the "Actions" pane, click on "Create Task"
Enter "mount D:\disk.vhd" (or anything you'd like) as the task name. Likewise description is optional -Select "Run whether user is logged on or not" Check "Run with highest privileges" -In Triggers tab, click New, select "At startup" and press OK.
-In Actions tab, click on New. Select "Start a program" as Action. In program/script, put "C:\Windows\Sys tem32\WindowsPo werShell\v1.0\p owershell.exe."
In add arguments, write exactly
"-command "mount-diskimag e D:\disk.vhd""
-In Conditions tab, uncheck everything. Press OK
Enter your Windows password and press OK. That's it!
Restart the system and see if your new drive is visible after login.

Set up Windows Indexing.
Win+W, type Indexing Options, enter Click on modify, check the new vhd drive (probably E).
OK, Close.
You can now create folders in the mounted vhd and add them to library.
I hope this help everyone else as much as it did me!

Newsletter

Subscribe to receive occasional updates on new posts.
Your email will not be used for any other purpose and you can unsubscribe at any time.
Please wait