Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server machine running CentOS 6.2. It is configured using LVM mapping as it is the default and I didn't see any problem with going that way.

I have a 500Gb drive in there right now, and 54Gb is at the root directory, while 442Gb is mounted to /home

Since this is a server, I just started putting all the files I needed to share in /home/sharedFiles and it has been working fine. However, I have run into a bit of an issue... or what I think will be an issue.

I have recently been installing some machines via KVM for experimentation and to have a test machine to make configuration changes to rather than changing the main system(which is, more or less, how I want it, all extra packages removed, etc.) As you may imagine, allocating a 10gb virtual disk to these machines has been eating away at my space. I'd rather not put these in /home since I consider that an OS level thing and not just my files. Is there a way I can move around/extend/shrink the LVM volumes? I actually would actually like most of my main hard drive split up for OS stuff, the Web Server files, and other storage that does not need to be redundant (Install media for Linux distros which are kept there for convenience, etc.) while a RAID array will handle my personal data. Is this kind of configuration possible without taking the system offline for an extended period of time?

EDIT: In fact, I tried to place the KVM images in /home and couldn't, so this is my only option.

share|improve this question
up vote 1 down vote accepted

Depends on the available space you have, the FS (ext3 I suppose) you have on /home. Generally, the idea is:

  1. Shrink Filesystem to the number of GB you need.
  2. Shrink the Logical Volume of the LVM
  3. Create a new Logical Volume
  4. Format that LV

So, let's go step by step: All steps executed as root. I assume that your /home is the /dev/mapper/home or /dev/sda2. Use the devices of your case.

  1. Shrink FS:

    umount /dev/mapper/home, or whatever is you /home or umount /dev/sda2

    resize2f2 /dev/sda2 350G

    350G is the NEW size.

  2. Shrink LV

    Execute as root:


    It must show you something like the following:

    LV Name /dev/system/home

    This is the logical volume you need to shrink. So, execute:

    lvreduce -L 350g system/home

    That will reduce the LV to the correct size.

  3. Create a new LV

    Now, you have 92GB free. So, let's create a new LV of that size:

    lvcreate -l 100%FREE -n kvmlv system

    That command creates a new logical volume named kvmlv in the Volume Group system. You can find your Volume Group either by the /dev/mapper, or by the vgdisplay command

    Now, you are ready to create you new FS. I would recommend to use ext4.

    mkfs.ext4 /dev/mapper/system-kvmlv

Now you are ready to mount it.

share|improve this answer
So there's no way to add to the existing \dev\dm-0 (the root partition)? Like in Windows, I know you can extend a partition if there is free space on the drive. I guess I am looking for something similar to that. – Kyle Jul 14 '12 at 20:10
If I understand correctly, what you want to do, no. – Peter Jul 15 '12 at 4:33
Ok, assuming it is not possible to do that, is there any way to back up my installation(just the Main OS, config, etc.), reprovision the drive with LVM, then install it just as it is now? Sorry, I'm kind of new to Linux but trying to learn. I thought this server project would get my feet wet with some of the more advanced admin stuff and eventaully want to start using linux at least 50% of the time on the desktop side. – Kyle Jul 16 '12 at 12:59
I cannot help you very much on that. And the reason is that you have YOUR setup, I have MINE. I do not have a deep knowledge of your system, so, I could say something wrong. In principle, yes, you can take a full back and restore everything back. Amanda is a nice backup solution. Depending on what you want to backup (eg just your files, or your /home?) even rsync could be the tool for you. – Peter Jul 23 '12 at 16:18
I finally figured out how to do it. I just had to take the volume offline, shrink it, then take the other volume offline and grow it to the amount of space the LVM had left. I totally understand not wanting to post something that will screw up someone else's system. Also, about the backup thing, I wanted to backup my actual OS. I have a backup of the files in /home, but I have done enough custom config on this machine that I didn't want to lose it. – Kyle Jul 23 '12 at 18:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .