Extending a volume group with currently unallocated space?

Hello,

I installed OpenSuse 11.0 late last year and I left little less than half of my drive unallocated. The idea was to install Windows Vista there later. However, I installed Vista to VirtualBox and it seems to work well enough there so I don’t think I will proceed with a “native” install for now anyway.

Since half of the drive is now unused I would like to reclaim this unallocated space to Linux. I’m using LVM and assuming that it can be done.

Before I start playing around with the partitioning tools, I would be grateful if someone could have a look at my “plan” as there is a good chance of wiping everything and I’ve never done this before.

My current partition table as listed by fdisk -l is as follows:


Device      Boot      Start    End         Blocks   Id  System
/dev/sda1   *           1       9           72261   83  Linux
/dev/sda2              10   71807       576717435   8e  Linux LVM

I was thinking of the following:

  1. Create a new partition starting from 71708 to the end of the drive

  2. Initialize the partition for use by LVM (YaST2 or pvcreate directly)

  3. Extend the existing volume group with the physical volume (partition) created in step 1 using vgextend, if not possible using YaST2 (LVM Configuration / Add Volume?)

  4. Adjust the logical volumes as necessary so that the new space is used.

Hopefully I’m not totally off the track - this is my first Linux installation with LVM.

Help is greatly appreciated,

nissu

I’m slightly puzzled as to what you are trying to do; normally you create a Volume Group containing certain physical disks; you then create logical volumes within that group.

Are you saying that you have a Volume Group within which you have only created logical volumes for part of the Volume Group? If so, there shouldn’t be a problem in creating more logical volumes within that Volume Group.

Ok, I’m trying to clarify my question a bit.

I have a one terabyte drive, of which I have partitioned only 550 gigabytes. I have one volume group (550 gigabytes), inside which I have logical volumes. The logical volumes fill up all the available space in the volume group, i.e. 550 gigabytes.

Almost half of my hard drive is now totally unused and unpartitioned, because I thought I would install Vista there later, which I’m not going to do.

I would like to know if there is any (easy) way to make the unused half accessible, preferably so that in the end I could just extend the logical volume for /home.

I have never done this so this is based on theory; normally a Volume Group is defined by the UUIDs that it contains. If you did it that way, you presumably gave a UUID to that part of the disk that was not in the Volume Group.

Can you identify each part of your system by UUID and identify which UUID relates to the Volume Group?

This is what I was able to gather using lvm:


# lvm vgdisplay
  --- Volume group ---
  VG Name               system
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               550.00 GB
  PE Size               4.00 MB
  Total PE              140800
  Alloc PE / Size       140800 / 550.00 GB
  Free  PE / Size       0 / 0
  VG UUID               6i5IGK-fCoB-g2rh-5352-Z137-Qvaz-65pd3Z


# lvm pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               system
  PV Size               550.00 GB / not usable 635.00 KB
  Allocatable           yes (but full)
  PE Size (KByte)       4096
  Total PE              140800
  Free PE               0
  Allocated PE          140800
  PV UUID               Nd1SjI-pbEk-K04U-26mJ-NB8w-d4Ne-S059Bj

I just realised that I could install OpenSUSE into VirtualBox, create a similar lvm scheme (i.e. leave half of the hard drive unused) and experiment safely with the lvm tools there.

My interpretation of that information is that the issue is what in the old days was called block size. The PE size is 4Mb and the maximum number have been allocated on the disk.

One reason for partitioning physical disks used to be to keep block size down to avoid wasting space particularly with short files.

I presume as physical disk sizes get larger, it will once more be advantageous to partition them to use the space more efficiently.

Hmm, I don’t know. I’m quite sure I have lots of unpartitioned space on my drive :slight_smile:

Have a look at the image below:

http://img16.imageshack.us/img16/1302/partitionsa.png

I had a go at this. I installed OpenSUSE 11.0 into VirtualBox with a 40 gigabyte virtual disk. I left about half of it unpartitioned, just like I’ve done on my real physical hard drive.

This was the starting point after installation:

http://img40.imageshack.us/img40/7885/snapshot10i.png

As you can see, the drive is not used after cylinder 3000.

I started the system in repair mode using the installation CD, fiddled with Expert Partitioner, i.e. added a new partition with the type Linux LVM, added that to my volume group, extended existing logical volumes to use all available space and ended up with this:

http://img40.imageshack.us/img40/8640/snapshot17.png

The above is what I wanted. I had to increase swap to 3 gigs, because otherwise the tool claimed that you have no swap, even though it was listed.

Clicking Next at this point offered a quite weird description of what the tool was about to do:

http://img40.imageshack.us/img40/7373/snapshot18.png

Not surprisingly I ended up with a system which didn’t boot anymore. I reverted back to a working snapshot of the virtual machine and tried again.

On the next attempt I did everything in small steps, i.e. created the new partition, selected Next in Expert Partitioner, accepted the confirmation and then added the physical volume to volume group, again selecting Next in Expert Partitioner, and so on. This time the orange confirmation boxes started to make sense. Create a new partition xxx? Extend existing volume group? No complaints about missing swap either.

It seems that the virtual machine installation works fine now and all of the virtual drive is utilised. I’m not going to try this on my real installation without backups though…

Thanks for your time John - it could be that I was not able to describe properly what I wanted to achieve, but it seems to be doable, although you have to be very careful with the Expert Partitioner.

it’s a little bit tricky to extend a VG but it works (for me) like this:
Create a new VG on the partition(s) you want to add, do NOT add any LV to this group.
open a terminal session and merge this new group with the existing group (vgmerge -v (-t) existing new) see man pages for vgmerge and lvm
unmount the VG
with the YAST partitioner or from a command line (vgresize or so, see man page lvm) resize the VG to it’s new size and mount it again.
If you can not unmount the partition because it’s /usr or so, do this procedure from a live CD. You can download a live CD from opensuse.org

With this method i could expand my /usr and /home partitions with left over space from an old Windows installation :slight_smile: .

have fun and sorry 4 bad english :wink:
Arthur

I hear what you are asking and I am attempting to do the same thing right now…
Have you ever received or learned how to do what you were/are seeking?

The difference is I do not have any of the 4 partitions remaining to create a new partition.
What I see I have to do is, extend the existing partition (sd4) onto the unused disk space.
I do not see a way using 'fdisk) to extend the end of an existing partition.
So I believe I may delete the partition as long as I recreate it using the exact START value
and the new END Value. (I did this and was able to mount my filesystem!! phew) BUT
the Volume group still believes the VG is 550GB not the 1TB, so somehow I need to extend the
VG or tell the VG the disk it resides on is 1TB not 550GB… (How I do not know), and next
I would extend the LV and the FS withint the LV…

(AIX can do this, dynamically with a command… but why would I expect LVM to work the same
on Linux? sarcasitcally rhetorical)

you do realize that you are reviving a 6yo post? LOL :slight_smile:

although I never used LVM (and hopefully would never need to)
but couldn’t you just boot into recovery CD
use something like gparted to resize the partition to fill the disk and than expamnd the LVM onto new space? this should be the less destructive option, maybe?
I might be wrong but you need to boot into recovery cd so the partition is not mounted.
although if the said partition is not your boot or “/” and only used for data store couldn’t you just unmount it and use gparted to resize it?

Is this a MBR format drive? so max partitions you can have are 4 You would need to change one partition to a extended then add additional as logical in the extended to make it work.