This page shows how to connect a block device manually.
- You have an account and are logged into cloud.scaleway.com
- You have configured your SSH Key
- You have a running server
- Your server has additional volumes
When you create a server with additional storage, the connection to a block device is automatic at the server boot.
If you want to avoid this behavior and connect additional block devices manually, execute the following command on your server
echo manual > /etc/init/nbd-add-extra-volumes.override (Ubuntu only).
There are three steps to connect a block device manually:
Important: The maximum number of volumes attach to a BareMetal instance is limited to 15 devices.
The NBD client requires the IP address and the port number of our NBD server exporting your volume.
These settings are available from your server details page on the control panel.
The above picture shows the IP address and the port number required to export the volume in our example.
You can also use “server metadata” which gives you a lot of information.
Execute the following command on your server to display server metadata:
VOLUMES_0 / VOLUMES_0_* always match the root volume of the server. Server connects and mounts it automatically at boot time.
VOLUMES_[1-15] / VOLUMES_[1-15]_* are additional volumes attached to the server.
VOLUMES_[1-15_EXPORT_URI=nbd://10.1.0.44:4321 this entry shows NBD server IP address and the port number of our NBD server exporting your volume.
An instance of the NBD client must be started for each block device to import.
root@c1-X-Y-Z-T:~# nbd-client 10.1.0.44 4321 /dev/nbd1 Negotiation: ..size = 9536MB bs=1024, sz=9999998976 bytes root@c1-X-Y-Z-T:~# fdisk -l -u /dev/nbd1 Disk /dev/nbd1: 100.0 GB, 99999997952 bytes 255 heads, 63 sectors/track, 12157 cylinders, total 195312496 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
In the above example,
nbd-client 10.1.2.21 4129 /dev/nbd1 connects to the NBD server.
The output of
fdisk -l -u /dev/nbd1 command shows that the block device
/dev/nbd1 is attached to the server with success.
If the new volume has never been formatted, you need to format the volume using
mkfs before you can mount it.
For instance, the following command creates an
ext4 file system on the volume:
To mount the device manually as /mnt/data, run the following commands:
To mount the additional volume automatically, you can create a systemd script that will mount your volumes automatically during the boot of your cloud server.
If not yet done, create the directory into you want to mount your volume:
mkdir -p /mnt/data
As the volume is empty by default, you have to create a filesystem before you can use it. To format it with with an
ext4 filesystem, use the following command:
mkfs -t ext4 /dev/nbd1
To get the
UUID of your volume, run the command
blkid and take a note of the ID as you will need it in the next step.
Create or edit the file that corresponds to the path of your directory
nano /etc/systemd/system/mnt-data.mount and edit is as following: The file name of the script must correspond to the path where you mount the volume (
UUID with the ID of your volume.
Now reload systemd:
systemctl daemon-reload Launch the script to mount the volume:
systemctl start mnt-data.mount Finally enable the script to mount your volume automatically during boot:
systemctl enable mnt-data.mount
Your volume will automatically be mounted after a reboot. You can run the
df -h command, this command will list all your devices and where they are mounted: