Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have a VPS (based on KVM, not sure which storage technology) for about two years now. It's mainly a learning machine, a utility proxy, or a seldom-used VPN gate, or whatever--no real work, no problem with downtime for few days.

So after I purchased it two years ago, I partitioned it using LVM with result like this:

  • one 10GiB physical disk
  • two partitions: /boot and LVM, together eating 100% of the disk space
  • on the LVM partition, several "normal" partitions like /, swap and /home

Now I have purchased additional space from the ISP. They did their magic so after reboot, there is another 10GiB of unpartitioned space.

I'm not exactly sure what is the correct next step. What I did in hope I'll see what are my options is that I went and booted into a SysResCD , but the GParted version provided does not support LVM. (New SysResCD shipped with GParted, with LVM support, already exists.)

Anyway, since I hear that LVM is supposed to make things easier, I suspect that this is not the correct way in the first place. (Actually I even suspect that using LVM within KVM might have been crazy idea in the first place, since well, at this moment, it might well looks like: partitions in LVM in KVM in another LVM on a set of physical disk in RAID...)

So what to do next: should I ask ISP to provide new SysResCD and continue what I started? Or is it easier now to simply move everything out of the LVM and fix the installation?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

There's no need to move out of LVM, and you do't need GParted to support doing LVMish things. Simply create a new partition from the additional space, then simply pvcreate it, vgextend your volume group into it, and you can then eithe grow your existing LV's or create new LV's.

share|improve this answer
Simply create a new partition from the additional space ..but what FS should I use? –  Alois Mahdal Sep 10 '13 at 19:40
You don't. Like I said, you create the partition, run "pvcreate" on it, then extend your vg with "vgextend". If you want a new filesystem, then create a new logical volume, and use whatever filesystem suits your use case. Or you can extend an existing logical volume and grow the filesystem. –  John Sep 10 '13 at 19:43
OK, I 1. created an unformatted partition; 2. changed type to LVM using cfdisk, 3. ran pvcreate /dev/sdx, vgextend myvg /dev/sdx 4. lvextend /dev/myvg/root -L 1G, 5. rebooted, but df -h still shows the old size –  Alois Mahdal Sep 10 '13 at 20:20
I also tried lvresize after lvextend with no effect. Also tried to write up to original 100% -- write still fails. –  Alois Mahdal Sep 10 '13 at 20:22
You never grew the filesystem, so of course df won't show you the new size. You didn't need to reboot. man resize2fs. –  John Sep 11 '13 at 12:06

John's answer a high-level overview, which was necessary to get me started. After doing some more research with his help, what I actually ended up doing was:

  1. I created a new unformatted partition

    I used mentioned GParted. Since it does not support LVM, thus did not offer the "Linux LVM" partition type, I had to choose unformatted and change the type manually.

    Obviously using cfdisk or other tool right away (from a live system) would be far easier.

    Also it's worth noting that contrary to what I expected, new partition did not get the last number as in /dev/sdaN. Instead it got /dev/sda3 even if /dev/sda5 was already occupied. IIRC, this applies to partitioning logic: primary partitions are always numbered 1-4, whereas extended start at /dev/sda5

  2. then used cfdisk to change partition type to "Linux LVM" (0x8E),

  3. next, I did pvcreate /dev/sda3 to create the actual LVM partition

  4. and vgextend myvg /dev/sda3 to include the new partition in my (single) volume group.

Finally, for each "space-hungry" partition I

  1. ran lvresize /dev/myvg/mypart -L 1G to resize it ("mypart" is name I gave it long ago during installation)

  2. and resize2fs /dev/myvg/mypart to actually resize the file system to size of underlying partition (default behavior for resize2fs).

Note that since resizing does not require remounting (ext3/ext4, Linux 2.6), in my case whole operation could be performed on-line without any downtime. (Yeah, dear occasional reader from Windows world! :))

share|improve this answer

You just need to increase the size of the existing partition, then tell lvm about the increased size, then add or resize any logical volumes as you see fit.

If you have a recent enough version of parted, then you can use its resizepart command to resize the existing partition holding the pv. If you must use an older version of parted, then put it into sector mode with the unit s command, then print the existing table, and note the exact sector the current partition starts on, then rm that partition, and then recreate it with mkpart. The default filesystem of ext2 is fine, and make sure you use the exact same start sector, then you can allocate 100% of the space on the disk to the partition. If you used resizepart then you don't even have to reboot, but if you used the older method you will. After that, pvresize /dev/sda2 will tell LVM about the new size, which you can use to create new volumes, or resize existing ones with lvresize. After resizing the logical volume, you need to tell the filesystem about it with resize2fs, assuming you are using ext[234].

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.