Jump toUpdate content
How to mount and use a Block Storage volume
To use a storage device in Linux it must be mounted (attached) to the operating system. Once it is mounted, a filesystem can be created on the device to store data. Similarly, to remove the device securely from the operating system, you should unmount it properly.
This document explains how to mount an additional block volume to your Instance. Note that the root volume of the Instance is mounted for you at the time of Instance creation, this how-to concerns additional block volumes only.
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 configured your SSH key
- You have an Instance with an attached additional Block Storage volume
How to verify device availability
- Connect to your Instance with
- Use the
lsblkcommand 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
How to format the Block Volume
- Create a file system with the following command. This command uses the
ext4filesystem, though you can choose another if you prefer.mkfs.ext4 /dev/sda
- Make sure your file system is correctly created by running the
lsblk -fcommand.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
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
- Mount the volume. We recommend you use the
defaultsoption, 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.
3. Make sure your file system is properly mounted by running the
You should see an output like the following. Check the
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
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 '/dev/sda /mnt/block-volume ext4 defaults 0 0' >> /etc/fstab
How to transfer 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:
You 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.
If 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 command
sudo apt install rsync. For Linux CentOS/ Fedora, use the YUM package manager:
sudo yum install rsync. On Mac OSX with the Homebrew package manager, use
brew install rsync.
- On your local machine, use nano create a file called
Enter the text
Hello World!, then save and exit the file.
3. 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.