Adding a Volume and Creating Partitions for Linux Systems
After adding a volume in the control panel, you must make it available in the operating system. Connect to the server with sudo privileges and view all volumes. Enter the following command:
Example result:
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 775D7B55-7C02-4DAE-AC79-B81AAA1BECE3
Device Start End Sectors Size Type
/dev/vda1 2048 104447 102400 50M EFI System
/dev/vda2 104448 52428766 52324319 25G Linux filesystem
Disk /dev/vdb: 40 GiB, 42949672960 bytes, 83886080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Only 4 primary partitions can be created on a single physical hard disk. An extended partition is a special type of partition which contains "free space" where more than four primary partitions can be created. Partitions created within an extended partition are called logical partitions.
Run the fdisk utility to create partitions:
To add a new partition, use the n command:
Partition type:
Use the p option to select the primary type:
Note: Press Enter to select the default values.
Enter the first sector:
Enter the last sector:
Next, you need to add an extended (additional) partition by selecting the e option:
Set the partition number:
To make second partition size to take up all remaining disk space, you may leave it at its default value by pressing Enter:
Next, you need to create a logical partition inside the extended partition (the logical partition will be defined automatically). To do this, enter the command n in the fdisk utility, then select the logical partition using the l option:
Set the beginning on the sector by default, press Enter:
Enter the last sector according to your desired logical partition size:
To display added partitions, use p command:
Note: The extended partition has 10 GB of free space where you can create more logical partitions.
Use the w command to save your changes:
Now create a file system on the primary and the logical partition using the mkfs utility, specifying the file system type after the dot.
Note: the extended partition cannot be formatted with file systems like ext3, FAT, or NTFS, and cannot directly hold data.
Next you need to create a mount point for each partition:
Note:
- Usually, the mount point is created in the /mnt or /media directories;
- You do not need to create a mount point for an extended partition.
To change the access mode of the partitions you have to execute the following command:
To mount partitions automatically after the server restart, make changes in /etc/fstab file. Use a text editor like nano or vi to open this file:
Add the following lines to the file that opens and save the changes:
To mount partitions use:
To print the list of mounted devices and the occupied space, use the command: