Volumes
In this post we will learn how to create and associate volumes, volumes are block devices that can be attached or detached to instances, can easily be disassociated from one instance and associated with another machine.
To create volumes go to Project / Volumes / Volumes click in Create Volume, enter a name for the volume and click in Create Volume again:
Example:
Volume name: vol-data01.
Now on the actions button to the right of the volume name select Manage Attachments:
Under Attach on an Instance select the machine and click in Attach Volume:
Example:
Attach to an instance: VM01.
Note: If you do not have instances available go to How to create instances in BCOS? to know more.
Now you need to mount the volume, go to the instance console where the volume was attached, access superuser permissions and format the volume:
Example:
Super user permission: sudo -i
Format volume: mkfs -t ext4 /dev/vdb
Mount the volume and then list the mount point to view it:
Example:
Mount volume: mount -t ext4 /dev/vdb /mnt
List mount point: df -h
Note that the added volume is already in use.
Restart the instance, you will notice that the volume will no longer be mounted:
Mount volume again:
If you want to keep the volume mounted even when you restart the machine, you should reference the volume in the /etc/fstab folder:
Example:
Edit folder text /etc/fstab: vi /etc/fstab
Entering the editor, enter the first line available with the following mounted volume references:
Example:
File system: /dev/vdb.
Mount pt: /mnt.
Type: ext4.
Options: defaults.
Dump: 0.
Pass: 0.
Restart the instance, you will notice that the volume will continue to mount normally.
In the next post How to create snapshots in BCOS?, we will learn how to create snapshots of instances.