How to partition, format, and mount a volume¶
This guide describes the basic procedure to prepare a storage volume attached for the first time to a virtual machine for use: creating the partition, formatting the filesystem, and mounting the device.
If the volume has already been partitioned and formatted before, skip to this point in the guide (section 4). Repeating the steps from the first section will delete all data currently stored on the volume.
1. Identify the device¶
Log in as root to the machine to which the volume is attached.
If it is a VM hosted at ReCaS, to become root, simply connect to it by following the shared instructions and run sudo su -.
To display the list of volumes, run:
fdisk -l
You will get output similar to the one shown in the figure, where the name of the volume to be configured (in this example /dev/vdb) is highlighted.

2. Create a partition¶
To create a partition on a volume up to 2 TB in size, run:
fdisk <device-name>
replacing <device-name> with the name of the volume (in this example /dev/vdb), and answering the various prompts as follows:

nto create a new partitionpto create a primary partition1to create only one partition (or a higher number to create that number of partitions)- the other options can be left as default (just press Enter)
wto write the partition and exit
At the end, run:
fdisk -l
to verify the name of the created partition (in this example /dev/vdb1).

3. Format the partition¶
To format the partition with the ext4 filesystem, the standard filesystem used on Linux systems, run:
mkfs.ext4 <partition-name>
replacing <partition-name> with the name of the created partition (in this example /dev/vdb1).
4. Create the mountpoint¶
create a directory that will be used as the mountpoint (in this example, /disk/vdb1)
mkdir -p /disk/vdb1
5. Mount the volume¶
Then mount the partition you just created on the chosen directory:
mount <partition_name> /disk/vdb1
replacing <partition-name> with the name of the partition to mount (in this example /dev/vdb1).
6. Verify the mount¶
To verify that the volume has been mounted correctly, you can use one of the following commands:
df -h
or:
mount