How to Attach Additional Block Volume in Oracle Cloud Instance

black internal hdd on black surface

As I continued rolling out new features across several services in my infrastructure, I noticed disk space was starting to run low. Fortunately, my Oracle Cloud instance still had some unallocated block volume available, but since I wasn’t too familiar with the Oracle Cloud Console, I had to figure things out as I went.

In this post, I’ll walk you through the exact steps I took to attach and mount a new block volume on my instance. If you’re in a similar situation or just getting started with OCI, I hope this guide saves you time and confusion.

Attach the Block Volume via OCI Console

Before accessing the disk in Linux, attach it via the Oracle web interface:

  1. Open the navigation menu and select Compute.
  2. Under Compute, click Instances.
  3. Under List scope, select the compartment that contains your instance.
  4. In the list of instances, click the name of the instance you want to attach the volume to.
  5. In the Resources section (left sidebar), click Attached block volumes.
  6. Click Attach block volume.
  7. Choose the volume you created earlier and click Attach.

Once attached as ISCSI, you should run the iscsi command which is provided when you click the three dots at the right of your instance name.

They will provide you with attach command, that’s all you need to run. Something like:

sudo iscsiadm -m node -o new -T iqn.xxx -p xxx:xxxx
sudo iscsiadm -m node -o update -T iqn.xxx -p xxx:xxxx -n node.startup -v automatic
sudo iscsiadm -m node -T iqn.xxx -p xxx:xxxx -l

If you don’t have iscsiadm, make sure you have open-iscsi installed before:

sudo apt update
sudo apt install open-iscsi

Once attached, the disk will appear in your instance, usually as /dev/sdb, /dev/sdc, etc.


Check Available Disks

Use lsblk to inspect attached storage:

lsblk

You’ll see something like these output:

sda       8:0    0  46.6G  0 disk
├─sda1    8:1    0  46.5G  0 part /
└─sda15   8:15   0    99M  0 part /boot/efi
sdb       8:16   0    50G  0 disk

Here, sdb is an extra 50 GB disk with no partitions. Time to prepare it.


Create a Partition

Run fdisk to create a new partition:

sudo fdisk /dev/sdb

In the prompt:

  • n – New partition
  • p – Primary
  • 1 – Partition number
  • Press Enter twice to accept default first and last sectors
  • w – Write and exit

Format the Partition

Format the new partition as ext4 (or your filesystem of choice):

sudo mkfs.ext4 /dev/sdb1

Mount the New Partition

Create a directory to mount the disk:

sudo mkdir /mnt/data

Then mount it:

sudo mount /dev/sdb1 /mnt/data

Verify with:

df -h

Make the Mount Persistent (Survive Reboots)

Find the UUID of your new partition:

sudo blkid /dev/sdb1

Example output:

/dev/sdb1: UUID="abcd1234-5678-90ef-ghij-klmnopqrstuv" TYPE="ext4"

Edit the fstab file:

sudo nano /etc/fstab

On Oracle Cloud Infrastructure (OCI), your /etc/fstab might include this reminder:

# If you are adding an iSCSI remote block volume to this file you MUST
# include the '_netdev' mount option or your instance will become
# unavailable after the next reboot.

So when working with remote iSCSI block volumes, always:

Since this is an iSCSI volume, add _netdev:

UUID=abcd1234-5678-90ef-ghij-klmnopqrstuv /mnt/data ext4 defaults,_netdev 0 2

Save and close. Test it without reboot:

sudo mount -a

If there’s no error, you’re good to go! Confirm your new storage with:

lsblk
df -h

Now that additional storage is ready to use! 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *