Originally Posted by peddip
I have a RHEL4 server in which i had configured LVM. I had added secondary HDD sdb and created 2 partitions sdb1 and sdb2 of which sdb1 was created as LVM and added it to existing VG (/home dir) when there was space crunch and i mounted sdb2 as another mount point. Is there any way to increase the size of the VG created earlier using the sdb2 partition??
My problem here is i'm running out of space in my /home dir which is created as VG.I'm not sure whether i can use sdb2 partition and increase the VG size??
The quick answer: YES. :-)
More verbose: It is possible with at least the following steps:
* backup/move/delete data in file system on sdb2
* change sdb2 to partition type lvm
* add sdb2 as PV to VG, that is used for LV containing home's data (old data lost now)
* unmount LV mounted as /home
* check file system before changing it (fsck)
* grow file system of the LV
* mount your bigger LV to /home again
Why does it work - or - The story behind:
A volume group (VG) is formed from at least one physical volume (PV). A PV is a hard disk partition created with type lvm. Finally inside a VG you create the logical volume (LV). LVs are like hard disk partitions, but with LVM the whole VG is seen like a single hard disk and partition size can be changed during - almost - normal OS operation. However, you need a file system to format, mount and use space of a LV in your system.
You can add more PVs to a VG at any time and expand existing LVs to use them, thats why you have LVM, not a "solid" partition schema. If you have enough free space to move all used stripes away from a PV to other PVs in the same VG, you could even remove it as well.
To use an expanded LV, you have to resize (grow) the file system (ext2/ext3/reiserfs/xfs/..). But be careful, before you shrink a PV you'll have to shrink the file system inside it, or you'll corrupt it. Not every file system supports both, growing and shrinking. You should know and choose accordingly before the first use, not when your volume is filled. BTW, freeing blocks exclusively reserved for the superuser might give you time to learn more about LVM before you change anything.
Some more sentences of caution: You may corrupt your file system in the process and need a fresh backup. Sure, you have a backup, haven't you? If this is a production system, our LVM is built on top of RAID devices. Use what suites your needs and what you can afford.
Newer rely on LVM entirely. However, it's great. I've not lost data while changing partitions inside a LVM system within the last 4 years, using both, LVM and LVM2, the current.