Volume: format and mount

After a volume has been created and attached to a virtual machine (see Volume: create and attach), in order to use for storing data you need to partition, format and mount it.

To achieve this, these operations have to be performed inside the virtual machine:

  • Partition Table

  • Format the volume

  • Mount the volume

Warning

These operations is specific to the OS and software installed on the Virtual Machine.

There are more than one software capable of partitioning your devices (e.g. fdisk, parted).

Here you can find an example of how to perform these operations using fdisk.

Partition Table

Suppose that the volume is attached to the virtual machine as device /dev/vdc.

Login in to the virtual machine and use fdisk to modify the partition table.

  • list the partition table

    sudo fdisk -l
    
  • partition of device /dev/vdc

sudo fdisk /dev/vdc

# 1 new partition, primary, with default sector numbers and type “Linux”

==> n; p; 1 ; …default ;

# check and write

==> p; w

Format the volume

Format the device /dev/vdc just partitioned as xfs:

sudo mkfs -t xfs /dev/vdc1

Mount the volume

sudo mkdir /mnt/stuff_1
sudo mount /dev/vdc1 /mnt/stuff_1

To mount the volume automatically at each boot of the virtual machine, please modify the /etc/fstab file.

Following the example, in the /etc/fstab could be written:

/dev/vdc1 /mnt/stuff_1 xfs auto,nofail,defaults 0 0