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.

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.

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.

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.

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.

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

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.

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.

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.

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.

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

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

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.

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

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.

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

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.

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

The new disk was now 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.

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