PDA

View Full Version : [SOLVED] Resizing an LVM2 partition (PV)



Renich
17th September 2011, 07:54 AM
Hello,

First, a little explanation of where I am standing:

I have a virtual instance of Fedora 16 running on KVM/Qemu.
The partition table is simple: /boot (500 MB) and lv_root (5.5 GB) (yes, no swap).
Now, I resized the fedora HDD image with qemu-img. It was 6 GB and now it's 7 GB.

I'd like to resize the lvm partition /dev/vda2
how can I do that?

lvresize is not working; neither is pvresize.

I'm trying to make a script that resizes (extends, no reduction) your partition (using rc.local) at boot time. Automatic resizing, eh? ;)

Anyway, I'd appreciate some help regarding the /dev/vda2 resize. It should be better if it's a one-liner; requiring no user interaction.

---------- Post added at 01:51 AM ---------- Previous post was at 12:30 AM ----------

Ok, it's solved. Here's what I did:

First, delete and recreate the partition table:



gdisk /dev/vda (yep, I'm using GPT)
d 2 <enter>
n 2 <enter>
<enter>
<enter>
<enter>
8e00 (this should be your partition type. In this case, this one is a LVM partition)
w (don't forget to write the partition table)

Then, very important, run:

partprobe

in order to update the partitions on your OS. I had to reboot after this... ;=s

Then, everything is sooooo simple:


pvresize /var/vda2
lvresize -r -l +100%FREE /dev/mapper/vg_f16-lv_root

Done!

I'd still would like to automate this. Any bash script proposal (/etc/rc.local) is appreciated! ;)

shisatum
26th September 2012, 09:25 PM
Renich, I'm having the same issue. I did not think this through before acting.
I typed this from the GParted LiveCD: (sda2 is my fedora partition)

gdisk /dev/sda2
d 2
n 2 <enter>, <enter>, <enter>...
w

When I typed partprobe, it did not work, now the file system is still there but it is unrecognizable. What can I attempt to recover the home file? It is all I need.

Thanks in advance for any help!

Renich
27th September 2012, 01:27 AM
Renich, I'm having the same issue. I did not think this through before acting.
I typed this from the GParted LiveCD: (sda2 is my fedora partition)

gdisk /dev/sda2
d 2
n 2 <enter>, <enter>, <enter>...
w

When I typed partprobe, it did not work, now the file system is still there but it is unrecognizable. What can I attempt to recover the home file? It is all I need.
!

Well, I think you got the partition type wrong. Most probably, you have LVM so, try gdisk again, but, this time:



gdisk /dev/sda <enter>
d 2 <enter>
n 2 <enter>
<enter>
<enter>
<enter>
8e00

shisatum
27th September 2012, 02:16 AM
Thank you,

I have now done this and it appeared to work, yet the partition is still recognized as unknown and when I attempt to boot I am stuck at the the grub bootloader.

Renich
27th September 2012, 04:03 AM
Thank you,

I have now done this and it appeared to work, yet the partition is still recognized as unknown and when I attempt to boot I am stuck at the the grub bootloader.

You might want to check /etc/fstab

I am sure it has a UUID reference. Remove that and use /dev/sda2 instead. The UUID surely changed.

shisatum
27th September 2012, 04:22 AM
cat fstab is:

aufs / aufs rw 0 0
tmpfs /tmp tmpfs nosuid,nodev 0 0

Renich
27th September 2012, 05:46 AM
Huh? That can't be. Were is your system?

I think you booted on a LiveCD or something and then tried cat /etc/fstab

If you're using the Fedora Rescue CD, be sure to let it find a system and ask it to mount it. Then, just cat /mnt/sysimage/etc/fstab

anishjp
28th September 2012, 12:20 PM
Hello,

I have a virtual instance of Fedora 16 running on KVM/Qemu.
The partition table is simple: /boot (500 MB) and lv_root (5.5 GB) (yes, no swap).
Now, I resized the fedora HDD image with qemu-img. It was 6 GB and now it's 7 GB.

I'd like to resize the lvm partition /dev/vda2
how can I do that?

lvresize is not working; neither is pvresize.

I'm trying to make a script that resizes (extends, no reduction) your partition (using rc.local) at boot time. Automatic resizing, eh? ;)



Do you see the the free space in your volume group after increasing the HDD size? Check if there are any free physical extends in your volume group



vgscan :- displays all your volume groups


vgdisplay /dev/*****volume group name of lv_root****

lvextend -n /dev/volume_group_name/lv_root -L mazimum sizeM

fsck -f /dev/volume_group_name/lv_root

resize2fs -p /dev/mapper/volume group name-lv_root

check the size of the new file system


df -h

logical volume extension should be done very carefuly or you may break ur system!