Friday, 4 November 2016

Extend an LVM volume on your linux server

What:

Linux: Red Hat, Centos

Problem:

Your Linux box is running out of space.

Solution:

To extend space on your lvm volume you will need to:

1. Add new disk to your system
2 .My new device has been detected as /dev/sdb

If your new disk is not detected you can reboot the system or send a rescan request using command below:
echo "- - -" > /sys/class/scsi_host/host0/scan
You can use entire disk as a phisical volume in an LVM volume group, but it's recommended in "RHEL6 Logical Volume Manager Administration LVM Administrator Guide" and LVM howto "11.1. Initializing disks or disk partitions" that you create a partition.

3. Create new partition and set type to 8e which is Linux LVM
fdisk /dev/sdb
or
cfdisk /dev/sdb
4. Create phisical volume
pvcreate /dev/sdb1
5. Find volume group name, which you want to extend
vgdisplay or pvs or df
6. Add your new disk to the volume group
vgextend vg_name /dev/sdb1
7. Confirm new free size with one of the following commands
pvs or vgdisplay or pvscan
Your volume group has now some free space, which you can allocate to logical volume/s

8. List your volumes
lvdisplay
9. Extend space on your volume by adding 10GB
lvextend -L +10G /dev/mapper/vg_name-LogVol
optionally allocate all available space
lvextend -l +100%FREE /dev/mapper/vg_name-LogVol
10. Resize file system
resize2fs /dev/mapper/vg_name-LogVol

Check your free space with df

No comments:

Post a Comment