LVOL extend on CenOS 6U4

How to extend root (/) partition on a virtualized CentOS 6U4 server, who has LVM.

1. Note the existing state
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_server80-lv_root
45G 2.3G 41G 6% /
tmpfs 939M 72K 939M 1% /dev/shm
/dev/sda1 485M 37M 423M 9% /boot

# vgdisplay -v vg_server80
…..
VG Status resizable size can be changed
……
Cur PV 1 number of present discs
Act PV 1
VG Size 49.51 GiB
PE Size 4.00 MiB
Total PE 12674
Alloc PE / Size 12674 / 49.51 GiB
Free PE / Size 0 / 0 there is no unused space on existing disc/LUN-u
…..
— Logical volume —
LV Path /dev/vg_server80/lv_root
…..
— Physical volumes —
PV Name /dev/sda2
…..

# pvscan see all the presented LUNs, but only if they are converted to PE
File descriptor 7 (pipe:[1238093]) leaked on pvscan invocation. Parent PID 9950: bash
PV /dev/sda2 VG vg_server80 lvm2 [49.51 GiB / 0 free]
Total: 1 [49.51 GiB] / in use: 1 [49.51 GiB] / in no VG: 0 [0 ]

2. See which disc is added to system
Find the disc/LUN presented to system, so that “/” can be extended.

How to see added LUN : reset the server and look up dmesg, or, if the already presented discs are /dev/sda (as is the case here) :
# cd /dev/
# ll|grep sd
brw-rw—- 1 root disk 8, 0 Sep 5 15:39 sda
brw-rw—- 1 root disk 8, 1 Sep 5 15:39 sda1
brw-rw—- 1 root disk 8, 2 Sep 5 15:39 sda2
brw-rw—- 1 root disk 8, 16 Sep 5 15:39 sdb

3. Present the newly found disc
# pvcreate /dev/sdb we are creating the Physicah Extends on the new disc
Physical volume “/dev/sdb” successfully created
# vgextend vg_server80 /dev/sdb extending Volume Group
Volume group “vg_server80” successfully extended
# vgdisplay -v vg_server80 check
…..
PV Name /dev/sdb
PV UUID ugCJE6-XBbN-fK9K-y6XU-HnvH-21a0-beUHC9
PV Status allocatable
Total PE / Free PE 511 / 511

We are extending LV for additional 511 PE (physical extends) from our new LUN :
# lvextend -l+511 /dev/vg_server80/lv_root
Extending logical volume lv_root to 47.57 GiB
Logical volume lv_root successfully resized
# resize2fs /dev/vg_server80/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_server80/lv_root is mounted on /; on-line resizing required
old desc_blocks = 3, new_desc_blocks = 3
Performing an on-line resize of /dev/vg_server80/lv_root to 12469248 (4k) blocks.
The filesystem on /dev/vg_server80/lv_root is now 12469248 blocks long.

# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_server80-lv_root
47G 2.3G 43G 6% /
tmpfs 939M 72K 939M 1% /dev/shm
/dev/sda1 485M 37M 423M 9% /boot

Good link.

This entry was posted in Linux and tagged , , . Bookmark the permalink.

Comments are closed.