Adding a Volume and Creating Partitions in FreeBSD
After adding a volume in the control panel, you need to make it available in the operating system.
Log on to the server as sudo or root and browse all volumes, execute the following command:
Example:
Providers:
Name: vtbd0
Mediasize: 26843545600 (25G)
Sectorsize: 512
Stripesize: 4096
Stripeoffset: 0
Mode: r1w1e3
descr: (null)
ident: BHYVE-72B8-3EC6-7459
rotationrate: unknown
fwsectors: 0
fwheads: 0
Geom name: vtbd1
Providers:
Name: vtbd1
Mediasize: 42949672960 (40G)
Sectorsize: 512
Stripesize: 4096
Stripeoffset: 0
Mode: r0w0e0
descr: (null)
identr: BHYVE-679A-4260-62AE
rotationrate: unknown
fwsectors: 0
fwheads: 0
This tutorial will show how to mount the /dev/vtbd1 40 GB device as a standard ufs (Unix Fast File System) partition and how to add a swap partition.
Note: if the added volume does not show up in the list, you have to restart the server.
Create a GPT partitioned volume with the command:
Note: GPT is a GUID Partition Table format which uses a Logical Block Addressing (LBA) system.
To view the volume, run the command:
40 83886000 - free - (40G)
Example 1
To add the first 10 GB partition, use the command:
This example will add the second partition of 20 GB:
The third partition can be added without specifying an initial LBA and size, so it will be created on all available space:
To check the resulting partitions:
40 20971520 1 freebsd-ufs (10G)
20971560 41943040 2 freebsd-ufs (20G)
62914600 20971440 3 freebsd-ufs (10G)
To create a file system on volume partitions, run the following commands. The -U option specifies the use of the Soft Update mechanism, which increases the speed of creating and deleting files:
newfs -U /dev/vtbd1p2
newfs -U /dev/vtbd1p3
Next you need to create a mount point for each partition:
mkdir /mnt/volume2
mkdir /mnt/volume3
To change the access mode of the partitions, you need to execute the following command:
chmod -R 660 /mnt/volume2
chmod -R 660 /mnt/volume3
To mount partitions automatically after the server restart, you need to make changes in /etc/fstab file. Use a text editor like vi or nano to open this file:
In the file that opens, you need to add the following lines and save your changes:
/dev/vtbd1p2 /mnt/volume2 ufs rw 0 0
/dev/vtbd1p3 /mnt/volume3 ufs rw 0 0
To mount partitions use:
To display the list of mounted devices and the occupied space, use the command:
...
/dev/vdbd1p1 9.7G 8.0K 8.9G 0% /mnt/volume1
/dev/vdbd1p2 19G 8.0K 18G 0% /mnt/volume2
/dev/vdbd1p3 9.7G 8.0K 8.9G 0% /mnt/volume3
Example 2 (adding a swap partition)
First we need to add 1GB swap partition:
The second partition can be added without specifying an initial LBA and size, so it will be created in all free space:
To check the resulting partitions:
40 2097152 1 freebsd-swap (1.0G)
2097192 81788848 2 freebsd-ufs (39G)
To create a file system on the volume partitions, run the following command. The -U option specifies the use of the Soft Update mechanism, which speeds up the creation and deletion of files:
Note: the swap partition does not need to be formatted.
Next, you need to create a mount point for every partition except swap:
To change the access mode of the partitions, you need to execute the following command:
To mount partitions automatically after the server restart, you need to make changes in /etc/fstab file. Use a text editor like vi or nano to open this file:
You need to add the following lines and save your changes:
/dev/vtbd1p2 /mnt/volume1 ufs rw 0 0 0
Use the following command to mount partitions:
Next you need to mount the swap partition:
You can use the command swapinfo to check if the partition was mounted successfully:
/dev/vtbd1p1 1048576 0 1048576 0%
Use this command to display a list of mounted devices and space occupied:
Note: The swap-type partition is not displayed in this list.
...
/dev/vdbd1p2 38G 8.0K 35G 0% /mnt/volume