Grow Oracle Linux Root Filesystem
It is always the case that in my Linux VM installations I run out of root file system space and need to grow it (I can hear you experienced admin, I should create another filesystem for my use and not use root file system for my joy). Here are the steps to grow root filesystem for Oracle Linux running on VMware:
Click on the wrench symbol to go to your virtual machine configuration menu
Choose Hard Disk (SCSI) menu to increase the size of an availabe virtual disk (in this case your root file system disk)
Now you can start your Oracle Linux on VM*.
First step at guest OS (Oracle Linux) is to grow disk partition size using fdisk. Here are the steps assuming that your root file system is on /dev/sda2 partition
- fdisk /dev/sda
- d (to delete)
- 2 (to delete partition 2)
- n (to create a new partition)
- p (to create a new partition with primary type)
- 2 (to create a new primary partition with id 2)
- Accept all defaults (to create a new primary partition with default offset and fully covering virtual disk you have already provisioned)
- w (write partition table)
Once you are done with disk partition modification rebounce Oracle Linux to ensure partition tables are read by Linux.
Once the guest OS is back, resize physical volume using pvresize. We will add 6GB (slightly less maybe) to existing physical partition using pvresize command
pvresize --setphysicalvolumesize 31G /dev/sda2
Now we can grow logical volume by 6GB
lvresize -L +6G /dev/VolGroup00/LogVol00
Final step is to grow file system online using resize2fs
You are done. You can continue filling root file system 🙂
* Before starting it is a good decision to protect your existing VM guest by using VMware snapshots.