How to attach block volume to VM instance in OCI

As a lot of cloud providers offer a free tier option of their products now, i wanted to run some tests on the Oracle Cloud Infrastructure (OCI) and encountered some actually trivial problems on how to increase the volume of my instance.

TLDR:
After attaching you block volume you also need to partition, format and eventually mount bind your volume. But let’s not jump ahead of ourselves.

1. Creating resources

By using the webconsole, one can easily create the resources. However be sure to pick the same availability domain for both the block volume and the instance.

block volume resource
VM instance resource

2. Attaching block volume to instance

Now you have to make both resources relate to eachother by attaching the volume to the VM instance. You can do that by clicking on your instance > Attached block volumes > Attach block volumes.

Pick your block volume in the drop down menu, alternatively you can also input the OCID of the block volume which is a global resource identifier.

Attaching block volume to isntance

3. Run the predefined iSCSI command

If you ssh into your VM you would not see the new volume. It (appears) that you have to register it first by running the predefined iSCSI commands. You can find them by clicking on the three vertical dots of the attached block volume

lsblks does not show any new partitions
Run the iSCSI commands first

From here on you out you are free to use the block volume as any other disk. For completness’ sake the next part will be following the tutorial of phoenixnap.com.

4. Create a partition

Using lsblk you can now see, that the system recognizes a new disk device.

However if you try to mount the disk without partitioning , like i did (mind you it was already late) you will get the error “wrong fs type, bad option, bad superblock on /dev/sdb, missing codepage or helper program, or other error

To partition a disk use the following command

 sudo fdisk /dev/sdb

To create a new partition press n.

Afterwards follow through the interactive menu. For simplicity just hit enter to use the default values.

To write the changes press w at the end.

You can see a new disk sdb has been recognized
partitioning a disk using fdisk

5. Format the partition

 sudo mkfs -t ext4 /dev/sdb1

6. Mount the partition

 sudo mkdir -p /mt/sdb1
 sudo mount -t auto /dev/sdb1 /mt/sdb1

Leave a Comment

Your email address will not be published.