0

I have a Virtualbox VM, with Ubuntu 12 installed in a 8gb disk, with encrypted LVM.

I managed to add a 20gb disk, and now I need to expand the LVM to use those 20gb too, or just copy the entire small disk to the big one and then remove the small one.

How do I do that?

1 Answer 1

1

Assuming the new disk is /dev/sdb, the following is the approach. Make sure you fully understand each of these commands before doing anything:

Create a new physical volume with the disk:

pvcreate /dev/sdb

Add the volume to your volume group:

vgextend <vg> /dev/sdb

Move anything from the 8GB disk to the 20GB (assuming it is /dev/sda)

pvmove /dev/sda /dev/sdb

Remove the 8GB from the volume group:

vgreduce <vg> /dev/sda

Stop /dev/sda being a lvm physical volume:

pvremove /dev/sda

Then you can take it out of the box...

Use the pvdisplay -m commands to confirm what is on each disk:

pvdisplay -m /dev/sda
pvdisplay -m /dev/sdb

You want to be certain nothing is left on the disk you remove.

3
  • Should this work fine even if the partition was encrypted? I didn't have /dev/sda, I had /dev/dm-0. I used that and everything seemed to work. But then I rebooted and got locked out, couldn't go past through the 'enter passphrase:' prompt. That was without removing the old disk in virtualbox. When I removed the old disk, I just got something like 'no bootable disk found!' (also tried moving the new one to port 0). (don't worry, it was a test vm) Jul 5, 2012 at 5:24
  • Ah - you mean you have LVM on top of an encrypted disk, rather than the LVM volumes encrypted?
    – Paul
    Jul 5, 2012 at 6:25
  • When I was installing Ubuntu 12 I chose 'encryped LVM' Jul 5, 2012 at 7:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .