WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [mini howto] setting up USB storage for 2 way transfers (Large Files mainly)  (Read 1218 times)


  • Guest

I am completely new to this qemu stuff. I was looking for a way to transfer very large files such as unpacked kernel source without using a network.

One way is to use an usb stick. Copy the files from the host, umount the usb stick and launch the qemu guest such that you have a match for your usb details. I have tested copy from and paste to this usb stick

My ref was

my result as an image showing mount tool and file manager

My steps
1 Depending on whether you have an udev rule or a file manager that automounts inserted media, DISABLE that for use with this method please
2 Insert usb storage stick and do not mount
Code: [Select]
tce-load -i usb-utils && lsusb4 Note the usb details mine were Bus 002 Device 002: ID 090c:1000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Flash Drive
We only care about Bus and Device numbers.
In example below the order is bus then hostaddr
5) launch qemu (in example I am launching TC32 bit) and change your numbers to suit
Code: [Select]
qemu-system-i386 -enable-kvm -hda vdisk.img -m 4G \
> -device usb-ehci,id=usb,bus=pci.0,addr=0x4 -device usb-host,hostbus=2,hostaddr=2

Its easy to see hostbus will be bus so hostaddr must be Device
6) Inside guest qemu session use mount tool to mount usb device if your file manager/guest udev rule does not automount


Just tested umount in guest...pull stick and re-insert it
It got a new (host) device number so I will need to reboot guest, with updated numbers to use stick again this host session
« Last Edit: September 24, 2023, 08:56:51 AM by aus9 »

Offline nick65go

  • Hero Member
  • *****
  • Posts: 805
My solution: in linux, just make a "disk" (of say 4-10 GB, aka 2 DVD size) from nothing, with ""dd". Format it like ext2, then use it in qemu as a disk.

1. for exporting files from VM: if is empty, use it to populate it from qemu.
2. for importing files into VM: first mount it in linux, populate it with files (kernel source, whatever) and then use it in qemu.

FYI: of course you need to un-mount it BEFORE any use in/out of qmeu. But no need to buy a USB stick, if your HDD space is big, plus the USB speed is lower than a HDD speed.PS: if using NBD (net block disk) you can "share" this disk from host to guest, with RW access, etc. [even with "disk" as local file, not on network].
« Last Edit: September 24, 2023, 10:18:34 AM by nick65go »