Update Workflows/Linux/Expand RHEL Filesystem.md
This commit is contained in:
@ -4,7 +4,7 @@ The purpose of this workflow is to illustrate the process of expanding storage f
|
||||
!!! info "Assumptions"
|
||||
It is assumed you are using a RHEL variant of linux such as Rocky Linux. This should apply to any version of Linux, but was written in a Rocky Linux 9.4 lab environment.
|
||||
|
||||
This document also assumes you did not enable Logical Volume Management (LVM) when deploying your server. If you did, you will need to perform additional (undocumented) LVM-specific steps after increasing the space following this document.
|
||||
This document also assumes you did not enable Logical Volume Management (LVM) when deploying your server. If you did, you will need to perform additional LVM-specific steps after increasing the space.
|
||||
|
||||
## Increase GuestVM Virtual Disk Size
|
||||
This part should be fairly straight-forward. Using whatever hypervisor is running the Linux GuestVM, expand the disk space of the disk to the desired size.
|
||||
@ -44,42 +44,7 @@ This step goes over how to increase the usable space of the virtual disk within
|
||||
9. Just leave this as-is and press ++enter++ without entering any values. Assuming you are using XFS, as this guide was written for, the default "Linux Filesystem" is what you want for XFS.
|
||||
10. This will write the changes to the partition table making them reality instead of just staging the changes.
|
||||
|
||||
=== "Using FDISK w/ LVM"
|
||||
|
||||
``` sh
|
||||
# Resize Partition of Disk in PV Group
|
||||
fdisk /dev/hda # Use pvdisplay to get the disk identifier
|
||||
p # List Partitions
|
||||
d # Delete the partition
|
||||
2 # Assume Partition 2 (e.g. /dev/hda2)
|
||||
n # Make a new Partition
|
||||
p # Primary Partition Type
|
||||
Starting Sector: <Use Default Value>
|
||||
Ending Sector: <Use Default Value>
|
||||
w # Commit changes to the disk
|
||||
|
||||
# Probe the new partition
|
||||
partprobe /dev/hda
|
||||
|
||||
# Reboot the Server
|
||||
reboot
|
||||
|
||||
# Resize PV Device
|
||||
pvdisplay # Note Current Size then reference it later
|
||||
pvresize /dev/hda2
|
||||
pvdisplay # To Confirm size Increased
|
||||
|
||||
# Extend the Logical Volume for the Target Disk
|
||||
lvextend -l +100%FREE /dev/VolGroup00/LogVol00 # Get this from running lvdisplay to find the correct LV
|
||||
|
||||
# Resize the Filesystem of the OS
|
||||
resize2fs /dev/VolGroup00/LogVol00
|
||||
|
||||
# Validate Space increased
|
||||
df -h
|
||||
```
|
||||
|
||||
|
||||
!!! example "Example Output"
|
||||
```
|
||||
Command (? for help): p
|
||||
Disk /dev/sda: 2147483648 sectors, 1024.0 GiB
|
||||
@ -98,20 +63,68 @@ This step goes over how to increase the usable space of the virtual disk within
|
||||
3 3328000 19826687 7.9 GiB 8200
|
||||
4 19826688 1073741790 502.5 GiB 8300 Linux filesystem
|
||||
```
|
||||
=== "Using FDISK"
|
||||
|
||||
``` sh
|
||||
pvdisplay # (1)
|
||||
fdisk /dev/hda # (2)
|
||||
p <ENTER> # List Partitions
|
||||
d <ENTER> # Delete a partition
|
||||
2 <ENTER> # Delete Partition 2 (e.g. /dev/hda2)
|
||||
n <ENTER> # Make a new Partition
|
||||
p <ENTER> # Primary Partition Type
|
||||
Starting Sector: <ENTER> # Use Default Value
|
||||
Ending Sector: <ENTER> # Use Default Value
|
||||
w <ENTER> # Commit all queued-up changes and write them to the disk
|
||||
|
||||
|
||||
```
|
||||
??? info "Detailed Command Breakdown"
|
||||
1. Use pvdisplay to get the target disk identifier
|
||||
2. Replace `/dev/hda` with the target disk identifier found in the previous step
|
||||
|
||||
**Point of No Return**:
|
||||
When you press `w` then ++enter++ the changes will be written to disk, meaning there is no turning back unless you have full GuestVM backups with something like Veeam Backup & Replication. Be certain the first and last sector values are correctly configured before proceeding.
|
||||
When you press `w` in both cases of `gdisk` or `fdisk`, then ++enter++ the changes will be written to disk, meaning there is no turning back unless you have full GuestVM backups or a snapshot to rollback with, or something like Veeam Backup & Replication. Be certain the first and last sector values are correctly configured before proceeding. (Default values generally are good for this)
|
||||
|
||||
## Detect the New Partition Sizes
|
||||
At this point, the operating system wont detect the changes without a reboot, so we are going to force the operating system to detect them immediately with the following commands to avoid a reboot.
|
||||
At this point, the operating system wont detect the changes without a reboot, so we are going to force the operating system to detect them immediately with the following commands to avoid a reboot (if we can avoid it).
|
||||
``` sh
|
||||
sudo partprobe
|
||||
sudo partprobe /dev/<drive> # Drive Example: /dev/sda (Rocky) or /dev/hda (Oracle Linux)
|
||||
sudo partx -u /dev/<diskNumber>
|
||||
sudo xfs_growfs /
|
||||
```
|
||||
|
||||
??? bug "Partition Not Expanded?"
|
||||
If you notice the partition still has not expanded to the desired size, you may have no choice but to reboot the server, then re-run the `gdisk` commands a second time. In my lab environment, it didn't work until I rebooted. This might have been a hiccup on my end, but it's something to keep in mind if you run into the same issue of the size not changing.
|
||||
??? bug "Partition Size Not Expanded? Reboot."
|
||||
If you notice the partition still has not expanded to the desired size, you may have no choice but to reboot the server, then re-run the `gdisk` or `fdisk` commands a second time. In my lab environment, it didn't work until I rebooted. This might have been a hiccup on my end, but it's something to keep in mind if you run into the same issue of the size not changing.
|
||||
|
||||
``` sh
|
||||
sudo reboot
|
||||
```
|
||||
|
||||
## Resize the Filesystem
|
||||
=== "XFS Filesystem"
|
||||
``` sh
|
||||
sudo xfs_growfs /
|
||||
```
|
||||
|
||||
=== "Ext4 Filesystem"
|
||||
``` sh
|
||||
resize2fs /dev/sda
|
||||
```
|
||||
|
||||
=== "Ext4 Filesystem w/ LVM"
|
||||
``` sh
|
||||
# Increase the Physical Volume Group Size
|
||||
pvdisplay # Check the Current Size of the Physical Volume
|
||||
pvresize /dev/hda2 # Enlarge the Physical Volume to Fit the New Partition Size
|
||||
pvdisplay # Validatre the Size of the Physical Volume Increased to the New Size
|
||||
|
||||
# Increase the Logical Volume Group Size
|
||||
lvextend -l +100%FREE /dev/VolGroup00/LogVol00 # Get this from running "lvdisplay" to find the correct Logical Volume Name
|
||||
|
||||
# Resize the Filesystem of the Disk to Fit the new Logical Volume
|
||||
resize2fs /dev/VolGroup00/LogVol00
|
||||
```
|
||||
|
||||
|
||||
## Validate Storage Expansion
|
||||
At this point, you can leverage `lsblk` or `df -h` to determine if the usable storage space was successfully increased or not. In this example, you can see that I increased my storage space from 512GB to 1TB.
|
||||
|
Reference in New Issue
Block a user