?
Solved

Using LVM to expand existing Linux directory

Posted on 2003-03-17
8
Medium Priority
?
664 Views
Last Modified: 2013-12-16
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
0
Comment
Question by:kidwong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 1

Expert Comment

by:Jaem
ID: 8158508
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)
0
 

Author Comment

by:kidwong
ID: 8163838
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
0
 
LVL 1

Expert Comment

by:Jaem
ID: 8166372
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...
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

Author Comment

by:kidwong
ID: 8171228
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
0
 
LVL 1

Accepted Solution

by:
Jaem earned 2000 total points
ID: 8173461
Hi kidwong,

The big picture: put everything in hda2. Check if it works. Backup. Repartition to your taste, and put everything back into place.

I got to try this first on my RH7.3, but those are the steps I would take:
1) Modify /etc/grub.conf, so it could boot with root device /dev/hda2 (instead of /dev/hda6).
2) Boot with the CD/rescue CD. Mount /dev/hda2 read-write, create a /usr directory and move everything into it. Then I would mount /dev/hda3 (resp. /dev/hda5, /dev/hda6) (read-only, so not to mess anything), copy all of its files under the directories /var (resp. /home, /) relative to the mount point.
3) Create a swapfile in /dev/hda2 mount point directory. Do "dd if=/dev/zero of=swapfile bs=1024k count=256" and "mkswap swapfile".
4) Modify /etc/fstab (hda2) (after: backing it up): Comment out every ref to partition others than hda2 and hda1. Create an entry for the swapfile:
/swapfile  none   swap    defaults 0 0
5) unmount all, reboot, select the grub entry for booting with /dev/hda2 as root, and check everything is OK, especially check that hda3, hda5, hda6, hda7 are not used (use "mount" and "swapon -s").
5bis) Emergency recovery: Undoing the changes is easier. Boot in rescue mode, mount /dev/hda2, remove all directories except /usr, then move everything in /usr to the root.

Now I would do a raw backup the partitions we are about to destroy (A CD writer would be good). I need to work the details out, cause it's something I really don't want to mess.

Then you should be ready to reorganize your partitions: you can do about anything to /dev/hda3, /dev/hda5... Everything is temporarily working on /dev/hda2, and you got backups. Do you still want to go the LVM route? Else you got to choose the resizing/partition editing software. I don't know what redhat got on its CD...

Only thing that bothers me about the current layout of your disk, is that the extended partition (/dev/hda4) is way too small, and /dev/hda2 is a bit too big (it might be a good idea to shrink it first to 5G). Getting rid of /dev/hda3 would be good also.

Another thought. You wouldn't have any hard drive lying around, would you? Temporarily connecting another harddrive is useful for moving things around and/or quick backups.

Tell me what you think.
0
 

Expert Comment

by:CleanupPing
ID: 9076620
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.
0

Featured Post

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month8 days, 22 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question