How to Transfer files between Host and Qemu

I previously posted instructions to install and run nano and ARM Linux Internet Platform (ALIP) distribution images for Overo and Beagleboard on QEMU,

If the image support networking, you could use ssh (install dropbear server in qemu) or nfs to transfer files between the host computer and qemu, or even run your program from the NFS share. This should be possible to do that on the Overo emulator since it support Ethernet. However, although I can access Internet, I cannot access the host via ssh as the host is in a private subnetwork (192.168.0.0) and qemu in another (10.0.2.0). We would probably have to enable bridge networking for that but the tun driver is apparently not compiled in ALIP kernel. I’ll look into that later on. [Update: Finally, we don’t need tun/tap to make this work, please read http://www.cnx-software.com/2011/10/02/how-to-transfer-files-between-host-and-qemu-via-ssh-and-nfs/ for details.]

Today, I’ll just show how to mount a Qemu image and copy files as described on the “Updating Image Contents” section of https://wiki.linaro.org/Resources/HowTo/Qemu-beagleboard:

  1. Find the ext3 partition inside the image file:

    #fdisk -lu overo_sd_alip.img | grep overo
    You must set cylinders.
    You can do this from the extra functions menu.
    Disk overo_sd_alip.img: 0 MB, 0 bytes
    overo_sd_alip.img1   *          63      106494       53216    c  W95 FAT32 (LBA)
    overo_sd_alip.img2          106496     6291455     3092480   83  Linux

  2. Take the “start” number of the qemu image (106496) and mount the qemu image at this offset (start  multiplied by block size (512)):

    mkdir mnt
    sudo mount -o loop,offset=$[106496*512] overo_sd_alip.img mnt

That’s it. You should now be able to access the rootfs in mnt directory and transfer files between the host and the qemu image. Once you are done simply “umount mnt” and start qemu again.

 

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX Rockchip RK3588 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
1 Comment
oldest
newest
Harris
Harris
4 years ago

ok thnks

Boardcon Rockchip RK3588S SBC with 8K, WiFI 6, 4G LTE, NVME SSD, HDMI 2.1...