NFS export
Mount it to freshly created directory. Add to fstab for automatic mount during boot process.
Preparations:
sudo su
dnf install \
nfs-utils
hostname hostname-s
export host="$(hostname)hostname -s)"
Decide which declaration will be used: FQDN or IP address (depending on purpose).
export src_host="(source host)"
ping ${src_host}
showmount -e ${src_host}
Verify that needed export is listed in the output and set a variable:
export src_export="(name of exported directory)"
showmount
Create local directory where a NFS export will be mounted. Naming used here comes from the name of attached disk to the VM (usually). To clarify, that it is a data disk, -
edata${src_host}suffix is added.
export dir="/mnt/${host}-data/data/ncp""
mkdir -p ${dir}
Before mounting the export, check where target directory is mounted, it should be mounted on the root /
and it should be empty.
df -h ${dir}
ls -la ${dir}
Finally, check variables and mount the export.
echo ${src_host}
echo ${src_export}
echo ${dir}
mount ${src_host}:${src_export} /mnt/${host}dir}
Check again
df -datah ${dir}
ls -la ${dir}
Mounting source should be presented as IP address and exported path and it should be mounted in the correct destination. For example:
[root@host mnt]# df -h ${dir}
Filesystem Size Used Avail Use% Mounted on
10.xxx.x.xx:/aaa/data/bbb/ccc 1.0T 0 1.0T 0% /mnt/host-data
#TODO: add into /fstab with oneliner
```bash
cat /etc/fstab
cat <<EOF >> /etc/fstab
${src_host}:${src_export} ${dir} nfs defaults 0 0
EOF
echo "add me to fstab"
mount | grep ${host}
nanocat /etc/fstab
systemctl daemon-reload
Umount and check automatic mounts, simulating restart.
umount ${dir}
df -h ${dir}
mount -aF
df -h ${dir}
Let's create an application directory. In my case, I use /data/ncp/
as structure for an application "NextCloud Production". Be consistent in directory structure: /data/
- for data, /home/
for users' home directories and similar across the infrastructure.
mkdir -p ${dir}/data/ncp/
df -h ${dir}/data/ncp/
when possible, test VM restart to ensure disk will be properly mounted
shutdown -r now