-
Notifications
You must be signed in to change notification settings - Fork 0
/
freebsd-pnfs-mds.sh
executable file
·65 lines (52 loc) · 1.52 KB
/
freebsd-pnfs-mds.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
grep -q =FreeBSD /etc/os-release || { echo "{WARN} this script is only for FreeBSD OS"; exit 1; }
ds_server0=$1
ds_server1=$2
expdir=${3:-/export}
if [ -z "$ds_server0" ] || [ -z "$ds_server1" ]; then
echo "Usage: $0 <ds0> <ds2>"
exit 1
fi
nfs4minver=1
nfs4minver=2
mntds0=/data0
mntds1=/data1
expdir0=/export0
expdir1=/export1
mkdir -p -m 700 $mntds0 $mntds1
mkdir -p $expdir $expdir0 $expdir1
cat <<EOF >>/etc/fstab
$ds_server0:/ $mntds0 nfs rw,vers=4,minorversion=$nfs4minver,soft,retrans=2 0 0
$ds_server1:/ $mntds1 nfs rw,vers=4,minorversion=$nfs4minver,soft,retrans=2 0 0
EOF
mount -vvv $mntds0 || exit 1
mount -vvv $mntds1 || exit 1
cat <<EOF >/etc/exports
#$expdir -maproot=root -sec=sys
#V4: $expdir -sec=sys
$expdir0 -maproot=root -sec=sys
$expdir1 -maproot=root -sec=sys
V4: / -sec=sys
EOF
echo 'vfs.nfsd.default_flexfile=1' >>/etc/sysctl.conf
#enable nfs server
egrep -i ^nfs_server_enable=.?YES /etc/rc.conf ||
cat <<EOF >>/etc/rc.conf
rpcbind_enable="YES"
mountd_enable="YES"
nfs_server_enable="YES"
nfsv4_server_enable="YES"
nfsuserd_enable="YES"
nfs_server_flags="-u -t -n 32 -m 2 -p $ds_server0:$mntds0,$ds_server1:$mntds1"
nfs_server_flags="-u -t -n 32 -m 2 -p $ds_server0:$mntds0#$expdir0,$ds_server1:$mntds1#$expdir1"
mountd_flags="-S"
nfsuserd_flags="-manage-gids"
EOF
service nfsd start
service mountd restart
service nfsuserd start
sysctl vfs.nfsd.default_flexfile=1
#enable nfs client
egrep -i ^nfs_client_enable=.?YES /etc/rc.conf ||
echo 'nfs_client_enable="YES"' >>/etc/rc.conf
service nfsclient start