Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Mount NFS share on server question
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
shrike
Apprentice
Apprentice


Joined: 20 Feb 2004
Posts: 187
Location: Closer to home

PostPosted: Wed Apr 20, 2022 12:29 pm    Post subject: [SOLVED] Mount NFS share on server question Reply with quote

What concerns me is the fs type is ext4 on the server. Can I use some form of (127.0.0.1:distfiles <mountpoint> nfs noauto,rw,_netdev 0 0) in fstab on the sever?


Server

Code:
A333 ~ # grep DIST /etc/portage/make.conf
DISTDIR="/mnt/distfiles"


Code:
 # grep dist /etc/fstab
PARTUUID=65be14f0-3910-4c75-9800-d08c095b16c5   /mnt/distfiles   ext4   auto   0 1
/mnt/distfiles    /export/distfiles    none    bind    0    0


Code:
A333 ~ # mount |grep dist
/dev/sda1 on /mnt/distfiles type ext4 (rw,relatime)
/dev/sda1 on /export/distfiles type ext4 (rw,relatime)


Code:
A333 ~ # df -hT |grep dist
/dev/sda1      ext4      118G   14G   99G  12% /mnt/distfiles


Client

Code:
~$ mount |grep dist
A333:/distfiles on /mnt/distfiles type nfs4 (rw,relatime,vers=4.2, <snip> ,clientaddr=192.168.1.166,local_lock=none,addr=192.168.1.153,_netdev)


Thanks,

shrike
_________________
______________________________________________
MSI X570 | AMD 5600X | 32GB Ram | AMD RX5500


Last edited by shrike on Wed Apr 20, 2022 1:53 pm; edited 1 time in total
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Wed Apr 20, 2022 12:36 pm    Post subject: Reply with quote

Quote:

/dev/sda1 on /mnt/distfiles type ext4 (rw,relatime)

It is already mounted as a partition.
With nfs you share already existing directories via /etc/exports NOT partitions.
What exactly are you trying to accompish ?
This
Quote:

127.0.0.1:distfiles <mountpoint> nfs noauto,rw,_netdev 0 0

is a bit weird.
Why mount it as nfs share when you can --bind mount it.You already did.

Nevertheless you either need
127.0.0.1:/mnt/distfiles
or in case of setting fsid=0 on a parent directory
127.0.0.1:/distfiles
Something like
Code:

mkdir -p /mnt/nfs/distfiles
echo "/mnt/nfs *(rw,fsid=0)" >> /etc/exports
echo "/mnt/nfs/distfiles *(rw,nohide)" >> /etc/exports

together with any other nfs sharing options.
BETTER just leave /dev/sda1 mounted on
/var/cache/distfiles
Then bind mount
/var/cache/distfiles to /mnt/nfs/distfiles
then share it with nfs.
_________________
:)
Back to top
View user's profile Send private message
shrike
Apprentice
Apprentice


Joined: 20 Feb 2004
Posts: 187
Location: Closer to home

PostPosted: Wed Apr 20, 2022 1:52 pm    Post subject: Reply with quote

alamahant,

Thanks for 'faster than greased lightning' response. :)

I have not have any issues as currently configured yet it seemed wrong for the server to access /mnt/distfiles w/o nfs mediation. At least during update day with a few clients contending for access. Seeing your response perhaps the question should have been, is my nfs server ok with '/mnt/distfiles /export/distfiles none bind'?.

Thanks for taking the time to ease my troubled brow.

shrike
_________________
______________________________________________
MSI X570 | AMD 5600X | 32GB Ram | AMD RX5500
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Wed Apr 20, 2022 2:55 pm    Post subject: Reply with quote

What is the output of /etc/exports?
Are you sharing /mnt/distfiles or /exports/distfiles?
In /etc/exports plz use "sync" sharing option
_________________
:)
Back to top
View user's profile Send private message
shrike
Apprentice
Apprentice


Joined: 20 Feb 2004
Posts: 187
Location: Closer to home

PostPosted: Wed Apr 20, 2022 3:29 pm    Post subject: Reply with quote

alamahant,

Quote:
What is the output of /etc/exports?


Code:
A333 ~ # cat /etc/exports
# /etc/exports: NFS file systems being exported.  See exports(5).

/export         192.168.1.0/24(insecure,rw,sync,no_subtree_check,crossmnt,fsid=0)
/export/distfiles    192.168.1.0/24(insecure,rw,sync,no_subtree_check)


Quote:
Are you sharing /mnt/distfiles or /exports/distfiles?


I am not sure how to answer this question. What command should I use? Or perhaps this is already answered in the 'Server - fstab' in OP.

Quote:
In /etc/exports plz use "sync" sharing option


"sync" is set.

Thanks,

shrike
_________________
______________________________________________
MSI X570 | AMD 5600X | 32GB Ram | AMD RX5500
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 2961
Location: Edge of marsh USA

PostPosted: Thu Apr 21, 2022 4:04 am    Post subject: Reply with quote

On the server at 192.168.0.105 where it is assumed that /mnt/storage1 is mounted as an ordinary partition:
Code:
$ grep mnt.storage1 /etc/exports
/mnt/storage1   192.168.0.0/255.255.255.0(rw,sync,no_root_squash,no_subtree_check)

