Frequently Asked Question

Create and Attach additional Volumes to an existing VM
Last Updated about a month ago

1. Introduction

Requirements may change over time, or you might run out of storage on a VM. This article will show you how to create an additional volume and create a new file system (partition) in your Linux VM. You will need dashboard access and root equivalent rights on the VM. 

2.1 Create and attach a Volume

Log in to the OpenStack Dashboard and head to  Compute , open Volumes and click the Create Volume button.

image

A Popup will open,
you can set a Name, Description and Size.
Click on Create Volume.

image

Open the context menu on the right hand side and click  Manage Attachments

image
image

Choose your VM in  the context menu Attach To Instance  and click Attach Volume

As soon as the volume is attached, you 'll see from the dashboard; as which block device the freshly created volume is interpreted.

image

2.2 Create the File System (Partition)

Log in via SSH to the VM.  
We know already as which block device the volume is attached. To be certain you can run

ubuntu@ubuntu:~$ sudo fdisk -l
# or
ubuntu@ubuntu:~$ sudo parted -l

When you are sure that /dev/vdc is the right block device use mkfs.ext4 command to start creating the partition on the selected storage device.

ubuntu@ubuntu:~$ sudo mkfs.ext4 /dev/vdc
image

2.3 Auto attach with fstab

fstab is your operating system’s file system table. The fstab file is read by the mount command, which happens automatically at boot time to determine the overall file system structure.
Each file system is described on a separate line; fields on each line are separated by tabs or spaces. For demonstration purposes we will use this basic example. 
/dev/vdc /mnt/my_volume ext4 defaults,nofail 0 0

First create a folder where you like to mount the volume. Afterwards edit the fstab file. 

ubuntu@ubuntu:~$ sudo mkdir /mnt/my_volume
ubuntu@ubuntu:~$ sudo nano /etc/fstab  
GNU nano 4.3                               /etc/fstab
# 
# /etc/fstab 
... 

/dev/vdc         /mnt/my_volume     ext4      defaults,nofail        0       0

To test the new fstab entry run a mount command against the mount point.

ubuntu@ubuntu:~$ sudo mount /mnt/my_volume

ATTENTION: do not restart your machine when the mount command fails.

Congratulations, the VM now automatically mounts a volume.
Depending on your use-case you want to change the permissions or owners for this mount point.

Loading ...