How do you add more space to a Fedora (LVM) partition?

13

6

In a nutshell, i have a VM that ran out of space. I increased the size of the VM's harddrive to be 4 times bigger but the OS partition is still only using 1x the space. I need to change the LVM partition to take up the extra 4x space but I don't know how to extend the LVM partition.

(NOTE: To make the screenshots given below I had to boot from a live-cd for gnome-partition-manager (aka gparted). Very unfortunately gparted is only able to "detect LVM" and can't do any LVM operations.)

Here is what "gparted" shows. Please notice that the "resize" option is not available:

enter image description here


The Problem:

I can't find good directions<1> on how to grow the LVM partition via GUI or command-line! How do you grow a LVM partition that was created by the default Fedora install?

If you are giving command line directions. Please explain what each line of commands does.

Trevor Boyd Smith

Posted 2011-09-13T13:33:54.283

Reputation: 2 093

1Anyone who does a default fedora install has this partition setup, I'm surprised no one else has run into this problem... fedora has such a large install base of users. – Trevor Boyd Smith – 2011-09-14T14:15:04.587

Update: I marked one of the answers as correct. I was unable to verify that the answer marked as correct worked on my VM... the process was to complex for me to get working. – Trevor Boyd Smith – 2013-01-08T20:57:05.527

Update: I ended up backing up data. Creating a new VM from scratch and restoring the data. – Trevor Boyd Smith – 2013-01-08T20:57:27.603

Answers

14

I thought I used to do this with system-config-lvm GUI tool in CentOS, but it's not working for me today. So I had to go old school. As always, this might destroy your data, so MAKE A BACKUP!! Thanks to experts across the internet for providing these hints. Unfortunately my notes do not include attribution details. Note I performed all of these changes while the system was live.

  1. Enlarge the disk using fdisk
    1. fdisk -l (to see the partition layout, typically we're dealing with /dev/sda2)
    2. fdisk /dev/sda
    3. d (delete a partition)
    4. 2 (if the part we want to grow is /dev/sda2; note this does not delete any data on disk)
    5. n (create a new partition)
    6. p (primary partition)
    7. 2
    8. <return> (default starting block, typically 14 since swap is first)
    9. <return> (default ending block, full size of the partition)
    10. make sure partition type is 8e for Linux LVM
      1. t
      2. 8e
    11. w (write changes to disk)
  2. reboot to get new partition table
  3. pvresize /dev/sda2
  4. pvscan should show new larger size
  5. lvextend -l +100%FREE /dev/vg_centos6/lv_root (-L +10G to add 10GB is another option)
  6. resize2fs /dev/vg_centos6/lv_root
  7. df should show new free space

MichaelS

Posted 2011-09-13T13:33:54.283

Reputation: 156

perfect , when we want resize root partition , we just need boot with boot.iso (for example http://mirrors.eu.kernel.org/fedora/releases/18/Fedora/x86_64/os/images/boot.iso) -> troubleshoot -> rescue (after choose 3rd option not mount) -> shell and do yours instructions :)

– Sérgio – 2013-05-21T22:03:47.670

I love you! I've spent hours trying to do just this! – Rob Forrest – 2014-01-07T15:26:54.830

1

The command lvextend can help you. For instance,

lvextend -L +54 /dev/vg01/lvol10 /dev/sdk3

tries to extend the size of that logical volume by 54MB on physical volume /dev/sdk3. This is only possible if /dev/sdk3 is a member of volume group vg01 and there are enough free physical extents in it.

Dimitri

Posted 2011-09-13T13:33:54.283

Reputation: 258

i would love to get a little bit more... i'm guessing that calling this command by itself without any input arguments would probably not fix the problem. – Trevor Boyd Smith – 2011-09-14T14:21:40.550

how do you know to use "/dev/vg01/lvol10". where did you get that from? – Trevor Boyd Smith – 2011-09-14T14:57:00.257

why did you put "/dev/sdk3"? – Trevor Boyd Smith – 2011-09-14T14:57:28.213

Sorry, i was busy. The /dev/sdk3 is the physical volume of your machine. For instance, for you, it might /dev/sda2. The /dev/vg01/lvol10 – Dimitri – 2011-09-14T15:59:33.667

Hi, sorry I was busy. This command is for example purpose only. It depends how do you install lvm in your system. The /dev/vg01/lvol01 is the logical volume 01 on the volume group 01. The /dev/sdk3 is the partition where the volume group is installed. In your case, the physical partition is /dev/sda2. So you must find what the volume group associated with this partition. http://bobcares.com/blog/?p=137

– Dimitri – 2011-09-14T16:18:06.287

that blog posting will probably solve what i need. but FML... the post is so damn long. when i get around to reading it and trying it... i will maybe repost here. – Trevor Boyd Smith – 2011-09-14T19:55:13.373