Adding Space to an LVM
Note: This is a snippet from another doc and still needs to be cleaned up. Please follow this with caution. It starts after a modification to a Xen domU machine called 'dev01'.
Adding New Disk in domU to it's PV
Once dom0's LV has been added to domU, you will need to make it available to the domU OS. In this case, we will add it to domU's existing PV.
Log into the VM; We will use dev01 and it's new /dev/xvdb disk for our example.
Preparing the Partition
Use fdisk -l and make sure you now see:
Disk /dev/xvdb: 53.6 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/xvdb doesn't contain a valid partition table
Enter the following:
In fdisk, enter the following:
n # New partition p # Primary partition 1 # Partition number <enter> # First free block <enter> # Last free block t # Change the new partiton's label 8e # To 'Linux LVM' p # Print how the new partition will look and confirm that it is right w # Write the changes to disk and exit.
This should look like:
# fdisk /dev/xvdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. The number of cylinders for this disk is set to 6527. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-6527, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-6527, default 6527): Using default value 6527 Command (m for help): t Selected partition 1 Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM) Command (m for help): p Disk /dev/xvdb: 53.6 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/xvdb1 1 6527 52428096 8e Linux LVM Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Creating the new PV
We need to turn the new partition into a Physical Volume so that we can then add it to the existing Volume Group. Do this by typing:
pvcreate dev01_snap /dev/xvdb1
Wait a few seconds for background steps to complete and then check that it is now visible by LVM as a PV by typing:
If it worked, you should now see this as the output:
--- Physical volume --- PV Name /dev/xvda2 VG Name dev01_vg1 PV Size 244.04 GB / not usable 5.90 MB Allocatable yes (but full) PE Size (KByte) 32768 Total PE 7809 Free PE 0 Allocated PE 7809 PV UUID 2bm15Z-vRGI-yKvp-NvGy-w1eC-mnrM-XE0GQe "/dev/xvdb1" is a new physical volume of "50.00 GB" --- NEW Physical volume --- PV Name /dev/xvdb1 VG Name PV Size 50.00 GB Allocatable NO PE Size (KByte) 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID kJaG6L-R31a-NTRZ-NXT4-1ldP-Egnd-0Z4f1E
Adding the new PV to the Existing VG
Now that we have the second PV, we need to add it to the existing VG. We will continue with this example using the dev01 VM.
To sort out what PV you want to add to which VG, run the following two commands (output shown):
PV /dev/xvda2 VG dev01_vg1 lvm2 [244.03 GB / 0 free] PV /dev/xvdb1 lvm2 [50.00 GB] Total: 2 [294.03 GB] / in use: 1 [244.03 GB] / in no VG: 1 [50.00 GB]
Above, we see the new PV, /dev/xvdb1 is not yet assigned to a VG so we know it's the one we want and that it is ready.
Reading all physical volumes. This may take a while... Found volume group "dev01_vg1" using metadata type lvm2
Above, we see that the existing VG is dev01_vg1. This is the VG that the new PV will be added to.
So then, run:
vgextend dev01_vg1 /dev/xvdb1
Volume group "dev01_vg1" successfully extended
If you see the above output, then it looks like it worked. Rerun pvscan and it should now look like:
PV /dev/xvda2 VG dev01_vg1 lvm2 [244.03 GB / 0 free] PV /dev/xvdb1 VG dev01_vg1 lvm2 [49.97 GB / 49.97 GB free] Total: 2 [294.00 GB] / in use: 2 [294.00 GB] / in no VG: 0 [0 ]
We can see that both PVs are in the same VG.
Now create the mount point that the new snapshot partition will be mounted:
|Any questions, feedback, advice, complaints or meanderings are welcome.|
|Us: Alteeve's Niche!||Support: Mailing List||IRC: #clusterlabs on Freenode||© Alteeve's Niche! Inc. 1997-2019|
|legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.|