> Storage and ZFS

While it's possible to run Tribblix on the old UFS file system, by default ZFS is used.

Similar to networking, Tribblix will manage ZFS for you most of the time.

ZFS thinks of storage in 2 layers.

ZFS pools

The first is the pool, which combines storage devices into a flexible pool of storage. To see which pools are present, their size and usage, run:

zpool list

To get a description of the pools, including their layout and the status of individual devices, run:

zpool status

On installation, Tribblix will create the root pool - commonly called rpool. You can install to a mirror, or a raidz pool, and if you have no further storage devices, you're done. If you have additional storage devices you're then free to create additional pools. It's generally best to keep the number of pools small, generally one for the system and one for data is plenty.

ZFS datasets

The second layer in ZFS is the dataset, most commonly a file system, but also a block volume. To show existing datasets, run:

zfs list

You can create as many file systems as you need, for example:

zfs create rpool/export/spreadsheets

assuming rpool/export is mounted at /export, the new file system will automatically be mounted at /export/spreadsheets.

Once you've finished with a file system, you can delete it:

zfs destroy rpool/export/spreadsheets

Snapshots

A key feature of ZFS is the ability to create snapshots, saving the state of the dataset at a given point in time. For example:

zfs snapshot rpool/export/spreadsheets@2021-12-02

The syntax is simple, the name of the dataset, followed by @, followed by the name of the snapshot.

To see what snapshots exist, a variant of zfs list is used:

zfs list -t snapshot

and once you no longer need a snapshot, you can delete it:

zfs destroy rpool/export/spreadsheets@2021-12-02

One thing you can do with a snapshot it to look inside it. A ZFS file system has a magic .zfs directory that's hidden and only appears when you explicitly access it. So if you try and list the .zfs directory, with:

ls /export/spreadsheets/.zfs

then you should see two directories - shares and snapshot. And then if you look inside the snaphost directory:

ls /export/spreadsheets/.zfs/snapshot

you'll see a list of all the snapshots. Look inside a snapshot and you'll see the data exactly as it was when the snapshot was taken.

If you need a file back, perhaps because it's been deleted or changed, you can use normal tools like cp to copy the old version out of the snapshot, which can save a lot of hunting for backups.

Zones and ZFS

When you create zones in Tribblix, zap will automatically manage whatever ZFS datasets are needed, so you don't have to do anything. This includes creating a file system for the zone itself, or a ZFS storage volume if you're using bhyve.

In addition, you can use the -D flag to zap create-zone to delegate a dataset to a zone. This will create a new dataset if it doesn't exist, and allocate it to the zone, so that the zone's administrator can manage it. (If you simply share a directory using -s or -S, the zone can use the data but can't manage the underlying ZFS file system.)


Index | Previous Section | Next Section


tribblix@gmail.com :: GitHub :: Privacy