Virtualbox

How can we install VirtualBox?

You can install VirtualBox using your Operating System package manager, or you can download it from https://www.virtualbox.org/wiki/Downloads, and install it the way you typically install any other software. After the main VirtualBox software is installed, we will also need to download the extension pack from the same web site.

How can we install an OS onto a VirtualBox VM?

First, we need to create a new VM:

  1. Launch VirtualBox if it is not running
  2. In the VirtualBox console, click on New and follow on-screen instruction

Obtain the installation media for your desired Operation System. For Fedora, Ubuntu, and other Linux distribution, you can download appropriate ISO file from the Internet. In the VirtualBox console, click on the VM that you just created, and click Start. VirtualBox will then display a screen where you can specify the drive that contains the installation media. If you have an ISO file, you can click on the folder icon to select appropriate ISO file and then click on the Start button.

After the guest operating system is installed, click on Device and select Insert Guest Additions CD image. This will install the extension pack, which allow us to resize the VM, and handle seemless mouse integration.

What is the purpose of extension pack and what is the purpose of guest addition?

The purpose of extension pack is to allow for external devices to work correctly, like USB. The purpose of guest additions is to add drivers to allow Guest to work with underlying H/W, like Display H/W

How can we resize the disk?

This procedure is fairly easy and straight forward, but, as always, whenever we manipulate a hard disk partition, there is always a risk of corruption or losing data, so we must first create a back-up copy of our VM.

Stop the VM if it is currently running.

Go to the folder that contains the VM. For me, when I initially install Virtualbox and the first VM, I chose to keep all the VMs in "C:\Users\Khai\VirtualBox VMs". So, go to the folder that contains your VM, and make a back-up copy of that folder.

Now, increase the maximum size of your virtual disk:

cd "C:\Program Files\Oracle\VirtualBox"
VBoxManage modifyhd "C:\Users\Khai\VirtualBox VMs\Ubuntu\Ubuntu.vdi" --resize 20480

The above command does something but if we start up the VM now, we still do not see the disk resized yet, because we still have resize the partition inside the VM.

Download GParted Live CD from http://gparted.sourceforge.net/download.php. Load the ISO file into your virtual machine by going into the virtual machine’s settings window, selecting your virtual CD drive, and browsing to the ISO file on your computer. Boot your virtual machine after inserting the ISO image and the virtual machine will boot from the ISO image. GParted’s live CD will ask you several questions while booting – you can press Enter to skip them for the default options.

Once GParted is booted, right-click the partition you want to enlarge and select Resize/Move. Specify a new size for the partition – for example, drag the slider all the way to the right to use all the available space for the partition. Click the Resize/Move button after you’ve specified the space you want to use. Finally, click the Apply button to apply your changes and enlarge the partition.

After the resize operation completes, shutdown your virtual machine and remove the GParted ISO file. Start your virtual machine. The OS may check the file system for integrity. Do not interrupt this check. The virtual machine’s partition will now take up the entire virtual hard disk, so you’ll have access to the additional space.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License