2

Resize a LVM partition in a Debian VirtualBox

Have you ever developed in a Debian VirtualBox running out of space? This happened to me some days ago when I have imported the live database for debugging. Following this step by step tutorial, you can increase the disk space.

Increase VirtualBox HardDisk

Open a terminal and go to the folder* of the VirtualBox instance in which you want to resize the partition. You will either find a VMDK or a VDI file. Close VirtualBox before you continue.

For VMDK format

You first have to convert the vdmk file to a vdi file:

VBoxManage clonehd --format vdi filename.vmdk filename.vdi

After this we increase the vdi to 30000 megabytes:

VBoxManage modifyhd filename.vdi --resize 30000

Then we convert the vdi back to vdmk:

VBoxManage clonehd --format vmdk filename.vdi filename.vmdk

For VDI format

We increase the vdi to 30000 megabytes:

VBoxManage modifyhd filename.vdi --resize 30000

Increase partition with a live cd

Since the partition in a VirtualBox is mostly the root partition, we have to boot with a live cd including GParted (Download). Include the CD in your VirtualBox and boot into the live distribution.

Screen Shot 2014-03-27 at 20.29.41

Open GParted, open the partition and resize the space. Now save and click on Apply.

Screen Shot 2014-03-05 at 09.25.24

Power off the maschine and remove the live cd.

Increase the LVM in Debian

Boot into your Debian VirtualBox and extend the LVM with the following command. My LVM was 10 GB before so i had to increase the LVM by 20.

lvextend -L+20G /dev/mapper/vagrant-root
  Extending logical volume root to 29.21 GiB

When you have reached the maximum size, you finally have to resize the filesystem.

resize2fs /dev/mapper/vagrant-root

Your LVM partition is resized now.

 

* You can find the folder when you open VirtualBox -> File -> Virtual Media Manager

Michi

Passion for sports with boards, climbing, mountain biking, traveling, photography, videography and software engineering. /n/n Heilbronn // Germany

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *