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

How to perform the operations is specific to the Operative system of the Virtual Machine. Here you can find one suggestion to perform these operations. Another option can be to use parted.

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