Why is folder sharing between host and guest in KVM so hard?

I’m having the hardest tine setting up a shared folder between a Linux host and Win11guest. I want to get rid of dual boot, but there are a few programs that I use which are Win only. I have set up a VB VM, but I want a fine tuned KVM VM. On VB sharing is trivial, but I can’t get it to work in KVM. I have the host sharing the folder with Samba, and can see it from another Linux VM, but not from windows. Any clues?

82cb5abccd918e03,

Back when I had to use a windows vm just did


<span style="color:#323232;">qemu ... -net user,smb=$HOME/
</span>

then in the windows vm just type \10.0.2.4 into file explorer. Does that not work?

man qemu says:


<span style="color:#323232;">              smb=dir[,smbserver=addr]
</span><span style="color:#323232;">                     When using  the  user  mode  network  stack,  activate  a
</span><span style="color:#323232;">                     built-in  SMB  server  so that Windows OSes can access to
</span><span style="color:#323232;">                     the host files in dir transparently. The  IP  address  of
</span><span style="color:#323232;">                     the  SMB server can be set to addr. By default the 4th IP
</span><span style="color:#323232;">                     in the guest network is used, i.e. x.x.x.4.
</span><span style="color:#323232;">
</span><span style="color:#323232;">                     In the guest Windows OS, the line:
</span><span style="color:#323232;">
</span><span style="color:#323232;">                        10.0.2.4 smbserver
</span><span style="color:#323232;">
</span><span style="color:#323232;">                     must be added in the file C:WINDOWSLMHOSTS (for windows
</span><span style="color:#323232;">                     9x/Me)  or C:WINNTSYSTEM32DRIVERSETCLMHOSTS (Windows
</span><span style="color:#323232;">                     NT/2000).
</span><span style="color:#323232;">
</span><span style="color:#323232;">                     Then dir can be accessed in \smbserverqemu.
</span><span style="color:#323232;">
</span><span style="color:#323232;">                     Note that a SAMBA server must be installed  on  the  host
</span><span style="color:#323232;">                     OS.
</span><span style="color:#323232;">
</span>

Another way is to setup Spice and use a webdav daemon in Windows to transfer files over Spice folder sharing.

You could also just RDP to the machine which is probably the easiest.

The simplest would just be to scp files to and from Windows. Like in powershell do scp -R yourusername@10.0.2.2:~/path/stuff output_dir to get files from Linux.

ebd6a8c9051028dc1607,
ReversalHatchery,

I have the host sharing the folder with Samba, and can see it from another Linux VM, but not from windows

Do you mean that it’s not automatically detected, or that you can’t connect to it even by name?

What I use for folder sharing is virtiofs. It’s very similar to how vmware solves this. It does not need a shared network connection or anything, it’s a bit like if you passed through a speaker or a graphics card.
No idea how it would be configured in your setup as I use it with proxmox, but if your setup runs a qemu command, you can edit its parameters, and you can set up a command that runs every time before the vm is started with that qemu command, I may be able to help you set it up, you just need to reply here telling that.

d3Xt3r, (edited )

First of all, forget all the Spice-based viewers - by far the best solution for interacting with a Windows guest is using freeRDP. It’s extremely smooth and lightweight, and feels like you’re interacting with Windows natively - unlike Spice viewers which feel very clunky. With freeRDP, you don’t need to configure Samba etc, clipboard sharing works, dynamic resolution works, and you can even use seamless windows (RemoteApps) to make it look like you’re natively running a Windows app in Linux!

Just enable Remote Desktop in Windows, and then from your host machine, you can run the following command to connect to your VM:

xfreerdp /v:192.168.122.xxx /u:dexter /p:password /drive:/home/dexter/Downloads,Downloads /cert:ignore /dynamic-resolution +clipboard /scale:180 /f

  • Obviously, change the above parameters according to your system.
  • Setting a static IP inside Windows would also make it easier, so you can just create a shortcut/script with the above command.
  • In my above command, I’ve shared my Downloads folder. This will appear in Windows as the share \tsclientDownloads. You can then map this share to a drive inside Windows to make it easier to access.
  • I’m on a HiDPI monitor so I’ve enabled scaling with the /scale:180 parameter.

Alternatively, you could use a GUI tool like Remmina, which uses freeRDP in the backend.

I also highly recommend using freeRDP v3.x if possible - this is available in Arch (AUR) and Flatpak. The reason being, freeRDP has made numerous improvements since v3.0 (released December last year), which make it 100% worth the upgrade - but most distros seem to be stuck on 2.xx for some reason.

Let me know if you have any questions. I use Win11 guests on KVM almost daily for testing various things as part of my job, and I access it via freeRDP without any issues.

flashgnash,

I had thought spice was supposed to be really good for VMs, it’s it just over hyped?

helenslunch,

there are a few programs that I use which are Win only

Have you tried Bottles/WINE/Proton/whatever?

elucubra,

Some people have, with not great results. The software is the Affinity suite (design, photo, publishing, and I have used Inkscape, Gimp, and Scribus, but they aren’t there yet for me) A windows VM is fine for now, but VB is a bit sluggish. My aim is to set-up a physical partition for the VM, and try GPU passthough.

progandy,

There is or was a project called WinApps i think that made it easy to set up a VM to run some applications.

tutus,

I ended up going to VMware Workstation as it just works. I could never get KVM to share between Linux and Windows host / guest no matter what I tried. Samba wasn’t an option for me to use.

I’m really glad there seems to now be a potential solution in wsdd2.

Kid_Thunder,

You can use Gnome Boxes to give you a front-end for KVM/qemu like VB. With the spice-webdavd package, you can share files similarly to the guest or send files directly to it.

As far as Samba goes, it is just a FOSS implementation of Microsoft's SMB. Just like with Windows, you'll have to open Explorer to the IP/Hostname of your Samba server or I guess have both join the same workgroup with the same name on the same subnet.

elucubra,

Thanks. I’ll try.

minimalfootprint,

I used this Guide (KVM +qemu) in a previous installation. I’m an intermediate Linux user and got it working without much trouble. Maybe it will fit your use case

elucubra,

Thanks

bizdelnick,

The native directory sharing method for kvm is virtiofs. Have you tried it?

nyan,

The method of last resort would be to place the files you want shared on a virtual drive that you pass to the Windows guest, then mount that virtual drive as a loopback device under Linux. I have only done this for very old versions of Windows that can’t talk to normally configured current versions of Samba, so I don’t know how it will behave with 11—simultaneous access doesn’t really work with my Win 98SE guest, but the method is adequate for passing files back and forth.

(The person who suggested wsdd2 is likely right on the money, though—a Samba share won’t be browsable without it from modern Windows, although you may still be able to connect to it blind if you know the address. Problem is, in my experiences with Samba, the address was usually not quite what I expected . . .)

elucubra,

I have considered using an external NVME I have in a USB case, but It’s a clunky workaround.

dukatos,

VB uses guest addons - driver to enable file sharing. Not sure something like that exists in qemu…

elucubra,

There are, and they are installed

Bitrot,

VirtIO drivers, but they wouldn’t affect file sharing over the network as OP is doing.

UntouchedWagons,
@UntouchedWagons@lemmy.ca avatar

Where are you expecting to see the host in windows? In the Network window? If so you’ll want to install, enable and run wsdd2

lemmyreader,

Interesting, thanks. Has just landed in Debian btw packages.debian.org/bookworm/wsdd2

elucubra,

Will try. Thanks

lemmyreader,

I think Linux does not care about WORKGROUP (etc.) and hostname from a Samba server point of view but Windows perhaps does. Check the Samba log files to see whether Samba complains. Samba usually creates lots of log files, just find the ones you need to read.

catloaf,

Sounds like a network issue, not a KVM issue. Have you done any troubleshooting from that angle, and if so, what have you found?

elucubra,

I suspect that there is something like that, since the Linux VM can access the share

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux@lemmy.ml
  • DreamBathrooms
  • magazineikmin
  • InstantRegret
  • GTA5RPClips
  • ethstaker
  • Youngstown
  • everett
  • slotface
  • osvaldo12
  • rosin
  • mdbf
  • kavyap
  • thenastyranch
  • ngwrru68w68
  • megavids
  • Durango
  • modclub
  • cubers
  • khanakhh
  • Leos
  • tacticalgear
  • cisconetworking
  • vwfavf
  • tester
  • anitta
  • normalnudes
  • provamag3
  • JUstTest
  • All magazines