29

Is it possible to use "Filesystem Passthrough" virtual hardware option inside virt-manager to share a folder on my Linux host with my Windows guest? I found some tutorials for how to do this with a Linux guest, but when I try this with my Windows guest I receive the following error message when attempting to start the VM:

Error starting domain: Unable to read from monitor: Connection reset by peer

Traceback (most recent call last):   File "/usr/share/virt-manager/virtManager/asyncjob.py", line 100, in cb_wrapper
    callback(asyncjob, *args, **kwargs)   File "/usr/share/virt-manager/virtManager/asyncjob.py", line 122, in tmpcb
    callback(*args, **kwargs)   File "/usr/share/virt-manager/virtManager/domain.py", line 1210, in startup
    self._backend.create()   File "/usr/lib64/python2.7/site-packages/libvirt.py", line 698, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: Unable to read from monitor: Connection reset by peer

I tried sourcing some documentation but all I could find was the official page linking to a FAQ and "some screenshots".

17

I don't believe this is possible using Windows guests. I usually setup a Samba server on the Linux KVM host and then share a folder out using that to my KVM guests.

Filesystem Passthrough

The documentation on sharing a KVM host's directory with the KVM guests (Linux) is available here on the virt-manager website. The page is titled: Example Sharing Host files with the Guest.

Setting up Samba

The linux-kvm website also contains directions for setting up Samba. That documentation is available here, titled: Tip: How you can share files on your Linux Host with a Windows Guest using Samba.

  • thumbs up for the "setting up samba" part. It is the safer approach – pqnet Aug 7 '14 at 0:46
  • @pqnet: could you please qualify how and why it's safer? – 0xC0000022L Jan 15 '16 at 23:33
  • 4
    @0xC0000022L because it does not depend on the virtualizator being able to trick effectively the guest operating system, which may break if the operating system change. Samba is a network protocol, thus the guest operating system has less expectation on what it can and it cannot do on it. – pqnet Jan 16 '16 at 16:56
  • The second link seems to be outdated. – colidyre Feb 24 at 17:47
  • @colidyre - ty updated. – slm Feb 24 at 18:27
6

Default file managers of both Gnome and KDE desktop environtment can easily access windows shared resources using SMB protocol.
You don't need to install a samba server on Linux host machine because Windows O.S. already comes with built-in samba communication protocols.

Let's say your guest O.S. is "Windows XP" for instance, choose the folder you want to share or just create one for that purpose, e.g. "hostshare" and right click on it -> "properties" -> "sharing" Tab -> select: "Share this folder on the network" and "Allow network user to change my files".

At this point be sure that windows' firewall gives access to shared file and printer resources. Go to "start Menu" -> "settings" -> "Control Panel" -> "windows firewall" -> "Exceptions" Tab -> select: -> "File and Printer Sharing".

Make sure that the Linux host machine can be seen from Windows guest V.M. through the network. So, from windows' command line type: "ping 10.0.0.12" where in this case (as an example) "10.0.0.12" is the host IP address; you have to change it to your own. If you do not have echo's responses you'll have to get into troubleshooting that.
And do the same thing from Linux command line: "ping -c3 192.168.122.216", where these numbers (as an example) belong to the virt-IP address assigned to the guest V.M.; you must change it to your own.

From Linux host machine open "Nautilus" and go to "File" -> "Connect to Server" -> Into "Server Address" box type: "smb/192.168.122.216" -> "Connect".
Nautilus window will open with the browseable resources of your windows built-in Samba server. You'll be able to see and access the "hostshare" windows folder's content. That's all!

2

I believe @slm has provided the best answer. HOWEVER, there is another use-case. This alternative is a bit of a hack, though.

Rough guide. Do not consider these definitive commands:

  1. create an image file (ms-dos floppy or ISO-9660 CD)
  2. format the image with a filesystem, e.g. mkfs.msdos
  3. copy and manipulate files on image as needed, such as with mcopy, et al
  4. mount image on Guest VM cd-rom or floppy drive

It's not ideal, but it can work if your Guest VM won't allow network protocol connections between dom0 and Guest (such as during a closed VPN session).

More info here:

https://stackoverflow.com/q/11202706/3407600

1

A read only share is possible (Windows guest has R/W, and Linux host can read only), since Linux host can mount NTFS on loopback device, suppose you use 'raw' type storage for the Windows guest:

Assume you have Win.img as the raw image, it is emulated as a disk.

  • Step 1: Find the offset of your file system (since it is a disk) using fdisk:
$ fdisk -lu Win.img

Disk Win.img: 16.3 GB, 16252928000 bytes
255 heads, 63 sectors/track, 1975 cylinders, total 31744000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3a793a79

    Device Boot      Start         End      Blocks   Id  System
    Win.img   *          63    31712309    15856123+   7  HPFS/NTFS/exFAT

Now, calculate the offset = 63 x 512 = 32256

  • Step 2: mount it
mount Win.img /mntpoint -o ro,loop,offset=32256

CAUTION

You can mount it RW, and thus Linux can write to it, but your file system will be corrupted! Because both your Linux and Windows are accessing the file system AT THE SAME TIME! They may allocate the same free blocks to write the files they want to write!

Linux read is not stable, in rare cases

With this method the file system is safe, and mostly OK to have stable read. However, as I said, they access the file system at the same time, and thus When windows tries to write something, Linux may not be informed, and thus read something corrupted. However, if you use it carefully, the read should be very stable.

  • 4
    How reliable is this? Data can be in caches. Writes will not be atomic with respect to reads on other system. – ctrl-alt-delor Jan 31 '15 at 23:52
0

I use Dokany+Win-SSHFS to mount remote folders over ssh. Let them to play the catch-up game, not the other way around <evil grin>

0

The solution of Andy worked for me, debian host and windows guest. Note that I have the spice-guest-tools installed with a special network driver from redhat.

In addition, I had to remove the password protection via smb Here at that link I found how to remove the password https://pureinfotech.com/setup-network-file-sharing-windows-10/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.