$ grep mnt.storage1 /etc/fstab
UUID="acf5c411-e2ad-4dfa-8740-4a8fbb27eb20" /mnt/storage1 ext4 exec,dev,noatime,suid  0 2


On the client:
Code:
$ grep mnt.storage1 /etc/fstab
192.168.0.105:/mnt/storage1   /mnt/nfsstore nfs rw,nfsvers=3,noauto,user,hard,tcp 0 0

_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
shrike
Apprentice
Apprentice


Joined: 20 Feb 2004
Posts: 187
Location: Closer to home

PostPosted: Thu Apr 21, 2022 2:20 pm    Post subject: Reply with quote

figueroa,

Thanks for sharing.

With the deprecation of http-proxy (python2.7) a while ago its been a adventure finding a replacement. https://wiki.gentoo.org/wiki/Local_distfiles_cache provides two alternatives, apt-cacher-ng and nginx. apt-cacher worked well but seemed foreign to portage. nginx sample configuration file is not a drop in and go example. I was disappointed in my inability to compose a working config for this storied package. Then, I saw recent mentions here in the forums of nfs as a distfile server so I adapted Funtoo's nfs wiki (https://www.funtoo.org/Nfs) to the purpose.

My NFS distfile server works for my home LAN. Yet it is unusual for a server to be a client too.

But to your NFS server/client configuration is the server a Gentoo machine? If yes what is DISTDIR=?

Thanks,

shrike

edit 1 Change 'Local Mirror' to 'Local Distfiles' link.
_________________
______________________________________________
MSI X570 | AMD 5600X | 32GB Ram | AMD RX5500


Last edited by shrike on Thu Apr 21, 2022 3:20 pm; edited 1 time in total
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 2961
Location: Edge of marsh USA

PostPosted: Thu Apr 21, 2022 3:03 pm    Post subject: Reply with quote

You'd have to adapt my NFS configuration to your use-case. I don't use NFS to get my portage updates, but rather rsyncd on the host and sync-uri = rsync://192.168.0.105/gentoo-portage on the client in /etc/portage/repos/gentoo.conf.

On the host, /etc/rsyncd.conf
Code:
pid file = /run/rsyncd.pid
use chroot = yes
read only = yes

uid = nobody
gid = nobody
hosts allow = 192.168.0.0/24
hosts deny = *
max connections = 2
 
[gentoo-portage]
   path = /usr/portage
   comment = Gentoo Portage tree
   exclude = /distfiles /packages


To make available a common distfiles by NFS, which I don't, It would be sufficient to NFS export your host distfiles by NFS and then mount that share on the client, and indicate the mounted location in /etc/portage/make.conf. There is no need to "mount" it on the host. Your distfiles directory should ordinarily be always mounted on the host as part of your normal filesystem layout, whether /usr/portage/distfiles or /var/cache/distfiles

Hope you find this meaningful.
_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1653

PostPosted: Thu Apr 21, 2022 3:16 pm    Post subject: Reply with quote

figueroa wrote:
To make available a common distfiles by NFS, which I don't, It would be sufficient to NFS export your host distfiles by NFS and then mount that share on the client, and indicate the mounted location in /etc/portage/make.conf. There is no need to "mount" it on the host. Your distfiles directory should ordinarily be always mounted on the host as part of your normal filesystem layout, whether /usr/portage/distfiles or /var/cache/distfiles

Hope you find this meaningful.


Just note that NFSv4 likes to have bind mounts to another location, often /exports, such that all mounts are under a central location. NFSv3 can have them anywhere.
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2000

PostPosted: Thu Apr 21, 2022 6:00 pm    Post subject: Reply with quote

FWIW, I use NFSv4 to export my distfiles and binpkgs from my desktop to my laptop for updates. (I used to do the same for the portage tree, but I download a squashfs image instead these days,)
Here's my /etc/exports:
Code:
# /etc/exports: NFS file systems being exported.  See exports(5).
/home           -ro,no_subtree_check,fsid=root,async,crossmnt   192.168.1.0/24
/home/foo       -ro,no_subtree_check,async                      192.168.1.0/24
/home/distfiles -ro,no_subtree_check,async,no_root_squash       192.168.1.0/24
/home/binpkgs   -ro,no_subtree_check,async,no_root_squash       192.168.1.0/24

I export everything under home so I can, if desired, make my home directories visible. The portage directories are bind mounted:
Code:
# Bind mounts for nfs
/var/cache/distfiles    /home/distfiles none            bind,defaults           0 0
/var/cache/binpkgs      /home/binpkgs   none            bind,defaults           0 0

and this is what exportfs says when nfs is running:
Code:
/home           192.168.1.0/24
/home/foo       192.168.1.0/24
/home/distfiles 192.168.1.0/24
/home/binpkgs   192.168.1.0/24

As far as I recall, the client side fstab entries are:
Code:
desktop:/distfiles       /var/cache/distfiles      nfs4    noauto,ro      0 0
desktop:/binpkgs         /var/cache/binpkgs        nfs4    noauto,ro      0 0

I set it up ages ago, so I don't recall why any of the settings are needed !
_________________
Greybeard
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum