Steps:-
1. Setup Network & Hostname
2. Download all required packages
(nfs-utils & nfs-utils-lib)
3. Create & Format the Partition
(use parted for >2TB shares)
4. Configure the share point,
mount the partition & configure auto mount
5. Append /etc/exports & /etc/fstab
6. Configure Firewall to allow NFS
service
7. Restart Services & Reboot the
Server.
I used the below commands (parted) to
setup a 5TB NFS share on CentOS 7 Kernel 3.10.0-514.el7.x86_64
Configure Network & Hostname
vi
/etc/sysconfig/network
NETWORKING=yes
HOSTNAME=newHostName
vi
/etc/hosts
127.0.0.1
newHostName
127.0.0.1 localhost
localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost
localhost.localdomain localhost6 localhost6.localdomain6
and
then rebooting the system
Download all packages for NFS
Download
all required packages
yum
update
yum
-y install nfs-utils
yum
-y install nfs-utils-lib
yum
install 0 0
With Fdisk
Fdisk
used to create a new partition on new device sda/sdb
Format
the new xfs file system using
#
mkfs.xfs /dev/sdb1
Mount
the xfs file system
#
mkdir /mnt/db
#
mount /dev/sdb1 /mnt/db
#
mount | grep /dev/sdb1
Create the GPT partition table
mklabel
gpt
Warning: The existing
disk label on /dev/sdb will be destroyed and all data
on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted) unit
GB
With Parted
Check partition using fdisk -l
Run parted utility
Select /dev/sdb
Create the partition
mkpart
primary 0.0GB 4000.8GB
Quit parted now
Create the filesystem
mkfs.ext4 /dev/sdb1
Create Share point
mkdir
/home/share
Change the permissions
chmod
-R 777 /home/share/
Mount the partition
mount
/dev/sdb1 /home/share
Automounting NFS Shares on Server
Reboot:
Append
text to the end of /usr/lib/systemd/system/nfs-idmap.service
[Install]
WantedBy=multi-user.target
Append
text to the end of /usr/lib/systemd/system/nfs-lock.service
[Install]
WantedBy=nfs.target
Add the partition to /etc/fstab and
mounting it
/dev/sdb1 /home/share ext4 defaults 0
0
[root@localhost
~]# cat /etc/fstab
#
#
/etc/fstab
#
Created by anaconda on Wed Jul 5 17:25:55 2017
#
#
Accessible filesystems, by reference, are maintained under '/dev/disk'
#
See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl-root / xfs defaults 0
0
UUID=f2c3a44a-621a-4dd9-b86d-cf5f2fdee4a0
/boot xfs defaults 0
0
/dev/mapper/cl-home /home xfs defaults 0
0
/dev/mapper/cl-swap swap swap defaults 0
0
/dev/sdb1
/home/share ext4 defaults 0 0
[root@localhost
~]#
Append /etc/exports
vi
/etc/exports
/home/share
"192.168.0.0/16"(rw,sync,no_subtree_check,no_root_squash)
Configure Firewall to allow NFS
service
firewall-cmd
--permanent --zone public --add-service mountd
firewall-cmd
--permanent --zone public --add-service rpc-bind
firewall-cmd
--permanent --zone public --add-service nfs
firewall-cmd
--reload
Restart Services
systemctl
enable rpcbind
systemctl
enable nfs-server
systemctl
enable nfs-lock
systemctl
enable nfs-idmap
systemctl
start rpcbind
systemctl
start nfs-server
systemctl
start nfs-lock
systemctl
start nfs-idmap
Reboot the host
Shutdown
-r now