Link to home
Start Free TrialLog in
Avatar of kidwong
kidwong

asked on

Using LVM to expand existing Linux directory

Hi all,

    It is my first time to ask question. I am using Redhat 8.0 for the servers in my office (one with IDE and one with SCSI HDD). Recently, the space for the for the /home directory is running out of space. Someone tell me that I can use LVM to resize and make use of the free space in other partitions (e.g.: /usr and /var) (sorry for using the word 'partition' as I can't think of another better word).

    However, when I read the information about LVM, it said that creating the LVM logical volume will distory the information in that directory. As I have never created it before, is it the case if I create one in my server? It is not affordable for me to have another new hard disk.

    On the other hand, if I choose to format the harddisk (this is the last step if nothing can do), what I need to do in order that I can resize the logical volume in the server?

    The following are some information all the system:
- Redhat 8.0 (kernel 2.4.18-26.8.0)
- with /, /home, /usr, /var, /boot
- LVM module LVM version 1.0.3
- not create any logical group and volume before

    Thank you for any suggestion.

William
Avatar of Jaem
Jaem

To use LVM, you will have to destroy your existing partitions, and recreate them as LVM ones. I have two possible solutions:
1) Real easy, but not very elegant. Create a home directory in /usr (I suppose it is where you got most of your free space) and create symbolic links in /home to corresponding directories in /usr/home as need arises.
2) Use resize2fs/fdisk or parted to rearrange your partitions. This might be tricky and dangerous, so you will need to do backups. resize2fs will shrink or expand e2/3fs. fdisk will modify your partition size. parted should be able to do both at once. You might even be able to create LVM. Could you tell us more about the size/layout of your harddrive? (fdisk -l /dev/hda)
Avatar of kidwong

ASKER

Thank you Jaem,

The following is the layout of the harddrive:

Disk /dev/hda: 255 heads, 63 sectors, 1222 cylinders
Units = cylinders of 16065 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1   *         1        13    104391   83  Linux
/dev/hda2            14       842   6658942+  83  Linux
/dev/hda3           843       969   1020127+  83  Linux
/dev/hda4           970      1222   2032222+   f  Win95 Ext'd (LBA)
/dev/hda5           970      1033    514048+  83  Linux
/dev/hda6          1034      1071    305203+  83  Linux
/dev/hda7          1072      1103    257008+  82  Linux swap

By the way, for the second suggestion, I am not sure how to implement as I have never done that before. Could you explain a little bit detail? Thank you

William
The plan might be:
1) Shrink a big partition (either with parted, or shrinking the fs (resize2fs), then the partition (fdisk)).
2) Use the freed space!

Now I realize I need much more information about your layout. Could you post the output of "df". That would tell me what is
/dev/hda2 (6.5Gig, /home ?)
/dev/hda3 (1Gig, /usr ?)
/dev/hda5 (500Meg, /var ?)
/dev/hda6 (300Meg, / ?)
And maybe look into etc/fstab to make sure that the filesystems are ext3.

Also could you give an estimate of how much space you want in your /home directory.

Apparently you got 1 Gig of free disk space left (you can create an hda8 partition). And if my layout is about right, it might be possible to temporarily move the hda5 hda6 hda7 partitions on a temporary location, and free them. Then you would get 1 more gig to play around with...
Avatar of kidwong

ASKER

Hi Jaem,

The following is the result of df -h:
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda6             289M   93M  180M  34% /
/dev/hda1              99M  9.0M   84M  10% /boot
/dev/hda5             486M  480M    5M  98% /home
none                   57M     0   57M   0% /dev/shm
/dev/hda2             6.3G  3.8G  2.1G  64% /usr
/dev/hda3             980M  144M  786M  16% /var

All of the filesystem are ext3. And I would like to have 2 Gig free space for /home.

Thanks for your help and looking forward to having your reply.

William
ASKER CERTIFIED SOLUTION
Avatar of Jaem
Jaem

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
kidwong:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.