How to resize an ext4 filesystem when it is not using LVM?
Issue Description: The procedure for resizing an ext4 filesystem varies depending on whether it is managed by a Logical Volume Manager (LVM) or not due to the inherent differences in how storage is managed in each case.
Root Cause Analysis: The procedure for resizing an ext4 filesystem varies depending on whether it is managed by a Logical Volume Manager (LVM) or not due to the inherent differences in how storage is managed in each case. While LVM is the preferred method for creating filesystems, you may encounter older instances of AI Center standalone and early Automation Suite releases that were installed using partition-based disk storage. Please see the 'Root Cause' section for more detailed information.
Diagnosing: Run the command 'lsblk' to list the block storage information of the environment. Find the name of the mount point of interest and check the value of the "TYPE" column. The value "part" indicates it is a partition and not using LVM.
Example 'lsblk' output
Resolution: Perform the following steps to resize the partition. Note, data loss can occur if these steps are not performed correctly. It is essential to take a backup before proceeding as well as double-checking the mount point name and device name to ensure they are correct.
Step A: Perform Pre-Node Maintenance (online documentation)
- Drain the node
- /opt/node-drain.sh
- Stop the rke2 server service
- systemctl stop rke2-server
Step B: Node Maintenance: Resize The Volume
- Unmount the mount point using the following command:
*** Ensure that '/var/lib/rancher' is the correct mount point. ***
umount /var/lib/rancher
- If the mount point is still in use, find out what's using it by running:
fuser -m /var/lib/rancher
This will provide a list of running processes using it. If necessary, you can terminate those processes with:
fuser -k /var/lib/rancher
- Run the `parted` tool on the device you want to resize, in this case, it's `/dev/nvme3n1`:
*** Ensure that '/dev/nvme3n1' is the correct mount point. ***
sudo parted /dev/nvme3n1
Note: "Only the highest numbered partition on the device can be resized."
- Inside the parted utility, resize the partition (1 in this case) to your desired size (expressed as a percentage of total disk space or in GB). For example, to use the entire disk, enter `100%`:
(parted) resizepart 1 100%
- Verify that the partition has been expanded correctly by printing the partition table:
(parted) print
- Exit the parted utility:
(parted) quit
- Resize the filesystem to fill the newly expanded partition:
sudo resize2fs /dev/nvme3n1p1
- Perform a filesystem check on the resized partition:
sudo e2fsck -f /dev/nvme3n1p1
- Finally, remount the filesystem. Again, ensure the mount point '/var/lib/rancher' and the device '/dev/nvme3n1p1' are accurate:
mount /dev/nvme3n1p1 /var/lib/rancher
Step C: Post-Node Maintenance (online documentation)
- Reboot the node
reboot
- Check that the rke2-server service is running
systemctl status rke2-server
- Ensure that the node is in a 'Ready' state
kubectl get nodes