-
Attach a storage device in the server. In this scenario, it's /dev/sdb.
lsblk
DEVICE_NAME="/dev/sdb" NFS_DIR="/nfs-dir" FS_TYPE="xfs" #FS_TYPE="ext4" #I recommend for AWS EBS
-
Format the storage device. In this scenario, it's xfs.
mkfs.$FS_TYPE $DEVICE_NAME
. -
Create the directory to mount and mount the formatted storage device.
mkdir $NFS_DIR mount $DEVICE_NAME $NFS_DIR
-
Add an entry to
/etc/fstab
to persist the storage device mount configuration.-
Get the UUID of the storage device .
blkid | grep $DEVICE_NAME /dev/sdb: UUID="e5eac1a0-4ea9-48ff-801a-063c3ef5d041" TYPE="xfs"
-
Modify
/etc/fstab
.echo "UUID=e5eac1a0-4ea9-48ff-801a-063c3ef5d041 $NFS_DIR $FS_TYPE defaults,nofail 1 2" >> /etc/fstab
-
Validate mount config and ensure there are no errors
mount -a
-
-
Prepare the exports configuration file .
echo "$NFS_DIR *(rw,root_squash)" >> /etc/exports.d/nfs-dir.exports
-
Update nfs exports configuration .
exports -a exports -v
-
Ensure that the new NFS export directory has the right permission
chown nfsnobody:nfsnobody $NFS_DIR chmod 777 $NFS_DIR
-
Ensure that SELinux allows writing to the exported directory .
setsebool -P virt_use_nfs 1 setsebool -P virt_sandbox_use_nfs 1
-
Ensure that the NFS server allows server traffic .
# for NFSv4 and NFSv3 iptables -I INPUT 1 -p tcp --dport 2049 -j ACCEPT # for NFSv3 only iptables -I INPUT 1 -p tcp --dport 20048 -j ACCEPT iptables -I INPUT 1 -p tcp --dport 111 -j ACCEPT
Last active
August 13, 2017 11:36
-
-
Save bzon/ebe9d0cf0d6bf1265c838ceade355a89 to your computer and use it in GitHub Desktop.
NFS Storage Guide
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment