Monday, January 19, 2015

VirtualBox: Adding a new Hard Drive to Ubuntu

Environment

  1. Oracle VirtualBox 4.3.0
  2. Ubuntu 14.04



Outline

  1. VirtualBox Configuration
    1. Add a new attachment to the Storage Tree
  2. Ubuntu Configuration
    1. Install GParted
    2. Format the Hard Drive
    3. Mount the Hard Drive



Virtual Box Configuration


In the Oracle VirtualBox Manager UI, select the virtual machine you wish to modify.

Once selected, click the "Settings" icon and follow the configuration sequence below:

1. Navigate to the "Storage" menu item, select the SATA controller, and find the option to "Add Hard Disk":

2. Select the "Create new disk" from the dialog box:

3. I prefer to use the VMDK option:
 The Virtual Storage section of the VirtualBox documentation takes up these options in more detail.

4. I prefer to use "Dynamically allocated" storage:

5. Give the new hard drive a name, and optionally choose a new file location.  The hard drive size can be adjusted either via the slider or directly in the input box.

Select "Create" to complete:



Installing GParted


GParted is a free partition editor for graphically managing your disk partitions in Ubutnu.
sudo apt-get install gparted

Successful operational output for me looks like:
 craig@U14BASE01:~$ sudo apt-get install gparted  
 [sudo] password for craig:   
 Reading package lists... Done  
 Building dependency tree      
 Reading state information... Done  
 The following extra packages will be installed:  
  libgtkmm-2.4-1c2a  
 Suggested packages:  
  xfsprogs reiserfsprogs reiser4progs jfsutils kpartx dmraid gpart  
 The following NEW packages will be installed:  
  gparted libgtkmm-2.4-1c2a  
 0 upgraded, 2 newly installed, 0 to remove and 267 not upgraded.  
 Need to get 1,180 kB of archives.  
 After this operation, 6,869 kB of additional disk space will be used.  
 Do you want to continue? [Y/n] Y  
 Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgtkmm-2.4-1c2a amd64 1:2.24.4-1ubuntu1 [655 kB]  
 Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty/main gparted amd64 0.18.0-1 [524 kB]  
 Fetched 1,180 kB in 2s (485 kB/s)  
 Selecting previously unselected package libgtkmm-2.4-1c2a:amd64.  
 (Reading database ... 168329 files and directories currently installed.)  
 Preparing to unpack .../libgtkmm-2.4-1c2a_1%3a2.24.4-1ubuntu1_amd64.deb ...  
 Unpacking libgtkmm-2.4-1c2a:amd64 (1:2.24.4-1ubuntu1) ...  
 Selecting previously unselected package gparted.  
 Preparing to unpack .../gparted_0.18.0-1_amd64.deb ...  
 Unpacking gparted (0.18.0-1) ...  
 Processing triggers for man-db (2.6.7.1-1) ...  
 Processing triggers for hicolor-icon-theme (0.13-1) ...  
 Processing triggers for gnome-menus (3.10.1-0ubuntu2) ...  
 Processing triggers for desktop-file-utils (0.22-1ubuntu1) ...  
 Processing triggers for bamfdaemon (0.5.1+14.04.20140409-0ubuntu1) ...  
 Rebuilding /usr/share/applications/bamf-2.index...  
 Processing triggers for mime-support (3.54ubuntu1) ...  
 Setting up libgtkmm-2.4-1c2a:amd64 (1:2.24.4-1ubuntu1) ...  
 Setting up gparted (0.18.0-1) ...  
 Processing triggers for libc-bin (2.19-0ubuntu6) ...  
 craig@U14BASE01:~$   

Once Gparted is installed, it can be run with root privileges:
sudo gparted


Manage your Disk Partition


The initial screen will look something like this:
Note that the additional hard drive configured in VirtualBox is accessible in the upper-right hand corner.

Select the new hard drive, and "Create Partition Table" from the "Device" sub-menu:

I prefer to use the "gpt" partition type, since it supports drives over 2 TB in size:

Once formatted, right-click on the drive and select "New":

The dialog defaults can be accepted, with the optional addition of a label in the lower right:

Once you click "Add", the status in the lower left will show "1 operation pending".  To execute this operation, click the green check mark in the menu bar:

Go ahead an click "Apply" in the dialog box that appears:

Depending on the size of your drive, this operation may take a few minutes:

Once completed, you should see a dialog box that looks something like this:

Congratulations!  You have now added an additional hard drive to your Ubuntu instance.


Mount the Hard Drive


It's a bit of a cop-out, but the quickest way to mount the new hard-drive is simply by restarting your Ubuntu instance.

Upon rebooting, the new hard drive will be accessible here:

It can also be viewed under
ls /media/username/


Further Reading and References

  1. Edit Mounting Options
    1. Using Dash (the sidebar in Ubuntu), type in "Disks". The software program that comes up will give you the option to edit the mounting options for the disk. 
  2. Changing Permissions

1 comment: