Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.