You are not logged in.

#1 2010-08-16 06:53:29

xintron
Member
From: Sweden
Registered: 2008-09-25
Posts: 32
Website

Resize LVM partition

I'm running qemu-kvm on my server for my virtual machines. All VPS uses an LVM-volume created on the host. Now I need to extend one volume and make the guest's root partition larger. This was done by lvextend on the host which extended my 5GB volume to 30GB. The guest partition-table looks like this:

 1      17.4kB  10.0MB  9983kB
       10.0MB  10.5MB  485kB   Free Space
2      10.5MB  5365MB  5354MB  ext4
       5365MB  21.5GB  16.1GB  Free Space

Running resize2fs on /dev/sda2 (the ext4 partition) on my guest gives me the following: `The filesystem is already 1307136 blocks long.  Nothing to do!` but as you can see from the partition-table above there are free space left.

I think I would be able to create a new partition, assign all free space to that partition but that's not what I want. It would have to do as a backup solution but the optimal would to extend the sda2-partition while online (the VPS will remain online at all time). So, any thoughts on this? Would it work to somehow change the partition-table making sda2 bigger and then telling the kernel about it while mounted?

Offline

#2 2010-08-16 08:08:48

kosmiciatakuja
Member
Registered: 2010-01-27
Posts: 46

Re: Resize LVM partition

The only thing that I can think of that could cause this is if the 5 gig ext4 partition is a logical partition (and therefore inside an extended partition). If this is so, you first have to resize the extended partition and then you can resize the logical partition inside. I'd recommend viewing this drive in gparted if you can fire up a graphical environment of some sort. Gparted shows this logical partition inside an extended partition very good graphically, it's easier to see and manage.

Last edited by kosmiciatakuja (2010-08-16 08:11:23)

Offline

#3 2010-08-16 08:29:17

xintron
Member
From: Sweden
Registered: 2008-09-25
Posts: 32
Website

Re: Resize LVM partition

kosmiciatakuja wrote:

The only thing that I can think of that could cause this is if the 5 gig ext4 partition is a logical partition (and therefore inside an extended partition). If this is so, you first have to resize the extended partition and then you can resize the logical partition inside. I'd recommend viewing this drive in gparted if you can fire up a graphical environment of some sort. Gparted shows this logical partition inside an extended partition very good graphically, it's easier to see and manage.

Can't fire up a graphical environment. But the main thing is to extend the partition if I understand you correctly? Last time I tried to resize the partition in parted I got an error saying that it wasn't possible while the partition is mounted.

Offline

#4 2010-08-16 09:12:21

kosmiciatakuja
Member
Registered: 2010-01-27
Posts: 46

Re: Resize LVM partition

Well, yes you have to resize the partition but I feel LVM already did this for you (I may be mistaken here). If you can't use graphical, try just parted, it can do the same things as gparted but doesn't give you the nice visual overview.

Also, if the partition must be mounted (for example it's the root partition) then in order to resize it I would recommend to boot the machine (or VM) with a different system, like arch live ISO and resize from there. If you can't do that, google about "online resizing", it's sometimes possible but I never done that myself so I can't help you there.

And to get back to my original point about extended vs logical partitions, let me illustrate with an example hdd layout of partitions:

<sda1> <sda2>  <sda3 [sda5] [sda6] [sda7]> <sda4>

in this layout sda1, sda2 and sda4 are primary partitions
sda3 is an extended partition
sda5, sda6 and sda7 are logical partitions and they are all contained inside sda3 (the extended partition).

so, if you would like to resize for example sda7, and there would be no space inside sda3, you would first have to enlarge sda3 and then enlarge sda7 and only then do a 'resize2fs /dev/sda7'

of course this is just my guessing, if your partition is primary then you can simply resize it (using lvm or whatever tool available) and resize the fs inside with resize2fs and just ignore my babbling above smile

Offline

Board footer

Powered by FluxBB