Mount a volume to a cloud instance

Note: This tutorial applies to Linux operating systems using the ext4 file system.

In xneelo Cloud you can create new volumes and attach them to your instances at any time.

When a new volume is attached, it is not automatically mounted to the instance. You’ll need to do this manually.

This requires both the file system to be created and the volume to be mounted so that it is accessible. Follow the steps below to learn how.



  • Confirm the volume has been detected

    This will check to see if the system has successfully detected the new volume.

    Steps

    1. 1
      Connect to the instance via SSH.
    2. 2
      Type in the following command:

        sudo lsblk -p
        1. 3
          This will display a list of all the available storage devices on the instance, including the attached volume.
        2. 4
          Confirm that the volume is present and that the size matches the volume you have attached.
        3. 5
          Follow on to the next steps to create the file system.





      • Create the file system

        Next, you need to create the filesystem on the newly attached volume.

        Steps

        1. 1
          Format the volume with the ext4 file system. Type in the following command:

              sudo mkfs.ext4 /dev/myvolume

              Replace /dev/myvolume with the name of your volume.

              1. 2
                For large files, run the following command:

                    mkfs.ext4 -E nodiscard /dev/myvolume 

                    Replace /dev/myvolume with the name of your volume.

                    1. 3
                      Follow on to the next steps to mount the volume.





                  • Mount the volume

                    Once the file system has been created, you will need to create a directory in order to mount the volume. 

                    In this example, the myvolume directory has been created within the mnt directory.

                    Steps

                    1. 1
                      To create the directory, type in the following command:

                            sudo mkdir /mnt/myvolume 
                            1. 2
                              Now that you have created the directory to which you can mount the volume, you can mount it by using the following command:

                                      sudo mount /dev/vdb /mnt/myvolume

                                      This will mount the volume to the /mnt/myvolume directory.

                                      If you want the volume to be mounted automatically every time the system starts up, you will need to add an entry to the /etc/fstab file. 

                                      In this example we are making use of nano.

                                      Steps

                                      1. 1
                                        Create the directory. Type in the following command:

                                                  sudo nano /etc/fstab
                                                  1. 2
                                                    Add the following line to the end of the file:

                                                                /dev/vdb  /mnt/myvolume  ext4  defaults  0  0

                                                                This line tells the system to mount the /dev/volumename device to the /mnt/myvolume directory using the ext4 file system with the default mount options.

                                                                1. 3
                                                                  Save the /etc/fstab file and exit the text editor.



                                                              Assist Note

                                                              Take a look at our other articles and guides on xneelo Cloud.