Jump toUpdate content

Quickstart

Reviewed on 26 May 2021Published 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 from 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.

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 a 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 a new 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 to which the volume shall be attached.

  4. Select an Instance from the drop-down list and click Attach this 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](https://en.wikipedia.org/wiki/Gibibyte) to define storage sizes and not [GB](https://en.wikipedia.org/wiki/Gigabyte) as the 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:

/dev/sda /mnt/block-volume ext4 defaults 0 0

You can now use your block storage volume like a regular disk of your instance, and store data on it as you wish.