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 linux hard drive with three areas:

  • /dev/hda1 - ext3 boot partition (20 MB)
  • /dev/hda2 - lvm2 main partition (6 GB)
  • unpartitioned space - 12 GB

I would like to merge the unpartitioned space into the lvm2 partition known as /dev/hda2. I tried using GParted, but it does not support lvm2.

What commands or utilities could I use to add the unpartitioned space to hda2 without losing my existing data?

share|improve this question

Put the unpartitioned space into its own partition, then use pvcreate then vgextend on it.

share|improve this answer

You can also 'resize' the second partition, then run pvresize on it. You would use fdisk instead of parted - it's uglier, but slightly lower level. Record the existing partition table, particular the start of the second partition, then delete the second partition, and recreate it with the same start point, system type (8e, Linux LVM) but the maximum end point allowed. Then you should reboot (the kernel cannot normally update partition tables for disks that are in use) and afterwards pvresize /dev/sda2. Now your Volume Group will be bigger. This method leads to arguably neater results, but is more fraught with danger and requires a recent set of LVM tools and kernel (you neglected to mention your Linux distribution/version) ; Ignacio's method is probably safer.

No matter which method you use to put the free space into the Volume Group, you will now need to expand your Logical Volume and the filesystem therein. See lvextend and resize2fs.

share|improve this answer

<friendlyreminder> Before proceeding, make sure you have backups if you have anything important stored on your disk. </friendlyreminder>

I would go for Norky's method. Two "physical" LVM volumes on a same disk extending as a same volume group and logical volume is not the best thing to have when talking about performance.

In normal desktop use you probably won't see a difference, but still I think that resizing the current LVM volume to be bigger would be the way to go. Just go ahead with Norky's suggestion and remember to also resize your filesystem afterwards :)

share|improve this answer

You must log in to answer this question.

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