How to Transfer files between the Host and Qemu via SSH and NFS

Last week, I wrote a blog post explaining how to copy files to a qemu image by mounting the qemu image in the host. This is only useful if emulated platform does not support networking.

If networking is enabled, using SSH (Secure Shell) or NFS (Network File System) is more convenient.

Using SSH with Qemu

To initiate the SSH connection from qemu, there is actually nothing extra to do as long as you have sshd installed and running on the host. If it is not installed simply run  sudo apt-get install openssh-shell on the host. This will install and automatically sshd.

To initiate the SSH connection from the host, you’ll have to redirect the ssh port to an unknown port and start qemu as follow (for overo):


Please refer to Beagleboard Emulator in Ubuntu with Qemu for the detailed instructions on how to setup qemu to emulate beagleboard or overo (OMAP3 Platforms)

Then install dropbear – a lightweight SSH server – in qemu:


This will also start dropbear automatically.

Once this is done, you can access qemu from the host as root or another user you may have added (Please note that 192.168.0.101  is the IP of the host):


 

If you do not wish to enter the password each time you connect, follow the instructions at No password SSH – Login to a SSH server with private/public keys

No SSH access is working fine, simply use scp to copy files between the host and qemu, for example:

Using NFS with Qemu

You can basically follow the instructions given on Setting Up an NFS Server on Ubuntu to configure the host, with the difference that you’ll need to add the insecure option or the NFS connection will be denied (NFS4ERR_PERM) as  the insecure option allows to use IP ports that are above 1024. So the /etc/exports file would look like:


Once the NFS server is configured on the host, you should be able to mount the NFS share in qemu:


 

 

 

Share this:

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

Radxa Orion O6 Armv9 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.
3 Comments
oldest
newest
Boardcon CM3588 Rockchip RK3588 System-on-Module designed for AI and IoT applications