How to Mount and Use a Block Device

Block Storage - Overview

Block storage volumes are additional volumes that you can connect to your Virtual Instances.

The block storage technology breaks files into smaller pieces, also called chunks, or simply blocks). Each of these pieces can be stored separately and under a unique address anywhere in the storage system. This way of storing data makes block storage ideal for latency critical applications such as transactional databases or mission-critical data as it is faster, latency-wise, than a traditional file-storage device.

In this tutorial you will learn how to format and mount a block storage volume that you have created for your Virtual Instance.

Requirements:

Verifying the 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

Your 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 the default on linux.

Formatting the Block Volume

You can now format your block 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 -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 if the FSTYPE field matches ext4 for your block volume.

Mounting 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 . Then, mount it. 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/volume-block
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.

Using fstab for Persistent Mounting

With the current configuration, the block device will not be mounted automatically upon reboot.
You might want your file system to survive the reboot.
The fstab file is there for you!

Add this line to the /etc/fstab file of your instance:

echo '/dev/sda /mnt/volume-block ext4 defaults 0 0' >> /etc/fstab

Umounting the Volume / Mounting it Elsewhere

1 . umount the volume to remove it from your current setup:

root@scw-festive-agnesi:~# umount /mtn/volume-block

2 . Check with lsblk that the volume is no longer mounted in the system:

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

Important: Do not forget to edit the /etc/fstab file and delete the line corresponding to your block volume.

Also, you may want to change the mount point. You can mount it elsewhere.
Please refer to the Mounting the block volume section above.
Do not forget to edit the /etc/fstab file and update the line corresponding to your block volume with the new mount point.

Increasing the Block Volume Size

To expand the size of your Block Storage volume:

1 . Access the Scaleway console Instances page and click on the Volumes tab.

2 . A list of your volumes displays. Click on beside the volume you wish to increase size of and then on Increase Volume.

3 . Click the + sign to increase the size according to your preference and confirm by clicking Increase your Volume.

Note: Currently, only the increase of a Block Storage volume is supported. The maximum size of a Block volume is 10 TB.

Increasing Volume via the Scaleway API

1 . Inspect the volume and verify its name, size and if the type is b_ssd by running the following request:

curl -q -H "X-Auth-Token: $SECRET_KEY" -X GET https://api.scaleway.com/instance/v1/zones/<REGION>/volumes/<VOLUME_ID>

Replace <REGION> with the geographical region of the cloud instance. This value can either be fr-par-1 for instances located in Paris or nl-ams-1 for instances located in Amsterdam. Replace <VOLUME_ID> with the unique identifier of the volume, which can be found on the Scaleway console under Instances > Volumes > More Info (for the selected volume).

The following response should appear as an output:

{"volume": {"creation_date": "2020-06-02T08:04:50.094118+00:00", "server": null, "id": "VOLUME_ID", "size": 25000000000, "name": "myAwesomeVolume", "zone": "<REGION>", "export_uri": null, "volume_type": "b_ssd", "modification_date": "2020-06-02T08:04:50.094118+00:00", "state": "available", "organization": "<ORGANIZATION_ID>"}}

2 . To modify the volume size, run the request below:

curl https://api.scaleway.com/instance/v1/zones/<REGION>/volumes/<VOLUME_ID> -H "X-Auth-Token: $SECRET_KEY" -X PATCH -H 'Content-Type: application/json;charset=utf-8' --data '{ "name":"new_name", "size":26000000000 }'

Replace <REGION>and <VOLUME_ID> following the guidelines mentioned previously and replace the existing size value with the new one.

Note: You can use the same request to change the name of you volume by replacing new_name by another of your choice. If you do not wish to change the volume name, erase "name":"new_name",from the request before running it.

A response appears confirming the changes:

{"volume": {"creation_date": "2020-06-02T08:04:50.094118+00:00", "server": null, "id": "<VOLUME_ID>", "size": 26000000000, "name": "new_name", "zone": "<REGION>", "export_uri": null, "volume_type": "b_ssd", "modification_date": "2020-06-02T08:08:27.385208+00:00", "state": "resizing", "organization": "<ORGANIZATION_ID"}}

Discover a New Cloud Experience

Deploy SSD Cloud Servers in seconds.