OCI Instance with External Block Volume
Hari Bantwal
Posted on November 9, 2023
There are moments when simple tasks can slow down our progress, often because they're not part of our regular routine. A recent experience brought this to my attention when I decided to delve into self-hosting for Windmill.dev and Supabase.
I realized that I needed external references to navigate the foundational aspects due to the multitude of available approaches. This post serves as a record of this experience, with the hope that the lessons learned can be valuable in future, more intricate endeavors.
Objective: Provision Instance in OCI, with external Block volumes to cater to Different Docker Services
Create compute instance through OCI Console
Create Instance
With below information:
Image: Oracle Linux 8
Shape: Ampere VM.Standard.A1.Flex
Cost: CHF 2.00/month
Subnet: Public
Add SSH Keys: Yes
Create Block Volumes through OCI Console
Create Block Volume
With below information:
Volume size: 50 GB Estimated Price: CHF 0.02301885/GB
Volume performance: Balanced 10 VPUs at CHF 0.00153459/PU/GB
IOPS: 25,000 IOPS (60 IOPS/GB)
Attach the Block Volume to the Instance
Navigate to Attached Instances on Block Volume Screen
Attach with below information
Attachment type: ISCSI
Access Type: Read/Write
Instance: Created in Step 1
Device path: /dev/oracleoci/oraclevdb
Run iSCSI commands & information
iSCSI commands to connect should be run using the commands shown "Attached Block Volumes"
Remote SSH to the Instance to run the commands
ssh -i <Your SSH Private Key> opc@<PUBLIC_IP>
sudo iscsiadm -m node -o new -T ...
sudo iscsiadm -m node -o update -T ...
sudo iscsiadm -m node -T ...
Create Disk Partition, Create File System Mount File System
sudo fdisk -l /dev/oracleoci/oraclevdb
sudo mkfs -t ext4 /dev/oracleoci/oraclevdb
Mount file system
sudo mkdir /vol
sudo mount /dev/oracleoci/oraclevdb /vol
OCI Block Volume is now mounted on Instance under the path /vol
Entry in /etc/fstab file for mounting after instance restart
/dev/oracleoci/oraclevdb /var/html-bv ext4 defaults,_netdv,nofail 0 2
How to Detach
- Unmount the drive
sudo umount /vol
- Run the disconnect commands
sudo iscsiadm -m node -T iqn....
sudo iscsiadm -m node -o delete -T iqn....
Find the commands below iSCSI commands & information
- Detach the instance
Blockvoulume is extended, How to make it available
After extending the Blockvolume, commands to run for repartition
ubuntu@instance-wordpress-template-755807:~$ sudo parted /dev/oracleoci/oraclevdb
GNU Parted 3.4
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit s
(parted) print
Model: ORACLE BlockVolume (scsi)
Disk /dev/sdb: 4294967296s
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 2048s 2147483647s 2147481600s primary ext4
(parted) rm 1
Warning: Partition /dev/sdb1 is being used. Are you sure you want to continue?
Yes/No? Yes
Error: Partition(s) 1 on /dev/sdb have been written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further
changes.
Ignore/Cancel? Ignore
(parted) mkpart
Partition type? primary/extended? primary
File system type? [ext2]? ext4
Start? 2048
End? 100%
(parted) quit
Information: You may need to update /etc/fstab.
Resize the extended Block Volume
sudo resize2fs /dev/oracleoci/oraclevdb1
df -h
Posted on November 9, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.