ZFS: Maintenance

Table of Contents

Replace failed drive of a ZFS pool
Migrate from one ZFS mirror to another
Repartition the drives of a pool using network stored backup
Cloning a live FreeBSD ZFS System

Repartition the drives of a pool using network stored backup

by ross at 03:19:47 on June 30, 2015

If, for instance, you decide that there is too little swap in installed system, you have to repartition the root pool's drives in order to increase the swap partitions.

This is how you can do this. BTW, If you have a spare drive in the system you could ommit the ssh layer and dd/cat the dump file to that drive.

Prepare the dump

Create snapshot to be copied (if the pool name is system):

# zfs snapshot -r system@safe

Store the snapshot in a file using ssh (make sure the destination directory is writable):

# zfs send -R system@safe | ssh ross@ dd of=/share/zfs.dump

Now /share/zfs.dump on holds the dump of the ZFS pool.

Boot FreeBSD installation media

Select "Shell". Bring the network interface up:

ifconfig rl0 up
  1. Delete existing partitions.
  2. Recreate boot, swap and ZFS partitions.

The new ZFS partitions could be smaller or bigger than the original one. Just make sure it has enough space to hold the dump.

Now recreate the pool (assuming you have created /dev/gpt/system0 and /dev/gpt/system1 partitions and installed bootcode):

# zpool create -m none -o altroot=/mnt \
               -o cachefile=/var/tmp/zpool.cache \
               system mirror /dev/gpt/system0 /dev/gpt/system1
# zfs set mountpoint=/ system

Copy the filesystems and data:

# ssh ross@ cat /share/zfs.dump | zfs receive -F system

The pool is copied, you can now delete the temporary snapshot:

# zfs destroy -r system@safe

Prepare to boot the newly created mirror:

# zpool set bootfs=system system
# mkdir -p /mnt/boot/zfs
# cp /var/tmp/zpool.cache /mnt/boot/zfs/zpool.cache