Jump toUpdate content

Block Storage - Quickstart

Reviewed on 08 June 2023 • Published on 26 May 2021

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.

Security & Identity (IAM):

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
Requirements:

How to create a Block Storage volume

  1. Click Instances from the left side menu. The Instances section displays.
  2. Click Volumes to display a list of all your current volumes.
  3. Click Create volume to create a volume that can be attached to any of your Instances.
  4. Choose a region for the volume.
    Important:

    The volume must be in the same region as the Instance you want it to connect to.

  5. Select Block Storage when configuring the volume. Enter the volume name and select a size.
  6. Click Create volume to confirm the creation of the volume.

How to attach a Block Storage volume to an Instance

  1. Click Instances from the left side menu. The Instances section displays.
  2. Click Volumes to display a list of all your current volumes. The newly created volume displays on top of the list.
  3. Click Attach to Instance to choose the Instance you want to attach the volume to.
  4. 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

  1. Connect to your Instance with ssh.

    ssh root@<your_instance_ip>
  2. Use the lsblk command to make sure your block volume is available:

    root@scw-festive-agnesi:~# lsblk
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    sda 8:0 0 23.3G 0 disk
    vda 252:0 0 18.6G 0 disk
    ├─vda1 252:1 0 18.5G 0 part /
    └─vda15 252:15 0 100M 0 part /boot/efi

    You can see your block volume named sda with the chosen storage size.

    Note:

    The Scaleway ecosystem uses GiB to define storage sizes and not GB as default on Linux.

How to format the Block Volume

  1. 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
  2. Make sure your file system is correctly created by running the lsblk -f command:
    root@scw-festive-agnesi:~# lsblk -f
    NAME FSTYPE LABEL UUID MOUNTPOINT
    sda ext4 925c2c17-ca8c-493a-a9cd-b475d87fd276
    vda
    ├─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.

  1. Create the mount point. In this tutorial, we choose /mnt/block-volume.

    root@scw-festive-agnesi:~# mkdir /mnt/block-volume
  2. 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
  3. Make sure your file system is properly mounted by running the lsblk command.

    root@scw-festive-agnesi:~# lsblk
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    sda 8:0 0 23.3G 0 disk /mnt/block-volume
    vda 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.