2

Story so far

We recently migrated from Linux laptops to Macbook Pro laptops (company IT no longer supports native Linux laptops with VPN, so it's all Macbook/OSX devices for us). However, all of our development requires the use of Ubuntu and Debian, so we're running everything in virtual machines. Our plan is to use QEMU (with the appropriate hardware acceleration via hvf) to easily spin up VMs on-demand. We are able to successfully launch our VMs via something like this:

qemu-system-x86_64 \ -m 4096 \ -smp 4\ -accel hvf \ -show-cursor \ -drive file=/public/my_os_disk.qcow2,if=virtio \ -net user,hostfwd=tcp::8022-:22 \ -net nic 

This starts up our VM (Ubuntu) instance with 4GB of RAM, 4 cores, hardware acceleration, and allows us to ssh into the VM (port 22 from the VM's perspective) via ssh -p8022 username@localhost.

Question

How can we setup an NFS server on the Linux guest so that our Mac/OSX host can share files? If the host were also Linux, we could use virtfs like we used to, but it seems our solution must involve networking. We've setup NFS server on the Ubuntu VM (using common articles, 1, 2). We then setup the QEMU launcher script to enable the NFS ports (i.e. 111, 2049), like so:

qemu-system-x86_64 \ -m 4096 \ -smp 4\ -accel hvf \ -show-cursor \ -drive file=/public/my_os_disk.qcow2,if=virtio \ -net user,hostfwd=tcp::8022-:22,hostfwd=tcp::2049-:2049,hostfwd=tcp::111-:111 \ -net nic 

On the Mac host (or OSX host), we attempt to mount the NFS share (assuming the Linux guest is exporting the /export_from_linux path on the the 10.0.100.0/24 subnet) via:

mount -t nfs localhost:/export_from_linux /my_mac_mount_path 

However, this just hangs indefinitely.

What is the best way to (preferably using NFS) establish a means of sharing files between a Mac/OSX host, and a Linux/Ubuntu guest running in QEMU?

1
  • I can add that I did what you did BEFORE the actual question, and it worked for me (I only needed to be able to connect to the VM using ssh) so thanks for your "first half" of your question :) Commented Feb 11 at 13:54

1 Answer 1

0

You do not need to hostfwd 111, just 2049, or alternatively you can use a map from 8049 to 2049; as 2049 might be occupied on the macOS system.

So at minimum, you will need to have QEMU create a mapping for the alternate NFS port:

-netdev user,hostfwd=tcp::8049-:2049 

Now you can mount NFS on port 8049 on the macOS side; say, to a Debian NFSv4 server:

sudo mount -o port=8049,vers=4,resvport -t nfs 127.0.0.1:/export_from_linux /my_mac_mount_path 

Note that we are using an option to enforce vers=4 on the macOS side (and you should be running an NSFv4 compatible server on the Linux side; i.e. Debian 11's nfs-kernel-server.

BUT the main key here is the resvport setting. For whatever reason, macOS would not mount without this setting.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.