Exercice: NFS and LVM
Exercise: Provision LVM Storage and Export via NFS on RHEL 10
Task
You are required to attach new storage, configure volume management, configure local and remote mounts, and provide an NFS export on a RHEL 10 virtual machine running under Proxmox VE. Complete the following objectives:
- Storage Provisioning & Hardware Scan:
- In Proxmox VE, allocate and attach a new virtual SCSI hard drive to the RHEL 10 VM.
- On the RHEL 10 VM, scan the SCSI bus without rebooting so the new disk (assumed
/dev/sdb) is visible tolsblk.
- LVM Storage Layer:
- Create a GPT partition
/dev/sdb1taking 100% of the disk and flagged for LVM. - Initialize a Physical Volume (PV) on
/dev/sdb1. - Create a Volume Group (VG) named
vg_data. - Create a Logical Volume (LV) named
lv_manuutilizing 100% of the free space invg_data. - Format
lv_manuwith anXFSfilesystem.
- Create a GPT partition
- Persistent Local Mount:
- Create the directory
/manu. - Configure persistent mounting at
/manuusing the filesystem UUID (via/etc/fstabor native systemd mount unit).
- Create the directory
- NFS Server Setup & Hardening:
- Install the required NFS utilities and enable the
nfs-serverservice across reboots. - Export the directory
/manuto your local subnet (e.g.,192.168.1.0/24) withrwandsyncoptions. - Permit NFS traffic persistently through
firewalld. - Adjust SELinux boolean settings so NFS can export read/write filesystems.
- Install the required NFS utilities and enable the
- Client Configuration:
- On a remote Linux client, install necessary NFS client utilities.
- Ensure
/manuis persistently mounted at/mnt/manuusing_netdevandx-systemd.automount(or dedicated systemd.mountand.automountunits) to ensure boots do not hang if the server is offline.
Verify
Execute these commands to validate every stage of your setup.
1. Verify Storage & LVM on Server
# Check block devices and partition tables
lsblk -f /dev/sdb
# Check LVM entities
pvs /dev/sdb1
vgs vg_data
lvs vg_data/lv_manu
2. Verify Server Local Mount (/manu)
# Check current mount and filesystem capacity
findmnt /manu
df -hT /manu
# Validate fstab syntax without unmounting
mount -fav
3. Verify NFS Service, Exports, and Security
# Verify NFS service status
systemctl is-enabled nfs-server
systemctl is-active nfs-server
# Check export table
exportfs -v
# Verify firewall rules
firewall-cmd --list-services | grep -E 'nfs|rpc-bind|mountd'
# Check SELinux boolean configuration
getsebool nfs_export_all_rw
4. Verify from Client System
# Verify export visibility from client
showmount -e <NFS_SERVER_IP>
# Verify active or automount trigger
ls -la /mnt/manu
findmnt /mnt/manu
# Test read/write privileges
touch /mnt/manu/test_rw_check
ls -l /mnt/manu/test_rw_check
rm -f /mnt/manu/test_rw_check
Solution
1. Proxmox VE Hardware Allocation & Bus Scan
- In the Proxmox VE Web UI:
- Navigate to: VM > Hardware > Add > Hard Disk.
- Set Bus/Device to
SCSI(VirtIO SCSI). - Specify size (e.g.,
50 GiB) and click Add.
- On the RHEL 10 VM, rescan the SCSI buses:
for host in /sys/class/scsi_host/host*/scan; do echo "- - -" > "$host" done # Confirm the drive is present (assumed /dev/sdb) lsblk
2. Partitioning, LVM, and Filesystem Creation
# 1. Partition with GPT and label for LVM
parted -s /dev/sdb mklabel gpt mkpart primary 2048s 100%
parted -s /dev/sdb set 1 lvm on
# 2. Create Physical Volume (PV)
pvcreate /dev/sdb1
# 3. Create Volume Group (VG)
vgcreate vg_data /dev/sdb1
# 4. Create Logical Volume (LV) using all available space
lvcreate -l 100%FREE -n lv_manu vg_data
# 5. Format with XFS
mkfs.xfs /dev/vg_data/lv_manu
3. Configure Local Mount Point (/manu)
# Create mount point
mkdir -p /manu
# Fetch filesystem UUID
FS_UUID=$(blkid -s UUID -o value /dev/vg_data/lv_manu)
# Configure persistent mount in /etc/fstab
echo "UUID=${FS_UUID} /manu xfs defaults 0 0" >> /etc/fstab
# Mount without rebooting
systemctl daemon-reload
mount -a
(Alternative: Native Systemd Mount Unit)
cat << 'EOF' > /etc/systemd/system/manu.mount
[Unit]
Description=Local Mount for /manu
After=lvm2-monitor.service
[Mount]
What=/dev/vg_data/lv_manu
Where=/manu
Type=xfs
Options=defaults
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now manu.mount
4. NFS Server Configuration & Security Setup
# 1. Install NFS packages and enable service
dnf install -y nfs-utils
systemctl enable --now nfs-server
# 2. Configure export in /etc/exports (replace 192.168.1.0/24 with your network)
echo "/manu 192.168.1.0/24(rw,sync,no_root_squash,no_subtree_check)" >> /etc/exports
# 3. Refresh exports
exportfs -rav
# 4. Open firewall ports
firewall-cmd --permanent --add-service=nfs
firewall-cmd --permanent --add-service=rpc-bind
firewall-cmd --permanent --add-service=mountd
firewall-cmd --reload
# 5. Configure SELinux
setsebool -P nfs_export_all_rw 1
semanage fcontext -a -t public_content_rw_t "/manu(/.*)?" 2>/dev/null || true
restorecon -Rv /manu
5. Client-Side Persistent Mount
On the client machine:
Step A: Install Client Tools & Prepare Directory
- RHEL/CentOS/Fedora:
dnf install -y nfs-utils - Ubuntu/Debian:
apt-get update && apt-get install -y nfs-common
Create the directory:
mkdir -p /mnt/manu
Step B: Persistence Method 1 — /etc/fstab with Automount (Recommended)
Add the following line to /etc/fstab:
<NFS_SERVER_IP>:/manu /mnt/manu nfs defaults,_netdev,nofail,x-systemd.automount,timeo=14,intr 0 0
Apply changes:
systemctl daemon-reload
mount -a
Step B: Persistence Method 2 — Native Systemd Units
Create the mount and automount units:
- Mount unit:
/etc/systemd/system/mnt-manu.mount[Unit] Description=NFS Share Mount (/mnt/manu) After=network-online.target Wants=network-online.target [Mount] What=<NFS_SERVER_IP>:/manu Where=/mnt/manu Type=nfs Options=defaults,_netdev,timeo=14,intr TimeoutSec=30 [Install] WantedBy=multi-user.target - Automount unit:
/etc/systemd/system/mnt-manu.automount[Unit] Description=Automount for NFS Share (/mnt/manu) ConditionPathExists=/mnt/manu [Automount] Where=/mnt/manu TimeoutIdleSec=600 [Install] WantedBy=multi-user.target
Enable and start automount:
systemctl daemon-reload
systemctl enable --now mnt-manu.automount