I have to make a configuration file available to guest OS running on top of KVM hyper-visor.

I have already read about folder sharing options between host and guest in KVM with 'qemu' and 9P virtio support. I would like to know about any simple procedure which can help in one time file transfer from host to guest.

Please let me know, how to transfer file while guest OS is running as well as a possible way to make the file available to guest OS by the time it starts running(like packaging the file and integrating with the disk-image if possible).

Host OS will be linux.

4 Answers 4


Just hit upon two different ways:

  • Transfer files via network. For example you can run httpd on the host and use any web browser or wget/curl to download files. Probably most easy and handy.
  • Build ISO image on the host with files you want to transfer. Then attach it to the guest's CD drive.

    genisoimage -o image.iso -r /path/to/dir
    virsh attach-disk guest image.iso hdc --driver file --type cdrom --mode readonly
    • You can use mkisofs instead of genisoimage.
    • You can use GUI like virt-manager instead of virsh CUI to attach an ISO image to the guest.
    • You need to create a VM beforehand, supply that VM's ID as guest. You can see existing VMs by virsh list --all.
  • Any standard network file transfer protocol should work, such as setting up an FTP or NFS server on the host.
    – bgvaughan
    Jun 2, 2015 at 10:41
  • 2
    Consider using scp or rsync which are often already available on both host and guest.
    – Lambert
    Jun 2, 2015 at 10:47
  • @bgvaughan I cannot access guest OS to run commands. I have to make those files available. So, I just cannot make host as a server to keep files in host and give access to guest. Thanks.
    – MVSR
    Jun 2, 2015 at 10:47
  • 1
    @MVSR You need to create a VM beforehand, supply that VM's ID as guest. You can see existing VMs by virsh list --all.
    – yaegashi
    Jun 2, 2015 at 10:52
  • @yaegashi Thanks. I ll look into it. I just figured it out and deleted the earlier comment. Please add the additional info in the answer and I will accept it.
    – MVSR
    Jun 2, 2015 at 10:56

Another easy way to do it before you start the guest is to simply mount the guest filesystem on the host, see here. Then you can just copy the files over to the mounted filesystem. For QCOW2 image for example you can do:

sudo modprobe nbd max_part=63
sudo qemu-nbd -c /dev/nbd0 <image_filename>.cow

then you can mount it by opening it up in a graphical file manager, or with the mount command.

  • Alternatively $ guestmount file.qcow2 /mnt/tmp Jun 7, 2021 at 16:30

Another way would be to use the guestmount utility

  1. Shut down the guest

  2. Mount guest disk guestmount -a ~/win10.vdi -m /dev/sda3 /mnt

  3. Edit guest files in /mnt

  4. Start guest


Another way is using an USB flash drive.

Virtual Machine Manager > Virtual Machine > Redirect USB device

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Sep 27, 2023 at 0:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .