I’ve always known that virtualizing things can make management of all types of resources easier. Recently, I had the most pleasant experience adding disk space to a virtual machine. Of course, if you use LVM, this can happen just as easily with real physical disks, but for me, I was able to do this without restarting my machine.
Issue: I’m out of disk space on my root partition.
Solution: The root partition is created on a logical volume with LVM2. Just add another disk, extend the volume group, and then extend the logical volume.
# Added new physical partition /dev/sda3
# create a physical volume out of it
> pvcreate /dev/sda3
# Now, add it to the volume group that my logical volume is on
> vgextend VolGroup00 /dev/sda3
# Now that the volume group has more disk space, the logical volume can grow
> lvextend -L+11G /dev/VolGroup00/LogVol00
# Ok, last of all, I want to filesystem to recognize that more space is available
> fsadm resize /dev/VolGroup00/LogVol00
# sweet, I have more space now
> df -h
All that was done without having to take the system off line. Linux makes life easy sometimes doesn’t it!