GNS3 / gns3-server

GNS3 server
GNU General Public License v3.0
796 stars 262 forks source link

File transfer to QEMU #2407

Open z5241248 opened 1 month ago

z5241248 commented 1 month ago

For Docker, we can use the command "docker cp" to transfer files to a container. But for QEMU, how do we do it without using the cloud?

I tried using a shared folder (mount -t 9p…), but it's not the best way because I need to execute the command to mount the shared folder in the QEMU system every time it starts. Furthermore, mounting a shared folder doesn't seem to work with Windows systems.

Do you have a good way to transfer files without using the cloud?

grossmj commented 1 month ago

Do you have a good way to transfer files without using the cloud?

Have you found a way to do it?

z5241248 commented 1 month ago

Do you have a good way to transfer files without using the cloud?

Have you found a way to do it?

First, please forgive me if there are some mistakes in my grammar

I found a way to make it work. Still mount external folder.

For Linux Qemu

You can mount a shared folder like following content. Add the command when the Qemu starts:

qemu-system-x86_64 … -virtfs local,path=/mnt/shared,mount_tag=host0,security_model=passthrough,id=host0

And then, you should create a new folder in the system:

mkdir -p /mnt/shared mount -t 9p -o trans=virtio,version=9p2000.L host0 /mnt/shared

For Windows Qemu

I tried to using Samba, it works.

You can refer this link, it's from Qemu official: https://www.qemu.org/docs/master/system/invocation.html#hxtool-5

First, you should install the Samba server in your host system.

And then, add the command when the Qemu starts:

-nic user,id=nic0,smb=/share_directory

There is a example

qemu-system-x86_64 -name win7-Lite-1 -m 2048M -smp cpus=1,sockets=1 -enable-kvm -machine smm=off -boot order=c -drive file=/data/gns3/data/GNS3/images/QEMU/win7-Lite.qcow2 -vnc 0.0.0.0:2 -nic user,id=nic0,smb=/opt -machine usb=on -device usb-tablet

When you start your Windows Qemu system, you should check your ip address.

image

And then, adding a Network mapping.

Samba uses the x.x.x.4 address by default, the qemu official document also mention it. image

image

If it succeeds, a new hard drive will appear.

image