+ Post New Thread
Results 1 to 13 of 13
Windows Server 2008 R2 Thread, Mounting virtual discs on startup in Technical; Apologies for what is probably a basic question, but my limited access to the machine in common means that I ...
  1. #1

    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    120
    Thank Post
    20
    Thanked 3 Times in 3 Posts
    Rep Power
    10

    Mounting virtual discs on startup

    Apologies for what is probably a basic question, but my limited access to the machine in common means that I need a high chance of getting it right first time.

    I wish to ensure that a virtual disk is mounted automatically on system startup.

    The virtual disk is on an external USB drive and will be used for Microsoft backup purposes. Performance is adequate when manually mounted.

    As the server mounting this drive is a Hyper-V server, it does not have USB access, so the virtual disk is also accessed via a file share.

    We need to use this method as to allow Microsoft backup on the virtual machine to use incremental backups, it needs to have a whole disc available and not just a partition.

    Thanks

    Ian

  2. #2

    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    120
    Thank Post
    20
    Thanked 3 Times in 3 Posts
    Rep Power
    10
    Anyone?

  3. #3
    dwhyte85's Avatar
    Join Date
    Mar 2009
    Location
    Berkshire
    Posts
    1,219
    Thank Post
    159
    Thanked 147 Times in 132 Posts
    Rep Power
    103
    If you kept it mounted using MagicDisc it holds it mounted after reboot - I use it myself on my home servers (and it's freeware).

    Re-read, now I see what you mean... but, you can connect to a 'local device' on the machine and it creates one of those... if you see what I'm getting at?
    Last edited by dwhyte85; 22nd November 2010 at 01:22 PM.

  4. #4

    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    120
    Thank Post
    20
    Thanked 3 Times in 3 Posts
    Rep Power
    10
    I have setup two files which perform what I intend, but I cannot get these to run when using the server scheduler functionality.

    I created a folder on the C drive called startup. This has full control, mod, r/e, r, w, list permissions for system and administrator and r/e,r for leo\users. Likewise, the following two files have the same:

    attach_vhd.cmd
    Code:
    diskpart /s c:\startup\attach_vhd.txt
    attach_vhd.txt
    Code:
    select vdisk file="\\griffin\daily backups\leo-backup.vhd"
    attach vdisk
    The server that I wish to mount this on is called 'LEO' and the server where the vhd is on is 'griffin'. Leo is a virtual machine, griffin is its host. 'Daily backups' is an external USB disc hosted on griffin and not directly accessible from leo, other than through a share.

    When I run attach.cmd directly, the disc mounts fine, but when I setup a scheduled task from the windows scheduler to run 'when the computer starts', it does not work, even if I run it now. I'm not sure where to look for any errors - could not see any in the event log.

    The scheduled task is set to run as administrator, whether or not the user is logged in or not. The admin password is set at time scheduled task is created. There are a couple of other options which I have tried the obvious.

    The command just sees to be always running in the scheduler until I stop and disable it.

    Thanks

    Ian

  5. #5
    chrisbrown's Avatar
    Join Date
    Aug 2010
    Location
    Melbourne, Australia
    Posts
    103
    Thank Post
    2
    Thanked 16 Times in 14 Posts
    Rep Power
    17
    Why not just mount the vhd as another HDD in HyperV?

  6. #6

    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    120
    Thank Post
    20
    Thanked 3 Times in 3 Posts
    Rep Power
    10
    Quote Originally Posted by chrisbrown View Post
    Why not just mount the vhd as another HDD in HyperV?
    To be honest, until you had said about a second VHD being mounted in hyper-V, I had not realised that it could be done. However, after giving it more thought...

    I don't think that a hyper-v machine will start if a virtual disc is missing, so because the external disc is on a removerable USB drive this may occur for a number of reasons.

    Also, I would rather have the flexibility to mount and dismount the disk while the virtual machine is running. If the disc is mounted on the fly, I believe that it would be simpler to detach and attach another, if it was attached outside hyper-V in the first place.

  7. #7
    chrisbrown's Avatar
    Join Date
    Aug 2010
    Location
    Melbourne, Australia
    Posts
    103
    Thank Post
    2
    Thanked 16 Times in 14 Posts
    Rep Power
    17
    Hi Ian,

    I don't use HyperV myself so I'm only drawing on my ESX knowledge. Could you perhaps mount the drive using PowerShell once the machine has booted?
    i.e. PseudoCode (bears no resemblance to real HyperV commands because I don't know them):
    Code:
    $vm = Get-VM "Server1"
    if ($vm.PowerState -eq "Running") {
        if (Test-Path "F:\DiskToattach.vhd") {
            $vm.MountDisk("F:\DiskToAttach.vhd")
        }
    }
    Theoretically you'd go:
    Is the machine on? (Yes). Is the vhd path accessible? (Yes). Mount the VHD.

    After Google: PowerShell Management Library for Hyper-V


    After re-reading this it makes little sense, so I'm really just spitballing. Home this helps in some way and doesn't just confuse you like it did me.

  8. Thanks to chrisbrown from:

    ianh64 (20th January 2011)

  9. #8

    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    120
    Thank Post
    20
    Thanked 3 Times in 3 Posts
    Rep Power
    10
    Hi Chris

    Thanks for your help. The code that I have above does actually work, but only if I manually run attach_vhd.cmd. The problem that I have is getting it to run on system boot or manually from the windows scheduler. I may then modify it to detect if disc is unmounted so that I can run it automatically just before the backup kicks off.

    -Ian

  10. #9
    chrisbrown's Avatar
    Join Date
    Aug 2010
    Location
    Melbourne, Australia
    Posts
    103
    Thank Post
    2
    Thanked 16 Times in 14 Posts
    Rep Power
    17
    Quote Originally Posted by ianh64 View Post
    The problem that I have is getting it to run on system boot or manually from the windows scheduler.
    Excuse my ignorance, as I said I'm not in a HyperV environment at the moment, but could you not just use this Action?
    screenshot_21-01-2011_8-40 AM.png

  11. #10

    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    120
    Thank Post
    20
    Thanked 3 Times in 3 Posts
    Rep Power
    10
    Chris

    That is exactly what I am using, but for whatever reason, it does not execute when invoked from the scheduler, either at startup, or manually triggered. It constantly goes into the running state until it is pre-empted and cancelled.

    I cannot see anything obvious log wise to see why it is not running. Not sure if/where the scheduler puts any log files.

  12. #11
    chrisbrown's Avatar
    Join Date
    Aug 2010
    Location
    Melbourne, Australia
    Posts
    103
    Thank Post
    2
    Thanked 16 Times in 14 Posts
    Rep Power
    17
    The Scheduler will dump into your event viewer, you can see this on the "History" tab in Task Scheduler. If you're using PowerShell to do this, I'd recommend throwing this command at the start of your script, it will log everything out to file:

    Code:
    Start-Transcript C:\mylog.txt

  13. #12


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    8,878
    Thank Post
    226
    Thanked 2,669 Times in 1,968 Posts
    Rep Power
    786
    Quote Originally Posted by ianh64 View Post
    I don't think that a Hyper-V machine will start if a virtual disk is missing, so because the external disk is on a removable USB drive this may occur for a number of reasons.
    Would it not be a lot easier to store the VHD you backup to on your host (or SAN), permanently mount it within the guest (Leo) and then robocopy the files which are created/modified by Windows Server Backup over the network to a folder on the USB HDD connected to the host (Griffin)? This way, you don't have to mess around with attaching and detaching VHDs?

    Quote Originally Posted by ianh64 View Post
    When I run attach.cmd directly, the disk mounts fine, but when I setup a scheduled task from the windows scheduler to run 'when the computer starts', it does not work, even if I run it now. I'm not sure where to look for any errors - could not see any in the event log.
    When the scheduled task runs the diskpart script, perhaps the volume inside the VHD is off-line and read-only?

    In fact when Hyper-V mounts the disk it doesn’t bring it on-line and flags it read only, so the PowerShell code I wrote not only had to call the WMI functions provided by Hyper-V's Image Management Service, but it also needed to invoke DiskPart.exe with a script to get the disk to a useful state. (Source)

  14. #13

    EduTech's Avatar
    Join Date
    Aug 2007
    Location
    Reading
    Posts
    5,062
    Thank Post
    160
    Thanked 920 Times in 723 Posts
    Blog Entries
    3
    Rep Power
    272
    I know this of no help what's so ever!

    but you would think that it would just be as simple as storing the VHD on the Hard Disk, Mounting the Volume and then editing the Boot.INI file so that it knew what to do.

    I've had a play with this before, never really picked it up since #fail

SHARE:
+ Post New Thread

Similar Threads

  1. Multiple virtual discs
    By djones in forum Thin Client and Virtual Machines
    Replies: 20
    Last Post: 25th May 2010, 09:38 AM
  2. Virtual PC startup boot
    By Darryl_Wilcox in forum Thin Client and Virtual Machines
    Replies: 4
    Last Post: 14th January 2010, 11:49 AM
  3. Windows Discs
    By chrisredfield93 in forum General Chat
    Replies: 1
    Last Post: 15th May 2009, 05:12 PM
  4. Mounting CD ISO in to virtual PC 2007
    By alextreadwell in forum Thin Client and Virtual Machines
    Replies: 8
    Last Post: 15th May 2009, 02:53 PM
  5. No more scratched discs
    By EduTech in forum General Chat
    Replies: 2
    Last Post: 6th October 2007, 06:52 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •