FreeBSD jailed ZFS datasets – how do I find the .zfs/snapshot directory?

On FreeBSD, you can jail a ZFS dataset – that is, the jail can manipulate the ZFS dataset as if it was a host (more or less). This has useful applications.

In my case, I want to backup a snapshot of that dataset from the host.

For example, I want to backup this dataset:

[12:19 r730-01 dvl ~] % zfs list data02/freshports/jailed/dev-ingress01/data/latest_commits
NAME                                                         USED  AVAIL  REFER  MOUNTPOINT
data02/freshports/jailed/dev-ingress01/data/latest_commits   572K   798G   120K  /var/db/ingress/latest_commits

Within the jail, the path to that dataset is /var/db/ingress/latest_commits. Indeed, within the jail, you can see the snapshots, including the one I want to backup ( snapshot-for-backup):

[12:21 dev-ingress01 dan /var/db/ingress/latest_commits] % cd .zfs/snapshot
[12:21 dev-ingress01 dan /var/db/ingress/latest_commits/.zfs/snapshot] % ls
autosnap_2023-12-25_06:00:02_hourly/     autosnap_2023-12-25_10:00:03_hourly/     autosnap_2023-12-25_11:15:02_frequently/ autosnap_2023-12-25_12:00:00_hourly/
autosnap_2023-12-25_07:00:08_hourly/     autosnap_2023-12-25_10:45:04_frequently/ autosnap_2023-12-25_11:30:04_frequently/ autosnap_2023-12-25_12:15:04_frequently/
autosnap_2023-12-25_08:00:03_hourly/     autosnap_2023-12-25_11:00:02_frequently/ autosnap_2023-12-25_11:45:00_frequently/ snapshot-for-backup/
autosnap_2023-12-25_09:00:10_hourly/     autosnap_2023-12-25_11:00:02_hourly/     autosnap_2023-12-25_12:00:00_frequently/
[12:21 dev-ingress01 dan /var/db/ingress/latest_commits/.zfs/snapshot] % 

The problem to solve: how to go from this:

/var/db/ingress/latest_commits/.zfs/snapshot

to this:

/jails/dev-ingress01/var/db/ingress/latest_commits/.zfs/snapshot

when all you have is the dataset name:

data02/freshports/jailed/dev-ingress01/data/latest_commits

zfs get all

I know how to get this information about the dataset. Line 13 has the mount point. That’s part of what is needed.

