Extending Root Partition on CentOS 6.5

Home » Computer Articles » Linux » Extending Root Partition on CentOS 6.5
September 30, 2014 Linux No Comments

I updated my VPS with more memory and disk space. This is what I had to do, to use all the space on a bigger hard drive with a LVM partition.

 

To see the current disk usage

# df -h

 

To see the current partitioning

# fdisk -l

 

Create a new partition

# fdisk /dev/sda (Created a new 3rd partition)

 

List all the partitions

# fdisk -l

 

View current physical volumes a.k.a. pv

# pvdisplay

 

Allow Linux OS to use the new partition in LVM

# pvcreate /dev/sda3

 

See the new pv /dev/sda3

# pvdisplay

 

View the current volume groups

# vgdisplay

 

Add the new PV /dev/sda3 to the existing VG vg_centos64

# vgextend vg_centos64 /dev/sda3

 

# vgdisplay

 

View the current LV

# lvdisplay

 

Now make the LV larger

# lvextend -l +2559 /dev/vg_centos64/lv_root

or

# lvextend -l +100%FREE /dev/vg_centos64/lv_root

 

Now you can see the larger size of the LV

# lvdisplay

 

Online resize of the actual filesystem now on that LV

# resize2fs /dev/vg_centos64/lv_root

 

# reboot

 

You can see the new size now.

# df -h

 

Reference:

See reference below for more information.

http://geekswing.com/geek/unix/extending-a-linux-disk-with-lvm-extending-root-partition/

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.