Appearance
Attach Block Storage to an Instance
Instances usually come with a root disk, but for persistent data storage that exists independently of the instance's lifecycle (and can be moved between instances), you should use Volumes (Block Storage).
This guide walks you through creating a volume, attaching it to a running instance, and configuring it within the Linux operating system.
Prerequisites
- A running Compute Instance (Linux).
- Access to the Horizon Dashboard.
- Available Volume storage quota.
Steps
Checklist: None
Sign in to Horizon
Use your browser to navigate to the Stud I/O Cloud Compute Control Panel (Horizon) or use the button below:
🌐Open HorizonSign in and choose the appropriate Project.
Create a Volume
First, create the storage volume in the same availability zone as your instance.
- Navigate to Volumes > Volumes.
- Click Create Volume.
- Volume Name: Give it a descriptive name (e.g.,
db-data-vol). - Size (GiB): Enter the desired size (e.g.,
50). - Availability Zone: Ensure this matches the zone where your instance is running.
- Click Create Volume.
Attach Volume to Instance
Once the volume status is Available:
- In the Volumes list, find your new volume.
- Click the arrow/dropdown in the Actions column and select Manage Attachments.
- Attach to Instance: Select your target instance from the dropdown list.
- Click Attach Volume.
- Note the Device Name provided (usually
/dev/vdbor similar).
Verify Device in Instance
Now, log in to your instance to configure the storage.
- SSH into your instance:bash
ssh ubuntu@<your-instance-ip> - List block devices to confirm the new disk is attached:bashYou should see a device (e.g.,
sudo lsblkvdb) with the size of your volume, likely without partitions.
Format the Volume
Warning: This step erases all data on the volume. Only do this for new volumes. If attaching an existing volume with data, skip to the Mount step.
- Create an
ext4filesystem on the device:bashsudo mkfs.ext4 /dev/vdb
Mount the Volume
- Create a directory to serve as the mount point:bash
sudo mkdir /mnt/data - Mount the volume manually to test:bash
sudo mount /dev/vdb /mnt/data - Verify it's mounted:bash
df -h | grep vdb
Configure Automount (fstab)
To ensure the volume mounts automatically after a reboot, add it to /etc/fstab.
Get the UUID of the new volume:
bashsudo blkid /dev/vdbCopy the UUID string (excluding quotes).
Open
/etc/fstabfor editing:bashsudo nano /etc/fstabAdd a new line at the end (replace
<UUID>with your actual UUID):textUUID=<your-uuid-here> /mnt/data ext4 defaults,nofail 0 2Save and exit (Ctrl+O, Enter, Ctrl+X).
Verify the configuration by unmounting and mounting all:
bashsudo umount /mnt/data sudo mount -aIf no errors occur, your configuration is correct.
Troubleshooting
- Volume stuck in "Attaching": Wait a few moments. If it persists, check the instance logs.
- "Device busy" when unmounting: Ensure no open files or shells are currently inside the
/mnt/datadirectory. - Permission denied: Remember to use
sudofor administrative commands likemountand editing/etc/fstab.