Block Storage - Quickstart
Scaleway Block Storage provides network-attached storage that can be plugged in and out of cloud products such as Instances like a virtual hard-drive. Block Storage devices are independent of the local storage of Instances, and the fact that they are accessed over a network connection makes it easy to move them between Instances in the same Availability Zone. From the user’s point of view, once mounted, the block device behaves like a regular disk.
You may need certain IAM permissions to carry out some actions described on this page. This means:
- you are the Owner of the Scaleway Organization in which the actions will be carried out, or
- you are an IAM user of the Organization, with a policy granting you the necessary permission sets
- You have an account and are logged into the Scaleway console
- You have created an Instance
How to create a Block Storage volume
- Click Instances from the left side menu. The Instances section displays.
- Click Volumes to display a list of all your current volumes.
- Click Create volume to create a volume that can be attached to any of your Instances.
- Choose a region for the volume.
Important:
The volume must be in the same region as the Instance you want it to connect to.
- Select Block Storage when configuring the volume. Enter the volume name and select a size.
- Click Create volume to confirm the creation of the volume.
How to attach a Block Storage volume to an Instance
- Click Instances from the left side menu. The Instances section displays.
- Click Volumes to display a list of all your current volumes. The newly created volume displays on top of the list.
- Click Attach to Instance to choose the Instance you want to attach the volume to.
- Select an Instance from the drop-down list and click Attach volume to attach it to the selected Instance.
How to mount and use a Block Storage volume
In order to mount and use your Block Storage volume, you need to connect to the Instance it is attached to via SSH. Then, check that the volume is available, format it and finally mount it, following the instructions below.
How to verify device availability
-
Connect to your Instance with
ssh
.ssh root@<your_instance_ip> -
Use the
lsblk
command to make sure your block volume is available:root@scw-festive-agnesi:~# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 23.3G 0 diskvda 252:0 0 18.6G 0 disk├─vda1 252:1 0 18.5G 0 part /└─vda15 252:15 0 100M 0 part /boot/efiYou can see your block volume named
sda
with the chosen storage size.
How to format the Block Volume
- Create a file system for your volume. If you do not know which file system to use, you probably want to use
ext4
:root@scw-festive-agnesi:~# mkfs.ext4 /dev/sda - Make sure your file system is correctly created by running the
lsblk -f
command:root@scw-festive-agnesi:~# lsblk -fNAME FSTYPE LABEL UUID MOUNTPOINTsda ext4 925c2c17-ca8c-493a-a9cd-b475d87fd276vda├─vda1 ext4 root 8509fe04-d91c-410a-9087-c5d34537d3ae /└─vda15 vfat B3E7-7040 /boot/efi
Check that the FSTYPE
field matches ext4
for your Block volume.
How to mount the Block Volume
Once your file system is created, you need to mount it.
-
Create the mount point. In this tutorial, we choose
/mnt/block-volume
.root@scw-festive-agnesi:~# mkdir /mnt/block-volume -
Mount the volume. It is recommended to use the
defaults
option:**defaults**Use the default options: **rw**, **suid**, **dev**,**exec**, **auto**, **nouser**, and **async**.If you want to see all available options, you can run
man mount
on your Instance.root@scw-festive-agnesi:~# mount -o defaults /dev/sda /mnt/block-volume -
Make sure your file system is properly mounted by running the
lsblk
command.root@scw-festive-agnesi:~# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 23.3G 0 disk /mnt/block-volumevda 252:0 0 18.6G 0 disk├─vda1 252:1 0 18.5G 0 part /└─vda15 252:15 0 100M 0 part /boot/efi
Check the MOUNTPOINT
field.
How to use fstab for Persistent Mounting
With the current configuration, the block device will not be mounted automatically upon reboot. Use the fstab
file to make sure the reboot does not impact your file system.
Add this line to the /etc/fstab
file of your Instance:
echo "UUID=$(blkid --output value /dev/sda | head -n1) /mnt/block-volume ext4 defaults 0 0" >> /etc/fstab
You can now use your Block Storage volume like a regular disk of your Instance, and store data on it as you wish.