Format and Mount
Formatting a device/volume erases all existing data on a device, if a file system already exists on the target device/volume. If you need to retain the data on your volume, you should skip to the
mount section below.
You can verify the device name that your attached volume will have in your instance in the Attached To column on the
Volumes | Volumes page on your Nectar dashboard.
In your instance you can see the attached Volume as a Block Device using the lsblk (list block devices) command.
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 10G 0 disk └─vda1 252:1 0 10G 0 part / vdb 252:16 0 60G 0 disk /mnt vdc 252:32 0 65G 0 disk
Depending on how you created your volume, it may not have a file system and you need to create one before mounting, i.e. format the device. The exact format command syntax is dependent on the virtual machine’s operating system and the type of file system you need. The example below formats the volume attached as
/dev/vdc’ in the Ubuntu-based instance using the
$ sudo mkfs -t ext4 /dev/vdc
To make your volume/device available to the operating system you need to mount it on a directory called a mount point. You can mount your device using an in-memory-only mount, but the mount will be lost upon rebooting your instance. We recommend you configure the mounting of your device/volume filesystem persistently using the configuration file
/etc/fstab. In both examples we will create a mount point called
In memory only
You can use below commands to create a mount point called
/pvol and to mount the device
/dev/vdc at that mount point.
$ sudo mkdir /pvol $ sudo mount /dev/vdc /pvol -t auto
To ensure that your Volume is remounted after a reboot of your instance, you should configure it in the file
First create the mount point
$ sudo mkdir /pvol
Then use a text editor to open the
/etc/fstab file. You can do this with the command below. We are using the nano text editor in this example but you can use whichever text editor your prefer, just replace nano with the name of the text editor (Vim etc).
sudo nano /etc/fstab
You can then add the following line to
/dev/vdc is the device you’re mounting and
/pvol is the its target mount point.
/dev/vdc /pvol auto defaults,nofail 0 2
After adjusting the
/etc/fstab file you need to initiate any changes. Use the mount all command:
$ sudo mount --all
You may have to change ownership or write privileges to enable writing to the ephemeral storage, using chown, chgrp or chmod, e.g.
$ sudo chown ubuntu:ubuntu /pvol
Your use-case or operating system may require different details or a different approach than this example.