Growing the file system of a default Centos 7 install

6 Mar

If you’re deploying a Centos.7 VM image and need to resize it, there are two options:

  • Add an additional disk add incorporate it as a LVM physical volume
  • Extend the current physical volume and grow the PV and LV

I’m going for the second one in my test setup, for a default CentOS 7 install these are the steps:

  1. Power off the VM.
  2. Increase the size of the disk.
  3. Power on and run disk, removing the current LVM partition and recreating it to expand it to the new size (in my test setup, this is /dev/sda and the second partition, /dev/sda2).
  4. Reboot again, in order to make the kernel pickup on the new partitioning.
  5. Resize the physical volume: pvresize /dev/sda2
  6. Verify the new size with pvdisplay
  7. Grow the logical volume by adding all the available space:
    lvresize -l +100%FREE /dev/centos/root
  8. Finally, grow the actual root partition – no need to reboot:
    xfs_growfs /

Turning off buffering

1 Mar

Often you need to turn of buffering of stdout. I can never for the life of me remember the command for this, so here it is:

stdbuf -i0 -o0 -e0 command