Continuing with the series of articles on ZFS under FreeBSD, we will explain how to create a basic ZFS pool, we will only create the pool and mount it.
Before continuing with the article, it is advisable to review
this previous one
so that all concepts are clear.
To enable FreeBSD to mount ZFS pools at startup, we must enable the service:
We start the service:
We check the available disks in the system:
<BHYVE SATA DISK 001> at scbus0 target 0 lun 0 (ada0,pass0)
<BHYVE SATA DISK 001> at scbus1 target 0 lun 0 (ada1,pass1)
We can see that the system has two disks, the first one was used for the OS installation, we will use the second one as data storage, in this case we can use the entire disk or create partitions. The only case in which partitions must be created is if the pool is going to be bootable.
We check the space of the system pool:
NAME USED AVAIL REFER MOUNTPOINT
zroot 996M 4.35G 192K /zroot
We check the status of the system pool:
pool: zroot
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
zroot ONLINE 0 0 0
ada0p3 ONLINE 0 0 0
errors: No known data errors
We can see that zroot occupies the ada0 disk, partition 3.
FreeBSD does not recommend using entire disks in any case:
Caution: Using an entire disk as part of a bootable pool is strongly discouraged, as this may render the pool unbootable. Likewise, you should not use an entire disk as part of a mirror or RAID-Z vdev. These are because it it impossible to reliably determine the size of an unpartitioned disk at boot time and because there’s no place to put in boot code.
We create a new GPT partition table:
ada1 created
We check the status of the disk partitions:
=> 40 2097072 ada1 GPT (1.0G)
40 2097072 - free - (1.0G)
We create the partition:
ada1p1 added, but partition is not aligned on 8192 bytes
We check the status of the disk partitions:
=> 40 2097072 ada1 GPT (1.0G)
40 2097072 1 freebsd-zfs (1.0G)
We create the pool with the newly created partition:
We check the status of the pool:
pool: data
state: ONLINE
scan: none requested
config:
NAME STATE READ WRITE CKSUM
data ONLINE 0 0 0
ada1p1 ONLINE 0 0 0
errors: No known data errors
We can see the pool space in /data:
NAME USED AVAIL REFER MOUNTPOINT
data 528K 831M 192K /data