_____ _ _ ______ _ _
| __ \(_) | | | ____| | | | |
| | | |_ ___| | __ | |__ __ _| |_ ___ _ __ __| | ___ _ __
| | | | / __| |/ / | __| \ \/ / __/ _ \ '_ \ / _` |/ _ \ '__|
| |__| | \__ \ < | |____ > <| || __/ | | | (_| | __/ |
|_____/|_|___/_|\_\ |______/_/\_\\__\___|_| |_|\__,_|\___|_|
A robust, interactive Bash script designed to simplify the process of extending the root partition (LVM) on Ubuntu Virtual Machines hosted on VMware ESXi.
Extending a Linux disk in a VMware environment usually involves a series of manual commands: rescanning the SCSI bus, resizing the partition, resizing the physical volume (PV), extending the logical volume (LV), and finally resizing the filesystem.
This script automates the orchestration of these steps into a guided, interactive wizard, reducing the risk of error and saving time.
- Interactive Wizard: Step-by-step prompts guide you through the process.
- Dependency Management: Automatically checks for and installs
cloud-guest-utils(required forgrowpart). - Safety First: Validates root privileges and checks for device existence.
- Auto-Detection:
- Detects filesystem types (
ext4,xfs) and applies the correct resize command. - Lists available disks and partitions to help you choose the correct target.
- Detects filesystem types (
- LVM Support: specifically designed for LVM (Logical Volume Manager) setups.
- VMware ESXi: You must have already increased the allocated disk size for the VM in the ESXi/vCenter settings.
- OS: Ubuntu (or Debian-based distros using LVM).
- Permissions: Root access (sudo).
Download and execute the script directly:
curl -fsSL https://raw.githubusercontent.com/USFAkbari/LVM_Disk_Extender/main/extend_disk.sh | sudo bash-
Clone the repository (or download the script):
git clone https://github.com/USFAkbari/LVM_Disk_Extender.git cd LVM_Disk_Extender -
Make the script executable:
chmod +x extend_disk.sh
-
Run the script:
sudo ./extend_disk.sh
-
Follow the verification steps:
- Step 1: Select the disk to rescan (usually
sda). - Step 2: The script rescans the disk to detect the new unallocated space.
- Step 3: Select the partition to expand (usually the last one, e.g.,
3). - Step 4: The partition is grown.
- Step 5: The Physical Volume (PV) is resized.
- Step 6: Select the Logical Volume (LV) to extend (defaults to
/dev/ubuntu-vg/ubuntu-lv). - Step 7: The LV is extended to use 100% of the free space.
- Step 8: The filesystem is resized on the fly.
- Step 1: Select the disk to rescan (usually
ALWAYS BACK UP YOUR DATA BEFORE MODIFYING DISK PARTITIONS.
While this script has been tested and includes safety checks, manipulating disk partitions and filesystems carries inherent risks. The author is not responsible for any data loss that may occur. Please ensure you have a valid snapshot or backup of your VM before proceeding.
This project is licensed under the MIT License - see the LICENSE file for details.