Extending hdd volume in a VM running CentOS 6.5

Here is stelps to exptend HDD volume in VM running CentOS 6.5

 

* Backup VM is always recommended

 

1. Power off VM

2. Edit VM’s virtual disk size to what you want (in this example, 18G to 25G)

3. Power back on

4. SSH to the CentOS server

5. Type fdisk -l  and df <- make a screen shoot to comparison later if you like.

[root@localhost chris]# fdisk -l

 

[root@localhost chris]# df
Filesystem           1K-blocks    Used Available Use% Mounted on
/dev/mapper/vg_centoschris-lv_root
                      14356400 5647748   8562816  40% /
tmpfs                  1962340      72   1962268   1% /dev/shm
/dev/sda1               495844   69147    401097  15% /boot
 

 

6. vgdisplay <- make a screen shoot to comparison later if you like.

[root@localhost chris]# vgdisplay

 

7. lvdisplay  <- check logical volume name

 

[root@localhost chris]# lvdisplay
  — Logical volume —
  LV Path                /dev/vg_centoschris/lv_root ; Group volume name + Logical volume
  LV Name                lv_root
  VG Name                vg_centoschris
  LV UUID                NjY3A9-Fl1G-fOAy-izbH-Ih1L-cnJv-obACLM
  LV Write Access        read/write
  LV Creation host, time centos-Chris, 2014-03-15 12:39:53 -0400
  LV Status              available
  # open                 1
  LV Size                13.91 GiB
  Current LE             3561
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  – currently set to     256
  Block device           253:0

 

8.  Execute below command to convert the new partition to a physical volume:

[root@localhost chris]# pvcreate /dev/sda3

 

9.  Execute below command to extend the physical volume on group volume(vg_centoschris)

[root@localhost chris]# vgextend vg_centoschris /dev/sda3

 

10.  Execute below command to see available how space.

[root@localhost chris]# vgdisplay vg_centoschris | grep "Free"

  Free  PE / Size       2302 / 8.99 GiB
 

11.  Execute below command to add exact volume

[root@localhost chris]# lvextend -L +8.99G /dev/vg_centoschris/lv_root

  Rounding size to boundary between physical extents: 8.99 GiB
  Extending logical volume lv_root to 22.90 GiB
  Logical volume lv_root successfully resized
 

12.  Execute below command to expand the ext3 filesystem online, inside of the Logical Volume:

[root@localhost chris]# resize2fs /dev/vg_centoschris/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_centoschris/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/vg_centoschris/lv_root to 6003712 (4k) blocks.
The filesystem on /dev/vg_centoschris/lv_root is now 6003712 blocks long.
 

13.  Verifying

[root@localhost chris]# df
Filesystem           1K-blocks    Used Available Use% Mounted on
/dev/mapper/vg_centoschris-lv_root
                      23637884 5654832  17744064  25% /
tmpfs                  1962340      80   1962260   1% /dev/shm
/dev/sda1               495844   69147    401097  15% /boot
 

 

 

 

 

 

 

 

Leave a Reply