Attach Oracle Cloud Block Volume to OCI Compute Instance

Share on:

Block Volume provides network storage to use with your Oracle Cloud compute instances. After you create, attach, and mount a volume to your instance, you can use it just as you would a physical hard drive on your computer. A volume can be attached to a single instance at a time, but you can detach it from one instance and attach it to another instance, keeping your data intact.

In this blog, we will cover the steps to attach Block Volume to an existing OCI compute instance.

 

Prerequisites:

  • An Oracle Cloud free trial or paid account
  • OCI Virtual Cloud Network (VCN)
  • OCI compute instance located in a VCN’s private subnet or public subnet with API RSA private key

 

Step #1: Create a Block Volume

1. Open the navigation menu and click “Storage”. Under “Block Storage”, click “Block Volumes

cloud

 

2. Click “Create Block Volume”.

cloud2

 

3. In the “Create block volume” dialog window, enter the volume name, and select compartment and availability domain. Under the “volume size and performance” section, select the “custom” option and specify the block volume size. Leave all other options as default and click “Create Block Volume

cloud3

cloud4

 

Once you create volume, new block volume information will be as shown below

cloud5

 

Step #2: Attach Volume to OCI Compute Instance

1. Enable Block Volume Management Cloud Agent: Open the navigation menu and click Compute. Under Compute, click Instances. Click your compute instance name to view its details. Navigate to the “Oracle Cloud Agent” tab page and enable the “Block Volume Management” plugin

cloud6

 

2. Open the navigation menu and click “Storage”. Under “Block Storage”, click “Block Volumes”. Click your block volume name to view its details. Under the “Resources” section, click “Attach Instances”, then click “Attach to Instance

cloud7

 

3. In the “Attach to instance” dialog window, select “Attachment type” – ISCSI (default), “Access Type” – Read/Write (default). Under the “Instance” section, select compute instance tick option “Use Oracle Cloud Agent to automatically connect to ISCSI-attached volumes”, then click “Attach

cloud8

 

Note: block volume will be automatically attached to compute instance, so there is no need to run ISCSI Commands

cloud9

 

Step #3: Format and mount Block Volume from within Compute Instance

1. SSH to your compute instance (you can use cloud shell to access the instance). Run “lsblk” Linux command to get the list of volumes/devices. In this example, the device path is “/dev/sdb

cloud10

 

2. Create a new device partition using “fdisk” Linux command as shown below

cloud11

cloud12

 

3. Format a new device partition using “mkfs” Linux command as shown below

cloud13

 

4. Mount a new partition using the “mount” Linux command as shown below.

cloud14

 

5. Permanently mount the device by adding the below entry to “/etc/fstab” file

cloud15

 

Now block volume is permanently available in OCI compute instance for read/write access!

Share on:

More from this Author

Oracle 23c INTERVAL Data Type Aggregations

MySQL: Updating the Configuration of a MySQL DB System on OCI

Overview: A MySQL configuration is a collection of variables that define the operation of a MySQL DB system. It is analogous to ... Read More

Oracle 23c INTERVAL Data Type Aggregations

Oracle 23c: INTERVAL Data Type Aggregations

Overview: Oracle 23c introduces the use of SUM and AVG functions with INTERVAL datatype This enhancement makes it easier to calculate totals and ... Read More

Back to Top