none
Copied files showing up in VHD attached to host but not when I run the VM

    Frage

  • Hi All

    I've got this strange error that's crippling my lab work.  My setup is:

    win 2008 r2 host vhd I'm booting into with the hyper-v role

    I used to transfer files by mounting the VHD of the VM through disk mgmt.  But now I can do that - I copy the files over - see them there.  But when I start up the VM they're not there.  Its consistent when I mount the VHD in the host again they are there. 

    Can anyone help - alternatively does anyone have another simple way of transferring files from host to guest.

    Montag, 5. März 2012 04:06

Antworten

  • It sounds as if your VM is running from a differencing disk or snapshots and you are mounting the base VHD.

    In this case your VM might or might not 'see' the files that you copy to the root VHD if the differencing disk or snapstho is not re-set.  This has to do with how differencing disks work - at the sector level, not the file level.

    And, if the VM was running when you did this, this would most likey be the scenario of what happened.

    If the VM has a single VHD and you power off the VM, then mount the VHD, then copy the files, then dismount, then power on the VM I would expect the files to be visible - again, the VM must have only one VHD, no differencing disks, no snapshots.

    An alternate method is to create a Second VHD.  Create a differencing disk off that for each VM.  And then mount this diffeencing disk to each VM - the VM ends up with an "E:\" for example.  If the VM only needs to read it can do that just fine out of the disk chain and you can mount this root VHD and copy and modify files.  If the VM ever writes back to the differencing disk you may mask what is in the root.  The key here as that this is all read only for the VMs and write for you from the host.

    The other method is over the network.


    Brian Ehlert (hopefully you have found this useful) http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.

    Montag, 5. März 2012 16:02

Alle Antworten

  • The easiest method of transferring files from host to guest is the use the networking stack.  Just share a folder on your 2008 R2 host and connect from your VM.  Likewise, you go in the opposite direction.
    Montag, 5. März 2012 04:22
  • Hi,
     
    If you want to mount the VHD of the virtual machine in Disk Management on Hyper-V host machine, you need to power off the virtual machine.
     
    By the way, do those files have hidden attributes?  Do you have “Show hidden files, folders, and drivers” enabled on Hyper-V host machine but not within the virtual machine?
     
    In addition, as Darien mentioned, you can just think the virtual machine as a physical machine, then you can share files among it and other computers.
     

    Vincent Hu

    TechNet Community Support

    Montag, 5. März 2012 06:04
  • It sounds as if your VM is running from a differencing disk or snapshots and you are mounting the base VHD.

    In this case your VM might or might not 'see' the files that you copy to the root VHD if the differencing disk or snapstho is not re-set.  This has to do with how differencing disks work - at the sector level, not the file level.

    And, if the VM was running when you did this, this would most likey be the scenario of what happened.

    If the VM has a single VHD and you power off the VM, then mount the VHD, then copy the files, then dismount, then power on the VM I would expect the files to be visible - again, the VM must have only one VHD, no differencing disks, no snapshots.

    An alternate method is to create a Second VHD.  Create a differencing disk off that for each VM.  And then mount this diffeencing disk to each VM - the VM ends up with an "E:\" for example.  If the VM only needs to read it can do that just fine out of the disk chain and you can mount this root VHD and copy and modify files.  If the VM ever writes back to the differencing disk you may mask what is in the root.  The key here as that this is all read only for the VMs and write for you from the host.

    The other method is over the network.


    Brian Ehlert (hopefully you have found this useful) http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.

    Montag, 5. März 2012 16:02
  • Thanks All

    Looks like networking is the go.  As a hyper-v newbie I'd avoided this.  Do you have any good links on the simplest way to set this up.

    My setup is my lab VMs are on a 10.0.0.x subnet.  My host is on a 192.168.1.x subnet to get internet from my router.  How do I setup the routing between them?

    Freitag, 9. März 2012 19:28
  • BTW they do have snapshots so that Brian was correct.
    Freitag, 9. März 2012 19:29
  • Ouch - I'm used to using vmware workstation which has host/guest sharing built-in.  According to this thread you have to use RRAS: http://social.technet.microsoft.com/Forums/en-US/winserverhyperv/thread/2c86f04f-19c0-4587-a6e2-ca686b9c8b4d/

    Before I go down the rabbit hole is that really the case?

    Freitag, 9. März 2012 20:09
  • RRAS is not necessary at all.  Yes you can hack it in, but no reason to.

    The Hyper-V is not VMware Workstation (it is far closer to ESX which also does not have ways to perform similar hooks.)

    The VM and host can share over the wire - just like any two machines over the wire.  They can also share using a virtual disk or vurtual floppy to transfer files into and out of.

    In fact, if your sharing method is one way you can just keep a VHD mounted on the host to write in to and use a diffferencing disk on the client side to read out from.  You would need another set of disks to go the other way.

    Most folks just go over the network


    Brian Ehlert (hopefully you have found this useful) http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.

    Freitag, 9. März 2012 21:05
  • Thanks Brian - that's good news.  Currently if I ping from a guest I get 'destination unreachable' how do I set this up?

    Freitag, 9. März 2012 21:39
  • If both machines are on the same subnet - it should just work.

    If you create an Internal Virtual Switch and attach the VM to it you will need to manually configure an IP for both the host and VM on this network segment - there is no type of DHCP built in.  And then ping using these manually assigned IP addresses.

    Also, be aware that with Server 2008 and newer responding to ping is disabled by default.  You actually need to turn it on.

    netsh advfirewall firewall set icmpsetting 8

    The other option is to totally disable all firewall profiles.


    Brian Ehlert (hopefully you have found this useful) http://ITProctology.blogspot.com
    Learn. Apply. Repeat.
    Disclaimer: Attempting change is of your own free will.

    Freitag, 9. März 2012 22:18
  • No the host is on a 192.168.1.x net - guests are on 10.0.0.x - that's why I thought I'd need routing.
    Freitag, 9. März 2012 22:47