Adding a data disk is one of the first jobs on any new server. On OCI it has one extra decision, the attachment type, and one classic trap, an fstab entry that hangs the boot.
Step 1: create the volume
The volume must be in the same availability domain as the instance.
oci bv volume create --compartment-id $COMP --availability-domain "$AD" \
--display-name data01 --size-in-gbs 200 --vpus-per-gb 10 --wait-for-state AVAILABLE
--vpus-per-gb sets the performance tier: 0 lower cost, 10 balanced (default), 20 higher performance, and higher for ultra high performance. You can change it later without detaching.
Step 2: choose the attachment type
| Type | How it works | Pick when |
|---|---|---|
| Paravirtualized | Hypervisor presents the disk; appears automatically | Default for most VMs; simplest |
| iSCSI | Instance connects to the volume over iSCSI | Ultra-high performance tiers, some bare metal cases, multipath |
Paravirtualized is the easier start: no commands inside the OS to connect it.
Step 3: attach
oci compute volume-attachment attach --type paravirtualized \
--instance-id $INSTANCE --volume-id $VOLUME \
--device /dev/oracleoci/oraclevdb --wait-for-state ATTACHED
Using a consistent device path (/dev/oracleoci/oraclevdb, oraclevdc, ...) gives a name that does not change between reboots. List the available ones:
oci compute device list-instance-devices --instance-id $INSTANCE --is-available true --query 'data[].name'
For iSCSI attachments, the console shows iSCSI commands & information with the iscsiadm commands to run on the instance. Run them, or enable the Block Volume Management plugin in Oracle Cloud Agent to do it automatically.
Step 4: format and mount
On the instance:
lsblk
ls -l /dev/oracleoci/
sudo mkfs.xfs /dev/oracleoci/oraclevdb
sudo mkdir -p /data
sudo mount /dev/oracleoci/oraclevdb /data
df -h /data
Caution
mkfserases the disk. Run it only on a new, empty volume, and double-check the device name withlsblkfirst.
Step 5: make it permanent, safely
Use the UUID or the consistent device path, and always add nofail (and _netdev for iSCSI):
sudo blkid /dev/oracleoci/oraclevdb
echo 'UUID=<uuid-from-blkid> /data xfs defaults,_netdev,nofail 0 2' | sudo tee -a /etc/fstab
sudo umount /data && sudo mount -a && df -h /data
nofail means a missing volume does not drop the instance into emergency mode at boot. _netdev waits for the network before mounting, which iSCSI volumes need; it is harmless for paravirtualized ones.
Test with mount -a before rebooting. An fstab typo found after reboot means a trip to the serial console.
Grow it later
oci bv volume update --volume-id $VOLUME --size-in-gbs 400
Then on the instance rescan and grow the filesystem (paravirtualized volumes usually see the new size after a rescan; the console shows the exact rescan commands):
sudo dd iflag=direct if=/dev/oracleoci/oraclevdb of=/dev/null count=1
echo "1" | sudo tee /sys/class/block/sdb/device/rescan # device name from lsblk
sudo xfs_growfs /data
Detach cleanly
sudo umount /data
# remove or comment the /etc/fstab line
oci compute volume-attachment list --instance-id $INSTANCE --query 'data[?"volume-id"==`'"$VOLUME"'`].id' --raw-output
oci compute volume-attachment detach --volume-attachment-id $ATTACH --force --wait-for-state DETACHED
For iSCSI volumes, log out of the iSCSI target on the instance first (the console lists the disconnect commands).
Common problems
| Problem | Cause | Fix |
|---|---|---|
Disk not in lsblk (iSCSI) | iSCSI login not run | Run the attach commands or enable the plugin |
| Boot hangs in emergency mode | fstab entry without nofail | Serial console, comment the line |
| Mount lost after reboot | Not in fstab, or wrong device name | Use UUID or /dev/oracleoci/ path |
| Cannot attach | Volume in a different AD | Clone or restore a backup into the right AD |
Prevent it next time
- Always
nofailin fstab for data volumes. - Assign a backup policy (
bronze,silver,gold, or a custom one) when you create the volume. - Use consistent device paths in automation.