Managing a Block Storage volume
This documentation only explains how to mount additional block volumes to your Instance, as the root volume of your Instance is already mounted at creation.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- An SSH key
- An Instance with an additional Block Storage volume attached to it
Mounting and using 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 mount it, following the instructions below.
Verifying 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:lsblk
You should see an output like the following. You can see your block volume named sda
with the chosen storage size.
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/efi
Formatting the Block volume
- Create a filesystem with the following command. This command uses the
ext4
filesystem, though you can choose another if you prefer.mkfs.ext4 /dev/sda - Make sure your filesystem is correctly created by running the
lsblk -f
command.lsblk -f
You should see an output like the following. Check that the FSTYPE
field matches ext4
for your Block volume.
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
Mounting the Block volume
Once you have created your filesystem, you need to mount it.
-
Create the mount point. In this tutorial, we choose
/mnt/block-volume
.mkdir /mnt/block-volume -
Mount the volume. We recommend that you use the
defaults
option, as in the command below.mount -o defaults /dev/sda /mnt/block-volume**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. -
Make sure your filesystem is properly mounted by running the
lsblk
command.lsblkYou should see an output like the following. Check the
MOUNTPOINT
field.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
Using 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 filesystem.
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
Transferring data from your local machine to the remote Block volume
You may wish to transfer files from your local machine to your Instance’s remote Block volume. This can be simply achieved with rsync, a tool for efficiently transferring and copying files. The rsync utility is pre-installed on most Linux distributions and macOS.
-
Check that rsync is installed on your local machine with the following command:
rsync --versionYou should see an output similar to the following:
rsync version 3.1.3 protocol version 31Copyright (C) 1996-2018 by Andrew Tridgell, Wayne Davison, and others.Web site: http://rsync.samba.org/Capabilities:64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,append, ACLs, xattrs, iconv, symtimes, preallocrsync comes with ABSOLUTELY NO WARRANTY. This is free software, and youare welcome to redistribute it under certain conditions. See the GNUGeneral Public Licence for details.TipIf you get a
command not found
output (or similar), you need to install rsync. On Linux Ubuntu and Debian systems, you can do this with the APT package tool using the commandsudo apt install rsync
. For Linux CentOS/ Fedora, use the YUM package manager:sudo yum install rsync
. On Mac OSX with the Homebrew package manager, usebrew install rsync
. -
On your local machine, use nano to create a file called
hello-world.txt
:nano hello-world.txtEnter the text
Hello World!
, then save and exit the file. -
Enter the following command to transfer the file to your Instance’s mounted block volume. Ensure that you use your own Instance’s IP address:
rsync -a hello-world-2.txt root@<your.IP.address.here>:/mnt/block-volume
The file is now transferred. You can connect to your Instance again, and use the command cd /mnt/block-volume ; ls
to check that the file appears in the directory.
Increasing the partition size of the volume
We recommend that you make a backup of your data using the snapshot feature, before increasing the partition size of your volume. This helps you avoid any potential data loss.
-
Connect to your Instance using SSH.
-
Use the
lsblk
command to identify your Block Storage volume’s mount point. In the following example the volume is mounted at/mnt/block-volume
:root@scw-distracted-keldysh:~# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTSloop0 7:0 0 63.3M 1 loop /snap/core20/1852loop1 7:1 0 111.9M 1 loop /snap/lxd/24322loop2 7:2 0 49.8M 1 loop /snap/snapd/18596sda 8:0 0 9.3G 0 disk├─sda1 8:1 0 9.2G 0 part /├─sda14 8:14 0 4M 0 part└─sda15 8:15 0 106M 0 part /boot/efi -
Use
growpart
to increase the partition size of your block storage volume (here/dev/sdb1
):growpart /dev/sdX 1TipTake note of the space between the device identifier and the partition number.
-
Increase the partition size of the volume using
resize2fs
. Replace/dev/sdX
with the name of your block volume in the following command:resize2fs -p /dev/sdX1 -
Check the new block volume size using
lsblk
:root@scw-distracted-keldysh:~# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTSloop0 7:0 0 63.3M 1 loop /snap/core20/1852loop1 7:1 0 111.9M 1 loop /snap/lxd/24322loop2 7:2 0 49.8M 1 loop /snap/snapd/18596sda 8:0 0 18.6G 0 disk├─sda1 8:1 0 18.5G 0 part /├─sda14 8:14 0 4M 0 part└─sda15 8:15 0 106M 0 part /boot/efi