Mounting NFS filesystem exported by Linux host ?

Discussions about using Linux guests in VirtualBox.
Post Reply
Nicholas Yue
Posts: 6
Joined: 4. Jan 2020, 20:45

Mounting NFS filesystem exported by Linux host ?

Post by Nicholas Yue »

I am running a Linux Guest on a Linux Host

I have exported an NFS filesystem on the Linux host

What is the recommended way to mount the Linux Host exported NFS filesystem from within the Linux Guest ?

Do I need to add additional network adaptor ? What type should I add (is Host-only adapter suitable) ?

Cheers
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Mounting NFS filesystem exported by Linux host ?

Post by mpack »

How do you "export" a host filesystem?

Are you referring to a shared folder? If so then how did you do the share? I.e. are you talking about the VM's Shared Folders settings, or did you enable a share using host networking?

If VM settings share: that feature requires the Guest Additions to be installed in the guest OS. See section 4.3 of the user manual. And no, this is not using networking so it does not require a network adapter in the VM.

If a network share: that depends. Linux has every possible sharing scheme bolted onto it, so you'd have to configure compatible schemes in host and guest. If you use the Windows-compatible SMB scheme then you need SAMBA to be configured in both.

The details of how to navigate to a share depends on which filesystem browser you have.
Martin
Volunteer
Posts: 2560
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: Mounting NFS filesystem exported by Linux host ?

Post by Martin »

An nfs export is comparable to a samba share.
To mount it you need a normal network connection between guest and host.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Mounting NFS filesystem exported by Linux host ?

Post by scottgus1 »

Martin wrote:a normal network connection between guest and host.
And this connection would be Bridged, if there is a wired Ethernet LAN attached to the host, or Host-Only, which would work in any circumstances. (Virtualbox defaults to using NAT, which works to get internet into the VM in any circumstances, but would be hard to get a shared folder passed through.)

See Virtualbox Networks: In Pictures
Nicholas Yue
Posts: 6
Joined: 4. Jan 2020, 20:45

Re: Mounting NFS filesystem exported by Linux host ?

Post by Nicholas Yue »

Reading the responses, I am unsure but if sounds like Host-Only adaptor may still be suitable/usable for NFS mounting.

Here is my current setup and observation (it didn't work at the moment, hope to learn and find out why)

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

When I try to mount the NFS exported filesystem on the host from the guest VM, I got an access denied

BionicBeaver:~$ sudo mount -t nfs 192.168.0.16:/data2/hq /mnt/hq
mount.nfs: access denied by server while mounting 192.168.0.16:/data2/hq

I tested the mount from the host itself and it mounts fine so it appears to be a network setup issue

head0:~$ sudo mount -t nfs 192.168.0.16:/data2/hq /mnt/hq
head0:~$ df
head0:/data2/hq 452520960 338396160 91068416 79% /mnt/hq

==========================================================

On my Linux host (head0), the network IP is


head0:~$ hostname -i
172.17.0.1 172.19.0.1 192.168.0.16 fe80::42:59ff:fe6f:a1df fe80::41f:abff:fedc:7395 fe80::65b0:f1ac:c02b:7904

head0:~$ sudo showmount -e
Export list for head0:
/data2/picocluster *
/mnt/nfs *
/data2/hq (everyone)

==========================================================

On the Guest Linux (BionicBeaver), I have the following

BionicBeaver:~$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::aa00:bb18:2eab:9d1c prefixlen 64 scopeid 0x20<link>
ether 08:00:27:d4:88:9e txqueuelen 1000 (Ethernet)
RX packets 17 bytes 1902 (1.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 82 bytes 8462 (8.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.56.101 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 fe80::a206:3001:8ba7:40bb prefixlen 64 scopeid 0x20<link>
ether 08:00:27:e4:e9:95 txqueuelen 1000 (Ethernet)
RX packets 2 bytes 1180 (1.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 58 bytes 6780 (6.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 65 bytes 5213 (5.2 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 65 bytes 5213 (5.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


BionicBeaver:~$ ping 192.168.0.16
PING 192.168.0.16 (192.168.0.16) 56(84) bytes of data.
64 bytes from 192.168.0.16: icmp_seq=1 ttl=63 time=0.353 ms
64 bytes from 192.168.0.16: icmp_seq=2 ttl=63 time=0.509 ms

==========================================================
Attachments
Network Setting for Guest OS
Network Setting for Guest OS
VirtualBoxNetworkQuestion.png (41.33 KiB) Viewed 3063 times
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Mounting NFS filesystem exported by Linux host ?

Post by scottgus1 »

OK, looks like you got a good Host-Only setup, based on the enp0s8 getting the 192.168.56.101 IP address, which is default for the typical Host-Only network.

If this is the command that you tried in the VM:
Nicholas Yue wrote:BionicBeaver:~$ sudo mount -t nfs 192.168.0.16:/data2/hq /mnt/hq
then I surmise that your problem lies in the IP address in the command. Host-Only can't access outside the host, so it can't get the host's physical network adapter. Instead, Virtualbox makes a virtual network adapter through which the VM can access the host over Host-Only. The IP address of the virtual Host-Only adapter is 192.168.56.1 Try this address in your command in the VM.

Ping gets to 192.168.0.16 because it can go through the NAT adapter.
Nicholas Yue
Posts: 6
Joined: 4. Jan 2020, 20:45

Re: Mounting NFS filesystem exported by Linux host ?

Post by Nicholas Yue »

I tried the following suggestion

nyue@BionicBeaver:~$ sudo mount -t nfs 192.168.56.1:/data2/hq /mnt/hq

it just hangs without returning
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Mounting NFS filesystem exported by Linux host ?

Post by scottgus1 »

Please try pinging 192.168.56.1 inside the VM, and ping 192.168.56.101 from the host. Check that both OSs' firewalls allow ping.

If the ping goes through both ways, then the Host-Only network is working and further connection troubles are probably from host or VM OS's configuration issues.
Nicholas Yue
Posts: 6
Joined: 4. Jan 2020, 20:45

Re: Mounting NFS filesystem exported by Linux host ?

Post by Nicholas Yue »

From inside the VM, I am unable to ping 192.168.56.1

From the host, I am unable to ping 192.168.56.101

No sure how to narrow down the possible problem.

From inside the VM, I am still able to ping 192.168.0.16 though
Nicholas Yue
Posts: 6
Joined: 4. Jan 2020, 20:45

Re: Mounting NFS filesystem exported by Linux host ?

Post by Nicholas Yue »

It is working now.

An incorrect vboxnet was selected. After correcting it, NFS mounting from the VM to the host is working.

Thank you.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Mounting NFS filesystem exported by Linux host ?

Post by scottgus1 »

Getting the correct 'vboxnet' will do it! Glad you're up and running.
Post Reply