Thursday, June 29, 2023

Attach Oracle Cloud Block Volume to OCI Compute Instance

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 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 fee 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”.


2. Click “Create Block Volume”.



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



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





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 “Oracle Cloud Agent” tab page and enable “Block Volume Management” plugin. 


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



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



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



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”.  



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






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



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




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




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





No comments:

Post a Comment

Oracle 23ai: Hybrid Read-Only Mode for Pluggable Databases

  - Overview: Oracle 23ai database introduces a new feature to open Pluggable database in  a new mode called hybrid read-only. Hybrid read-o...