[12:08 r730-01 dvl ~] % zfs get all data02/freshports/jailed/dev-ingress01/data/latest_commits
NAME                                                        PROPERTY              VALUE                           SOURCE
data02/freshports/jailed/dev-ingress01/data/latest_commits  type                  filesystem                      -
data02/freshports/jailed/dev-ingress01/data/latest_commits  creation              Sun Dec 24 19:43 2023           -
data02/freshports/jailed/dev-ingress01/data/latest_commits  used                  572K                            -
data02/freshports/jailed/dev-ingress01/data/latest_commits  available             798G                            -
data02/freshports/jailed/dev-ingress01/data/latest_commits  referenced            120K                            -
data02/freshports/jailed/dev-ingress01/data/latest_commits  compressratio         1.79x                           -
data02/freshports/jailed/dev-ingress01/data/latest_commits  mounted               yes                             -
data02/freshports/jailed/dev-ingress01/data/latest_commits  quota                 none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  reservation           none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  recordsize            32K                             inherited from data02/freshports/jailed/dev-ingress01
data02/freshports/jailed/dev-ingress01/data/latest_commits  mountpoint            /var/db/ingress/latest_commits  local
data02/freshports/jailed/dev-ingress01/data/latest_commits  sharenfs              off                             default
data02/freshports/jailed/dev-ingress01/data/latest_commits  checksum              on                              default
data02/freshports/jailed/dev-ingress01/data/latest_commits  compression           on                              inherited from data02
data02/freshports/jailed/dev-ingress01/data/latest_commits  atime                 off                             inherited from data02
data02/freshports/jailed/dev-ingress01/data/latest_commits  devices               on                              default
data02/freshports/jailed/dev-ingress01/data/latest_commits  exec                  on                              default
data02/freshports/jailed/dev-ingress01/data/latest_commits  setuid                on                              default
data02/freshports/jailed/dev-ingress01/data/latest_commits  readonly              off                             default
data02/freshports/jailed/dev-ingress01/data/latest_commits  jailed                on                              inherited from data02/freshports/jailed/dev-ingress01
data02/freshports/jailed/dev-ingress01/data/latest_commits  snapdir               hidden                          default
data02/freshports/jailed/dev-ingress01/data/latest_commits  aclmode               discard                         default
data02/freshports/jailed/dev-ingress01/data/latest_commits  aclinherit            restricted                      default
data02/freshports/jailed/dev-ingress01/data/latest_commits  createtxg             8714200                         -
data02/freshports/jailed/dev-ingress01/data/latest_commits  canmount              on                              default
data02/freshports/jailed/dev-ingress01/data/latest_commits  xattr                 on                              default
data02/freshports/jailed/dev-ingress01/data/latest_commits  copies                1                               default
data02/freshports/jailed/dev-ingress01/data/latest_commits  version               5                               -
data02/freshports/jailed/dev-ingress01/data/latest_commits  utf8only              off                             -
data02/freshports/jailed/dev-ingress01/data/latest_commits  normalization         none                            -
data02/freshports/jailed/dev-ingress01/data/latest_commits  casesensitivity       sensitive                       -
data02/freshports/jailed/dev-ingress01/data/latest_commits  vscan                 off                             default
data02/freshports/jailed/dev-ingress01/data/latest_commits  nbmand                off                             default
data02/freshports/jailed/dev-ingress01/data/latest_commits  sharesmb              off                             default
data02/freshports/jailed/dev-ingress01/data/latest_commits  refquota              none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  refreservation        none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  guid                  15864338690700456792            -
data02/freshports/jailed/dev-ingress01/data/latest_commits  primarycache          all                             default
data02/freshports/jailed/dev-ingress01/data/latest_commits  secondarycache        all                             default
data02/freshports/jailed/dev-ingress01/data/latest_commits  usedbysnapshots       452K                            -
data02/freshports/jailed/dev-ingress01/data/latest_commits  usedbydataset         120K                            -
data02/freshports/jailed/dev-ingress01/data/latest_commits  usedbychildren        0B                              -
data02/freshports/jailed/dev-ingress01/data/latest_commits  usedbyrefreservation  0B                              -
data02/freshports/jailed/dev-ingress01/data/latest_commits  logbias               latency                         default
data02/freshports/jailed/dev-ingress01/data/latest_commits  objsetid              61452                           -
data02/freshports/jailed/dev-ingress01/data/latest_commits  dedup                 off                             default
data02/freshports/jailed/dev-ingress01/data/latest_commits  mlslabel              none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  sync                  standard                        default
data02/freshports/jailed/dev-ingress01/data/latest_commits  dnodesize             legacy                          default
data02/freshports/jailed/dev-ingress01/data/latest_commits  refcompressratio      1.95x                           -
data02/freshports/jailed/dev-ingress01/data/latest_commits  written               68K                             -
data02/freshports/jailed/dev-ingress01/data/latest_commits  logicalused           537K                            -
data02/freshports/jailed/dev-ingress01/data/latest_commits  logicalreferenced     114K                            -
data02/freshports/jailed/dev-ingress01/data/latest_commits  volmode               default                         default
data02/freshports/jailed/dev-ingress01/data/latest_commits  filesystem_limit      none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  snapshot_limit        none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  filesystem_count      none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  snapshot_count        none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  snapdev               hidden                          default
data02/freshports/jailed/dev-ingress01/data/latest_commits  acltype               nfsv4                           default
data02/freshports/jailed/dev-ingress01/data/latest_commits  context               none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  fscontext             none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  defcontext            none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  rootcontext           none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  relatime              on                              default
data02/freshports/jailed/dev-ingress01/data/latest_commits  redundant_metadata    all                             default
data02/freshports/jailed/dev-ingress01/data/latest_commits  overlay               on                              default
data02/freshports/jailed/dev-ingress01/data/latest_commits  encryption            off                             default
data02/freshports/jailed/dev-ingress01/data/latest_commits  keylocation           none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  keyformat             none                            default
data02/freshports/jailed/dev-ingress01/data/latest_commits  pbkdf2iters           0                               default
data02/freshports/jailed/dev-ingress01/data/latest_commits  special_small_blocks  0                               default
data02/freshports/jailed/dev-ingress01/data/latest_commits  snapshots_changed     Mon Dec 25 12:00:00 2023        -

What is missing

I think the missing information is the name of the jail (dev-ingress01) and the mountpoint (root) of that jail, relative to the host (/jails/dev-ingress01).

mount point

I think we can get the mountpoint from jls:

[12:28 r730-01 dvl ~] % jls -j dev-ingress01
   JID  IP Address      Hostname                      Path
     8  10.55.0.37      dev-ingress01.int.unixathome. /jails/dev-ingress01

Jailed into what jail

How can I find out what jail a given dataset is jailed with?

That’s the missing information.

I may move to non-jailed datasets for stuff which needs backing up this way.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top