Header RSS Feed
 
If you only want to see the articles of a certain category, please click on the desired category below:
ALL Android Backup BSD Database Hacks Hardware Internet Linux Mail MySQL Monitoring Network Personal PHP Proxy Shell Solaris Unix Virtualization VMware Windows Wyse

Dynamically increase physical volume (PV) in an LVM setup on a VM
Tuesday - Jun 28th 2016 - by - (0 comments)

The VM's (running in a VMware environment) serving as LXC hosts were setup in a way, that the volume group (VG) used for the containers, can be dynamically increased without downtime.

The classical and probably easiest way is to just add a new virtual disk to the VM, create a new PV of this disk and use vgextend to add the new PV to the existing VG.

A nicer method however (as least imho) is to increase the already used virtual disk/PV.

Before I touched anything, I check the current available space of the volume group:

vgs
  VG       #PV #LV #SN Attr   VSize  VFree
  vglxc      1   5   0 wz--n- 50.00g 6.00g
  vgsystem   1   2   0 wz--n-  6.61g 1.96g

1. In VMware you can increase the disk's size given you still have space in your volume.

2. You need to tell your OS (in my case this is an Ubuntu 14.04) that it should rescan the scsi bus to detect changes. As I increased the second disk, which is seen as /dev/sdb, I launched the following command for this:

echo 1 > /sys/class/scsi_device/2\:0\:1\:0/device/rescan

If you're not sure which device number your disk (again, in my case sdb) has, you can easily double-check the device path by checking /sys/block/sdb/device:

ll /sys/block/sdb/device
lrwxrwxrwx 1 root root 0 Jun 28 09:08 /sys/block/sdb/device -> ../../../2:0:1:0

3. Now you can verify that your disk's size has changed. I used fdisk:

fdisk -l /dev/sdb

Disk /dev/sdb: 75.2 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 cylinders, total 146800640 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

(the previous size was 20GB smaller)

4. All you need to do now is to tell LVM that the physical volume (ergo /dev/sdb in my case) has changed it's size:

pvresize /dev/sdb
  Physical volume "/dev/sdb" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

5. Check again the available space of the volume group:

vgs
  VG       #PV #LV #SN Attr   VSize  VFree
  vglxc      1   5   0 wz--n- 70.00g 26.00g
  vgsystem   1   2   0 wz--n-  6.61g  1.96g

VoilĂ . 20GB more space for my containers without downtime.

Note: This only works "that easy" because I used the complete disk /dev/sdb as physical volume. There are no partitions on sdb. If there were, it would be mandatory to increase the partition as well.

 

Add a comment

Show form to leave a comment

Comments (newest first):

No comments yet.

Go to Homepage home
Linux Howtos how to's
Monitoring Plugins monitoring plugins
Links links

Valid HTML 4.01 Transitional
Valid CSS!
[Valid RSS]

6938 Days
until Death of Computers
Why?