zfs - some simple things to know

Notes on getting data off a zfs disk.

zfs - some simple things to know

The Z File System (zfs) has many sophisicated capabilities. This comes with need to learn new terms and command to manage it.

These are my notes on zfs to allow some basis management of zfs partitioned disks. As always notes are driven by my needs (which are simple) and not to provide lots and lots of information on the multitude of possible zfs scenarios.


Find the pools on a zfs partition

In this case you have an existing partitioned disk with zfs "pool" on it and need to mount it to copy files off a pool. So we need to first find what are the available pools.

  1. Look at this: "geom disk list"
  2. Look at the partition table, to confirm it has zfs partition: "gpart show ada1"
  3. Create a place to mount it: "mkdir /mnt/ZFS-ROOT"
---
--- What disk are connected ?
---
$ geom disk list
Geom name: ada0
Providers:
1. Name: ada0
   Mediasize: 64424509440 (60G)
   Sectorsize: 512
   Mode: r3w3e5
   descr: QEMU HARDDISK
   ident: QM00001
   rotationrate: unknown
   fwsectors: 63
   fwheads: 16

Geom name: ada1
Providers:
1. Name: ada1
   Mediasize: 64424509440 (60G)
   Sectorsize: 512
   Mode: r0w0e0
   descr: QEMU HARDDISK
   ident: QM00005
   rotationrate: unknown
   fwsectors: 63
   fwheads: 16

Geom name: cd0
Providers:
1. Name: cd0
   Mediasize: 0 (0B)
   Sectorsize: 2048
   Mode: r0w0e0
   descr: QEMU QEMU DVD-ROM
   ident: (null)
   rotationrate: unknown
   fwsectors: 0
   fwheads: 0
---
--- what partitions are on ada1
---
$ gpart show ada1
=>       40  125829040  ada1  GPT  (60G)
         40     409600     1  efi  (200M)
     409640       2008        - free -  (1.0M)
     411648    4194304     2  freebsd-swap  (2.0G)
    4605952  121221120     3  freebsd-zfs  (58G)
  125827072       2008        - free -  (1.0M)
  ---
  --- Create a place to mount a zfs pool (from root)
  ---
# mkdir /mnt/ZFS-POOL
---
--- What pools are available ?
---
# zpool import
   pool: zroot
     id: 569129416606451842
  state: ONLINE
status: Some supported features are not enabled on the pool.
	(Note that they may be intentionally disabled if the
	'compatibility' property is set.)
 action: The pool can be imported using its name or numeric identifier, though
	some features will not be available without an explicit 'zpool upgrade'.
 config:

	zroot                                         ONLINE
	  gptid/e0ef5988-91e7-11ea-b3f8-cfc9bb16dfc9  ONLINE

Mount a pool within zfs partition

In this case you have an existing partitioned disk with zfs "pool" on it and need to mount it to copy files off the pool. Example is have disk which has file systems from prior FreeBSD installation which has single root pool.

  1. Find available pools (as above), we are going to mount "zroot" read only
  2. Mount the existing root file system pool (read only): "zpool import zroot -d /dev -o readonly=on -R /mnt/ZFS-POOL"
---
--- Mount pool
---
# zpool import zroot -d /dev -o readonly=on -R /mnt/ZFS-POOL
---
--- see whats there ...
---
# ls /mnt/ZFS-POOL
tmp	usr	var	zroot

References & Links:

ZFS History - on wikipedia of course. I looked up this as it was not clear exactly what FreeBSD zfs implementation is based on. Initially it was the Sun Solaris Open Source base, but appears to be converging onto OpenZFS.

Oracle ZFS Documentation - this is where Sun's ZFS went

"ZFS - How to mount a zfs partition" - this rather rambling and long discussion on trying to do something very simple prompted me to write my notes...


Picture - ZFS on FreeBSD from the OpenZFS page, see history above