Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I need to know how I can mount block devices, placed on a qemu guest system, from host. So in this case we have NFS server placed on guest system and NFS client on the host's side.

There are a lot of examples, but I don't know what address to specify, while mounting folder located on qemu guest from host system.

mount root@localhost:/storage /mnt/storage -t sshfs -o port=2222*

works for sshfs, but not for NFS (can't recognize server name).

I used the following steps on the servers side:

  1. download and start nfs-kernel-server
  2. add /storage_nfs to exports
  3. exportfs -va

On the clients side:

  1. Download and install nfs utils
  2. Try to mount root@localhost:/storage /mnt/storage -t nfs -o port=2222 (qemu port) But it seems that root@localhost is invalid (but it works for sshfs).

How can I use qemu guest as nfs server?

share|improve this question

3 Answers 3

Update after reading all comments on all answers:

I see your problem at first place is bridged connectivity between Guest and Host while providing internet by NAT to guest. I will show how to do that too with few scripts on Fedora 20 HOST!! Scripts may be working for modern debian or may not!

On HOST machine, place this script in /root/ or wherever, replace INTERNET_INTERFACE with your eth0 or p5p1 or wlo1 or wlan0. if your home network is already using the network then change the address of br0 with something else like: ifconfig br0 up make the script executable and run it:

use vim or nano:
# nano /root/

tunctl -u $NORMAL_USER -t tap0
brctl delbr br0
brctl addbr br0
brctl addif br0 tap0
ifconfig tap0 promisc up
ifconfig br0 up
iptables -F
iptables -t nat -F
iptables -I FORWARD 1 -i tap0 -j ACCEPT
sysctl -w net.ipv4.ip_forward=1
service rpcbind restart
service rpcidmapd restart

# chmod +x
# ./

As a normal user on host start the virtual machine with (There is some magic in the command "qemu-kvm", it's not just qemu!)

$ qemu-kvm -cdrom ~/Downloads/flxde.iso -m 1200 -net nic -net tap,ifname=tap0,script=no

Ofcourse replace -cdrom with your -hda and path to your image, also -m 500 or whatever you feel, the improtant is the -net nic -net......... settings :)

From within Guest machine, bring up the internet(my network interface is ens3 on Fedora 20 Live Image,yours is eth0 probably):

# ifconfig eth0 up
verify you can ping before adding it as a gateway.
# ip r add default via
# echo "nameserver" > /etc/resolv.conf
# ping (verify NAT is working)

NFS related:

Common: Check connectivity with ping between host <-> guest

On the guest (having ip

# iptables -F
# service rpcbind restart
# service rpcidmapd restart
# service nfs restart
# vim /etc/exports
/freebsd *(rw,insecure,sync,no_subtree_check,no_root_squash)
# ls -ld /freebsd/
drwxrwxrwx. 4 root root 90 Feb 21 14:41 /freebsd/
# exportfs -var

on the host:

# service rpcbind restart
# service rpcidmapd restart
# mkdir /freebsd
# mount -o vers=3 /freebsd

Please let me know if something is clear enough :)

share|improve this answer

If you're running the NFS server from within the qemu virtual machine, (the guest), then you should be able to go into the qemu guest and run this command:

ifconfig -a

It should return output sort of like this:

eth0      Link encap:Ethernet  HWaddr 00:18:51:D4:AA:12  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::218:51ff:fed4:cc53/64 Scope:Link
          RX packets:31580565 errors:0 dropped:0 overruns:0 frame:0
          TX packets:28594026 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:22750768353 (21.1 GiB)  TX bytes:25277742297 (23.5 GiB)

The device id (eth0) might be something else entirely, but your results will hopefully contain output. This output shows the network devices configured in the qemu guest.

In particular you'll be most interested in the IP address of the qemu guest. It should show up in this output. In the example above that host's IP address is

With this information in hand you should be ablet to now use this IP address when setting up your NFS server and client.

share|improve this answer
I tried this: sudo mount /mnt/storage -t nfs -o port=2222 in this case console is just hanging – Alex Hoppus May 14 '13 at 7:25
i am sorry sudo mount /mnt/storage -t nfs – Alex Hoppus May 14 '13 at 7:59
it seems to me that this IP is behind the virtual interface, that you can't access it directly. No? – Alex Hoppus May 14 '13 at 9:02
That is entirely possible. Do you know what type of networking you're using when the qemu guest starts up? It will have names like: NAT, bridged, or something along those lines. You coud do a ps -eaf | grep qemu on the host too. Might be in the command line for qemu it self. – slm May 14 '13 at 9:47
I will answer tomorrow, because now i have no access to machine. how knowing of networking type will help? – Alex Hoppus May 14 '13 at 18:12

mount nfs server on guest is same as nfs server on general pc. You only need know the ip of nfs server.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.