How to Resize an Oracle VirtualBox Disk

Document created by samuel on Aug 5, 2016Last modified by Karen Whipple on Aug 5, 2016
Version 3Show Document
  • View in full screen mode

 

Note:  This document is intended for users running a MapR Sandbox on Oracle’s VirtualBox who would like to resize the disk.  For instructions on how to achieve the same objective with VMware, see the article https://community.mapr.com/docs/DOC-1608.

 

The root volume that is included with the MapR Sandbox is just large enough to run the VM. If you run the 'df -h' command, you will be able to see that you have around 8GB of space on this.

 

# df -h
Filesystem Size  Used Avail Use% Mounted on
/dev/mapper/vg_maprdemo-lv_root 8.4G  8.0G     0 100%  /
tmpfs 2.9G     0  2.9G   0%  /dev/shm
/dev/sda1 477M   41M  411M  10%  /boot
localhost:/mapr 100G     0  100G   0%  /mapr
localhost:/mapr/demo.mapr.com/user 15G  5.2G  9.8G  35%  /user

 

The instructions below illustrate how to extend the volume.

 

Platform: Oracle VirtualBox running on MacOS X El Capitan

 

Step 1: If you are using a .VMDK file, then you would need to clone it to a .VDI format first. Open a terminal window on your mac, navigate to the place on your disk where the .vmdk file is present@@ and use the below command:

 

Command: VBoxManage clonehd <infilename or UUID> <outfilename> --format VDI --variant Standard

 

Example: VBoxManage clonehd "MapR-Sandbox-For-Apache-Drill-1.6.0-5.1.0-disk1.vmdk" "MapR-Sandbox-For-Apache-Drill-1.6.0-5.1.0-disk1.vdi" --format vdi

 

Swap this .vdi file in the place of the .vmdk file on your virtualbox.

 

Step 2: To increase the size of the drive, type the command given below in the terminal window:

 

Command: VBoxManage modifyhd <absolute path to file> --resize <size in MB>

 

Example: VBoxManage modifyhd "MapR-Sandbox-For-Apache-Drill-1.6.0-5.1.0-disk1.vdi" --resize 30000

 

Step 3: Extend the primary partition to include the new drive space. Download the GParted LiveCD or whatever partition manager program you want to use, mount it to the guest's virtual CD, and boot the guest (both in VirtualBox). From here you can expand the primary partition to use the new space.

 

Download Link for GParted - https://sourceforge.net/projects/gparted/files/gparted-live-stable/0.22.0-1/

 

In order to see the GUI of GParted, you have to enable the EFI mode on your VirtualBox. Please refer the screenshot below.

 

Also, you have to change the boot order to change the precedence such that the “Optical Disk” comes before the “Hard Disk.” Please refer the screenshot below to see where this setting is in the VirtualBox.

 

Accept the defaults and resize the disk you want. Please follow this blog for a

step-by-step process on how to achieve the same:

https://tvi.al/resize-sda1-disk-of-your-vagrant-virtualbox-vm/

 

Step 4: Use pvresize to expand the existing PV to the new top-of-partition.

 

Example: pvresize /dev/sda2

 

Step 5: Use lvresize or lvextend to resize the existing LV volume(s) into the enlarged PV.

 

Example: lvextend /dev/mapper/vg_maprdemo-lv_root -L +18G

 

Step 6: Use resize2fs to resize the file system(s) into the new enlarged volume(s).

 

Example: resize2fs /dev/mapper/vg_maprdemo-lv_root

 

You should be able to see the resized disk space now.

2 people found this helpful

Attachments

    Outcomes