In part 1 of my FreeBSD jail adventure, I switched from iocage to my own homespun jails. This will be a short piece on updating those base jails.
Since they are all nullfs mounting the same directories, you only have to update things once.
Note
|
Allan Jude mentioned doing symlinks instead of nullfs, but I haven’t tried that. You can hear his comments on BSD Now. |
Update the Host
First, you will want to update the host. However you want to go about this, go for it. For me, I use freebsd-update
.
I do a trick I learned from vermaden, though, it was something I found in a tweet
that was posted, maybe there’s an article…
bectl create 2022-02-25_13.0
bectl mount 2022-02-25_13.0
chroot /tmp/be_bootenv_id
mount -t devfs devfs /dev
freebsd-update fetch install
pkg update
pkg upgrade
exit
bectl activate 2022-02-25_13.0
shutdown -r now
The system will be rebooted and then you will boot into the new boot environment with the updates applied.
Jail Updates
Now let us update the jails. From the previous article, note I made the zfs dataset that is nullfs
mounted from at zroot/jails/templates/base-13.0-RELEASE
. This is what we will be updating.
First I take a snapshot of it (in case things go sideways)
zfs snapshot zroot/jails/templates/base-13.0-RELEASE@2022-02-25_update
Then I update it with the freebsd-update utility:
env UNAME_r=13.0-RELEASE freebsd-update -b /jails/templates/base-13.0-RELEASE fetch install
Now with the base image updated, I don’t know if it’s necessary (didn’t check, will update this in the future to add clarity),
but I restarted all my jails too while I was at it with service jail restart
. Of course, if not all your jails
are using the same base, you can restart them individually. Or, you can verify before/after to see if the changes
were applied without restarting the jails by taking a uname -a
before and after and confirming that the
change did happen. I inadvertantly updated the jails before the host because I rebooted without applying the
boot environment from before :)
And that’s it! All the base jails you have should be updated now, then you can do your pkg update/upgrades in your jails as necessary.
Once I’m done I also like to remove the old snapshot. I know the system is working right so I don’t need it anymore.