This page looks best with JavaScript enabled

FreeBSD ZFS Vol1 Basic ZFS

 ·  🎃 kr0m

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:

sysrc zfs_enable="yes"

We start the service:

service zfs start

We check the available disks in the system:

root@freeBSD:~ # camcontrol devlist

<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:

root@freeBSD:~ # zfs list

NAME                 USED  AVAIL  REFER  MOUNTPOINT  
zroot                996M  4.35G   192K  /zroot

We check the status of the system pool:

root@freeBSD:~ # zpool status

  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:

root@freeBSD:~ # gpart create -s GPT ada1

ada1 created

We check the status of the disk partitions:

root@freeBSD:~ # gpart show ada1

=>     40  2097072  ada1  GPT  (1.0G)  
       40  2097072        - free -  (1.0G)

We create the partition:

root@freeBSD:~ # gpart add -t freebsd-zfs -a 4k ada1

ada1p1 added, but partition is not aligned on 8192 bytes

We check the status of the disk partitions:

root@freeBSD:~ # gpart show ada1

=>     40  2097072  ada1  GPT  (1.0G)  
       40  2097072     1  freebsd-zfs  (1.0G)

We create the pool with the newly created partition:

zpool create data /dev/ada1p1

We check the status of the pool:

root@freeBSD:~ # zpool status data

  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:

root@freeBSD:~ # zfs list data

NAME                 USED  AVAIL  REFER  MOUNTPOINT  
data                 528K   831M   192K  /data
If you liked the article, you can treat me to a RedBull here