The great grandson of Husnu Sensoy

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)

Grow your virtual disk to a proper size (In this case I grow it form 28GB to 34GB)

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

  1. fdisk /dev/sda
  2. d (to delete)
  3. 2 (to delete partition 2)
  4. n (to create a new partition)
  5. p (to create a new partition with primary type)
  6. 2 (to create a new primary partition with id 2)
  7. Accept all defaults (to create a new primary partition with default offset and fully covering virtual disk you have already provisioned)
  8. 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

resize2fs /dev/VolGroup00/LogVol00

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.