LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   How to increase the disk space of /home (http://www.linuxquestions.org/questions/linux-server-73/how-to-increase-the-disk-space-of-home-729535/)

peddip 05-30-2009 12:56 PM

How to increase the disk space of /home
 
Hi,

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??

hasienda 05-30-2009 03:47 PM

You can do that.
 
Quote:

Originally Posted by peddip (Post 3557589)
Hi,

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.

peddip 06-01-2009 01:46 PM

Quote:

Originally Posted by hasienda (Post 3557677)
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.

You mean i will loose the data in my home dir, i dont want to loose the data in my /home. Is there any other way of doing it??

chrism01 06-01-2009 08:10 PM

He didn't say that, he said you lose the data on the sdb2.

hasienda 06-02-2009 05:14 PM

clarification
 
Quote:

Originally Posted by peddip (Post 3559359)
You mean i will loose the data in my home dir, i dont want to loose the data in my /home. Is there any other way of doing it??

As chrism01 said. I just pointed you at the possibility of loosing data in _any_ LVM change operation.

The way I recommended to you will not destroy anything in /home. But there is no guaranty working with data like a professional would do will require to always have a way back. Your and/or others home directory should be definitely on (top of) a list of important data, since you have to expect personal, unique data there, that you could hardly restore from common sources like you'd do in case of an OS restore i.e. from distribution packages. So having a full (working!) backup is right, even if you don't expect data loss at all.

peddip 06-12-2009 01:59 AM

Hi All,

I've increased the disk space of my /home by creating a PV using the sdb2 partition and increasing the size of the VG and LV(/home).

Thanks for your support guys...


All times are GMT -5. The time now is 05:29 AM.