Categories
Unix & Linux

How to upgrade ZFS pool on FreeBSD

Yesterday I upgraded my web server to the latest version of FreeBSD (9.0-RELEASE). 

FreeBSD 9.0 supports ZFS v28:

$ zpool upgrade -v
This system is currently running ZFS pool version 28.

The following versions are supported:

VER  DESCRIPTION
---  --------------------------------------------------------
 1   Initial ZFS version
 2   Ditto blocks (replicated metadata)
 3   Hot spares and double parity RAID-Z
 4   zpool history
 5   Compression using the gzip algorithm
 6   bootfs pool property
 7   Separate intent log devices
 8   Delegated administration
 9   refquota and refreservation properties
 10  Cache devices
 11  Improved scrub performance
 12  Snapshot properties
 13  snapused property
 14  passthrough-x aclinherit
 15  user/group space accounting
 16  stmf property support
 17  Triple-parity RAID-Z
 18  Snapshot user holds
 19  Log device removal
 20  Compression using zle (zero-length encoding)
 21  Deduplication
 22  Received properties
 23  Slim ZIL
 24  System attributes
 25  Improved scrub stats
 26  Improved snapshot deletion performance
 27  Improved snapshot creation performance
 28  Multiple vdev replacements

For more information on a particular version, including supported releases,
see the ZFS Administration Guide.

Check ZFS version of our pools:

$ zpool get all tank
NAME  PROPERTY       VALUE       SOURCE
tank  size           2.70T       -
tank  capacity       0%          -
tank  altroot        -           default
tank  health         ONLINE      -
tank  guid           16518060353267231552  local
tank  version        15          local
tank  bootfs         tank/root   local
tank  delegation     on          default
tank  autoreplace    off         default
tank  cachefile      -           default
tank  failmode       wait        default
tank  listsnapshots  off         default
tank  autoexpand     off         default
tank  dedupditto     0           default
tank  dedupratio     1.00x       -
tank  free           2.70T       -
tank  allocated      8.29G       -
tank  readonly       off         -
$ zpool upgrade
This system is currently running ZFS pool version 28.

The following pools are out of date, and can be upgraded.  After being
upgraded, these pools will no longer be accessible by older software versions.

VER  POOL
---  ------------
15   tank

Use 'zpool upgrade -v' for a list of available versions and their associated
features.

So we need to upgrade our pool to the latest version:

$ zpool upgrade -a
This system is currently running ZFS pool version 28.

Successfully upgraded 'tank'

If you boot from pool 'tank', don't forget to update boot code.
Assuming you use GPT partitioning and da0 is your boot disk
the following command will do it:

    gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0

WARNING: Don’t forget to upgrade boot partition/partitions!

Check disk labels:

$ gpart show
=>        34  5860533101  ada0  GPT  (2.7T)
          34        2014        - free -  (1M)
        2048         128     1  freebsd-boot  (64k)
        2176    33554432     2  freebsd-swap  (16G)
    33556608  5826976527     3  freebsd-zfs  (2.7T)

=>        34  5860533101  ada1  GPT  (2.7T)
          34        2014        - free -  (1M)
        2048         128     1  freebsd-boot  (64k)
        2176    33554432     2  freebsd-swap  (16G)
    33556608  5826976527     3  freebsd-zfs  (2.7T)

I have mirror partitions, so I need to upgrade bootcode on both of them:

$ gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
bootcode written to ada0
$ gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1
bootcode written to ada1

Run once again:

$ zfs upgrade -a
4 filesystems upgraded

Check zpool version:

$ zpool get all tank
NAME  PROPERTY       VALUE       SOURCE
tank  size           2.70T       -
tank  capacity       0%          -
tank  altroot        -           default
tank  health         ONLINE      -
tank  guid           16518060353267231552  default
tank  version        28          default
tank  bootfs         tank/root   local
tank  delegation     on          default
tank  autoreplace    off         default
tank  cachefile      -           default
tank  failmode       wait        default
tank  listsnapshots  off         default
tank  autoexpand     off         default
tank  dedupditto     0           default
tank  dedupratio     1.00x       -
tank  free           2.70T       -
tank  allocated      8.30G       -
tank  readonly       off         -

And don’t forget to reboot:

$ shutdown -r now

Leave a Reply

Your email address will not be published. Required fields are marked *