How to add a new disk to an Oracle Linux VirtualBox VM

I realised a few days ago that the 40 GB virtual hard disk of my Oracle Linux VM only had a few GBs left and that I would soon need more space to store additional data. Therefore I decided to add a new virtual disk and I have documented all the steps in this tutorial.

 Add a new hard disk to a Virtual Machine
Add a new hard disk to a Virtual Machine

First, I launched VirtualBox and I accessed the Oracle Linux VM Settings. I selected the Storage section and I clicked the “Adds hard disk” button.

Add hard disk
Add hard disk

It opened the Hard Disk Selector window with a list of disks currently attached to a VM or not. I wanted to create a new virtual disk so I clicked the “Create” button.

Create Disk Image
Create Disk Image

The “Create Virtual Hard Disk” assistant asked me to choose the type of file to use for the new virtual hard disk. I was going to use this virtual disk with a VirtualBox VM only so I chose the “VirtualBox Disk Image” VDI format and I clicked the “Next” button.

VirtualBox Disk Image format
VirtualBox Disk Image format

The next step was to choose whether the new virtual hard disk space would be dynamically allocated on the physical disk or whether it would have a fixed size (the full virtual disk size). I chose “dynamically allocated” because I wasn’t sure I would use the whole virtual disk. The file was going to be stored onto a M.2 SSD so the two options should have had similar speed performance anyway.

Dynamically allocated hard disk file
Dynamically allocated hard disk file

The next step asked me to choose the virtual hard disk file location as well as its name and its size. I chose a name, I entered 40 GB for the disk size and I clicked the “Create” button to create the virtual hard disk file

Create a 40 GB virtual hard disk
Create a 40 GB virtual hard disk

Once created, the new virtual disk file appeared in the list of not attached hard disks. I selected it and clicked the “Choose” button to add it to the VM.

Choose Virtual Hard Disk file
Choose Virtual Hard Disk file

The new virtual hard disk was now attached to the VM. The file was only 2 MB large right now because its space was dynamically allocated on the physical hard drive.

New Virtual Hard Disk added to the VM
New Virtual Hard Disk added to the VM

I started the VM and I logged in as oracle. I used the “Activities” menu on the left to access the “Show Applications” button. I opened the “Utilities” folder and I chose the “Disks” Application to format and mount the new hard disk.

Oracle Linux - Disks Application
Oracle Linux – Disks Application

The Disks application showed me a list of disks currently detected by the VM. I selected the disk I had just created (the second one in the list). It was not yet formatted and therefore appeared with an “Unknown” content. I clicked the “Additional partition options” button (the one with two gears) to access more options.

Unformatted disk
Unformatted disk

I selected the “Format Partition…” menu to format the new volume.

Format Partition
Format Partition

 

I gave a name to the Volume (data), I chose Ext4 for the filesystem type and I clicked the “Next” button.

Format Volume Options
Format Volume Options

There was a warning telling me that all data on the volume would be lost. I clicked the red “Format” button to confirm that I wanted to format the new disk.

Warning message
Warning message

I had to authenticate to perform the format operation. I entered the password and I clicked the “Authenticate” button.

Authenticate
Authenticate

The format was very quick and after just a fraction of a second I could see that the new drive had been formatted but that it was not yet mounted.

New disk formatted but not mounted
New disk formatted but not mounted

I clicked the “Additional partition options” button again and I selected the “Edit Mount Options” menu this time.

Edit Mount Options
Edit Mount Options

I deactivated the “User Session Defaults” option to access the additional options. I kept the “Mount at system startup” and “Show in user interface” options activated and I used the disk label (data) to mount the partition as “/mnt/data“. Finally I clicked the “OK” button to make the changes.

Mount Options
Mount Options

I had to authenticate again to add the new entry into the /etc/fstab file.

Authenticate again
Authenticate again

The new disk was now mounted as /mnt/data.

/dev/sdb mounted as /mnt/data
/dev/sdb mounted as /mnt/data

I opened a Terminal window and I checked with the “ls -l /mnt” command that the new partition appeared as /mnt/data.

ls -l /mnt/data
ls -l /mnt/data

Perfect, I was now ready to use this new volume to store the data. We will see in a future tutorial how to move the Oracle databases files to this new volume.

The post How to add a new disk to an Oracle Linux VirtualBox VM appeared first on MyBIJourney

All trademarks are properties of their respective owners.
FacebookTwitterPinterestWhatsAppMail