LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 05-30-2009, 12:56 PM   #1
peddip
Member
 
Registered: Dec 2008
Posts: 51

Rep: Reputation: 16
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??
 
Old 05-30-2009, 03:47 PM   #2
hasienda
Member
 
Registered: May 2009
Location: Saxony, Germany
Distribution: Debian/GNU Linux
Posts: 36

Rep: Reputation: 18
Exclamation You can do that.

Quote:
Originally Posted by peddip View Post
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.
 
Old 06-01-2009, 01:46 PM   #3
peddip
Member
 
Registered: Dec 2008
Posts: 51

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by hasienda View Post
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??
 
Old 06-01-2009, 08:10 PM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,232

Rep: Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024Reputation: 2024
He didn't say that, he said you lose the data on the sdb2.
 
Old 06-02-2009, 05:14 PM   #5
hasienda
Member
 
Registered: May 2009
Location: Saxony, Germany
Distribution: Debian/GNU Linux
Posts: 36

Rep: Reputation: 18
clarification

Quote:
Originally Posted by peddip View Post
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.
 
Old 06-12-2009, 01:59 AM   #6
peddip
Member
 
Registered: Dec 2008
Posts: 51

Original Poster
Rep: Reputation: 16
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...
 
  


Reply

Tags
linux, lvm, redhat, volume


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i increase hard disk space cyrilbritto Linux - Hardware 5 08-26-2011 07:15 AM
hard disk partitioning/I am out of space /how to increase linux space? RMLinux Red Hat 8 09-05-2008 12:33 PM
increase space on /home partition v1nc3nt Linux - Newbie 1 10-11-2006 03:56 AM
how to increase the hard disk space of linux? hari78 Linux - Newbie 5 03-01-2005 05:09 AM
Increase hard-disk / space in FreeB noir911 *BSD 0 05-01-2004 09:57 PM


All times are GMT -5. The time now is 08:44 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration