Block Volume: Attach & Mount with fstab
Harry
· 14 Sep 2026
· 1 views
Advertisement
Why a block volume?
The boot volume on a free VM is small and ephemeral-tagged. Real data — a MySQL datadir, uploads, backups — belongs on a Block Volume (10 GB free) that you format once, mount and auto-mount with fstab, so a stop/start or rebuild never loses your data.
Create + attach
Block Storage → Block Volumes → Create Block Volume (10 GB, same availability domain as the VM). Then: Attached instances → Attach to instance — pick Attach using ISCSI and run the shown iscsiadm commands on the VM.
Format, mount, auto-mount
sudo fdisk -l | grep Disk # find the new device, e.g. /dev/sdb
sudo mkfs.ext4 /dev/sdb # FORMATS IT - do once, destroys data
sudo mkdir -p /mnt/data
sudo mount /dev/sdb /mnt/data
# persist across reboots via fstab (nofail = boot even if slow):
echo "/dev/sdb /mnt/data ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab
sudo systemctl daemon-reload && sudo mount -a # sanity check fstabMove MySQL onto it safely
sudo systemctl stop mysql
sudo mkdir -p /mnt/data/mysql && sudo chown mysql:mysql /mnt/data/mysql
# point the datadir at the volume (edit /etc/mysql/mysql.conf.d/mysqld.cnf):
sudo sed -i "s|^datadir.*|datadir = /mnt/data/mysql|" /etc/mysql/mysql.conf.d/mysqld.cnf
sudo systemctl start mysql
# confirm it is really using the new disk:
mysql -e "SHOW VARIABLES LIKE 'datadir';"Now the database lives on persistent storage — the nasty “my data vanished after a restart” failure mode is gone.