Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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.

share|improve this answer
    
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) – HappyDeveloper Jul 5 '12 at 5:24
    
Ah - you mean you have LVM on top of an encrypted disk, rather than the LVM volumes encrypted? – Paul Jul 5 '12 at 6:25
    
When I was installing Ubuntu 12 I chose 'encryped LVM' – HappyDeveloper Jul 5 '12 at 7:13

You must log in to answer this question.

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