[TUTORIAL] Copy files between Host and a VM by using 9p (to/from Linux for now...)

UdoB

Distinguished Member
Nov 1, 2016
1,824
700
183
Germany

How can I copy files between the PVE Host and a VM?​

There are many ways, ssh/sshfs being the recommendation usually. One possible alternative does not need a network: 9p.
  • this is for temporary usage e.g. maintenance or initial setup. 9p is local, so the VM can not migrate anymore
  • for this reason I simply use “root”, which generally is not a good advise for “normal” day-by-day usage
  • and: this approach is not supported officially
For this article:
  • on the host exists some folder with data, I chose /tmp/hoststorage
  • it is okay to have data in it, we do not destroy anything

On the host​

While the VM is turned off add this single line manually to your /etc/pve/local/qemu-server/<vmid>.conf file:
Code:
args: -fsdev local,security_model=passthrough,id=fsdev0,path=/tmp/hoststorage  -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare
Now start your VM.

Linux Guest​

The guest should start as usual, everything should work normal. Open a root shell and run:
Code:
mkdir /mnt/host
mount -t 9p -o trans=virtio,version=9p2000.L hostshare /mnt/host
That’s all. You can read and write files using any file manager you want. On the host all of them are owned by root.

Windows Guest​

No success for me :-(
Seems to be missing: https://github.com/virtio-win/kvm-guest-drivers-windows/issues/126
Is this a valid attempt? https://virtio-fs.gitlab.io/howto-windows.html -- no: “Virtio-fs and virtio-9p are two different two different devices serving the same purpose from user point of view.”

References​



Side note: we need a place for FAQs like this, just to find them easier...
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!