# Best way to upgrade base jail with ezjail?



## Longfellow (Nov 10, 2015)

I've been practicing with ezjail for managing jails, and for the most part it seems easy. However, I get into trouble upgrading a base jail from one release to another (10.1 to 10.2).

`ezjail-admin update -U -s 10.1-RELEASE` is the command recommended in the handbook for an upgrade. It fails complaining about not being able to install the kernel in /boot/. Is it OK to just call `ezjail-admin install` to replace the old version with the new version?


----------



## sidetone (Nov 10, 2015)

Jails use the same kernel as the host system. It's expected that upgrading a jail won't overwrite the host system's kernel.

You put "10.2-RELEASE" in the upgrade path?

Heres the manpage, ezjail-admin(7)

It says `[B]ezjail-admin[/B] [B]update[/B] [B]-u[/B]` uses a binary update without upgrading releases.
According to it, the example is right for upgrading releases, `[B]ezjail-admin[/B] [B]update[/B] [B]-U[/B] [B]-s[/B] [I]10.2-RELEASE[/I]` .


----------



## Longfellow (Nov 14, 2015)

sidetone said:


> Jails use the same kernel as the host system. It's expected that upgrading a jail won't overwrite the host system's kernel.
> 
> You put "10.2-RELEASE" in the upgrade path?
> 
> ...



Hey sidetone,

Yes, it's not trying to clobber my host's kernel, and the binary upgrade of the host system went smoothly. ezjail's trying and failing to install the kernel in the base jail, and belching a lot of error messages.

I'm not sure what you mean by putting 10.2-RELEASE in the upgrade path, but the command you pointed out is was exactly the one I entered. Though, as I understand, the -s switch needs as an argument the old version running in the jail, so 10.1-RELEASE rather than 10.2. It'll detect that the host is running 10.2 and upgrade the jail to that (hopefully).

I recreated the experiment and captured output of the upgrade here:


```
# ezjail-admin update -U -s 10.1-RELEASE
Looking up update.FreeBSD.org mirrors... 5 mirrors found.
Fetching metadata signature for 10.1-RELEASE from update2.freebsd.org... done.
Fetching metadata index... done.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files... done.
Inspecting system... done.

The following components of FreeBSD seem to be installed:
kernel/generic world/base world/lib32

The following components of FreeBSD do not seem to be installed:
src/src world/doc world/games

Does this look reasonable (y/n)? Does this look reasonable (y/n)? Does this look reasonable (y/n)? Does this look reasonable (y/n)?
Fetching metadata signature for 10.2-RELEASE from update2.freebsd.org... done.
Fetching metadata index... done.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files... done.
Inspecting system... done.
Fetching files from 10.1-RELEASE for merging... done.
Preparing to download files... done.
/usr/sbin/freebsd-update: cannot open files/.gz: No such file or directory
Attempting to automatically merge changes in files... done.

The following file will be removed, as it no longer exists in
FreeBSD 10.2-RELEASE: /boot/device.hints
Does this look reasonable (y/n)?
The following files will be added as part of updating to 10.2-RELEASE-p7:
/etc/autofs/special_media
/etc/autofs/special_noauto
/etc/devd/zfs.conf
/etc/periodic/daily/510.status-world-kernel
/etc/rc.d/growfs
/usr/include/c++/v1/tr1/__refstring
/usr/lib/libmt.so
/var/db/etcupdate/current/etc/autofs/special_media
/var/db/etcupdate/current/etc/autofs/special_noauto
/var/db/etcupdate/current/etc/devd/zfs.conf
/var/db/etcupdate/current/etc/periodic/daily/510.status-world-kernel
/var/db/etcupdate/current/etc/rc.d/growfs
To install the downloaded upgrades, run "/usr/sbin/freebsd-update install".
Installing updates...install: /usr/jails/basejail//etc/autofs/special_media: No such file or directory
install: /usr/jails/basejail//etc/autofs/special_noauto: No such file or directory
install: /usr/jails/basejail//etc/devd/zfs.conf: No such file or directory
install: /usr/jails/basejail//etc/periodic/daily/510.status-world-kernel: No such file or directory
install: /usr/jails/basejail//etc/rc.d/growfs: No such file or directory
install: /usr/jails/basejail//var/db/etcupdate/current/etc/autofs/special_media: No such file or directory
install: /usr/jails/basejail//var/db/etcupdate/current/etc/autofs/special_noauto: No such file or directory
install: /usr/jails/basejail//var/db/etcupdate/current/etc/devd/zfs.conf: No such file or directory
install: /usr/jails/basejail//var/db/etcupdate/current/etc/periodic/daily/510.status-world-kernel: No such file or directory
install: /usr/jails/basejail//var/db/etcupdate/current/etc/rc.d/growfs: No such file or directory
done.
No updates are available to install.
Run '/usr/sbin/freebsd-update fetch' first.
Looking up update.FreeBSD.org mirrors... 5 mirrors found.
Fetching metadata signature for 10.1-RELEASE from update5.freebsd.org... done.
Fetching metadata index... done.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files... done.
Inspecting system... done.

The following components of FreeBSD seem to be installed:
kernel/generic

The following components of FreeBSD do not seem to be installed:
src/src world/base world/doc world/games world/lib32

Does this look reasonable (y/n)?
Fetching metadata signature for 10.2-RELEASE from update5.freebsd.org... done.
Fetching metadata index... done.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files... done.
Inspecting system... done.
Preparing to download files... done.

The following files will be added as part of updating to 10.2-RELEASE-p7:
/boot/kernel/if_cxl.ko
/boot/kernel/if_cxl.ko.symbols
/boot/kernel/if_ix.ko
/boot/kernel/if_ix.ko.symbols
/boot/kernel/if_ixv.ko
/boot/kernel/if_ixv.ko.symbols
/boot/kernel/if_me.ko
/boot/kernel/if_me.ko.symbols
/boot/kernel/if_oce.ko
/boot/kernel/if_oce.ko.symbols
/boot/kernel/if_vxlan.ko
/boot/kernel/if_vxlan.ko.symbols
/boot/kernel/mrsas_linux.ko
/boot/kernel/mrsas_linux.ko.symbols
/boot/kernel/pmspcv.ko
/boot/kernel/pmspcv.ko.symbols
/boot/kernel/uled.ko
/boot/kernel/uled.ko.symbols
/boot/kernel/virtio_console.ko
/boot/kernel/virtio_console.ko.symbols
To install the downloaded upgrades, run "/usr/sbin/freebsd-update install".
Installing updates...install: /usr/jails/newjail//boot/kernel/if_cxl.ko: No such file or directory
install: /usr/jails/newjail//boot/kernel/if_cxl.ko.symbols: No such file or directory
install: /usr/jails/newjail//boot/kernel/if_ix.ko: No such file or directory
install: /usr/jails/newjail//boot/kernel/if_ix.ko.symbols: No such file or directory
install: /usr/jails/newjail//boot/kernel/if_ixv.ko: No such file or directory
install: /usr/jails/newjail//boot/kernel/if_ixv.ko.symbols: No such file or directory
install: /usr/jails/newjail//boot/kernel/if_me.ko: No such file or directory
install: /usr/jails/newjail//boot/kernel/if_me.ko.symbols: No such file or directory
install: /usr/jails/newjail//boot/kernel/if_oce.ko: No such file or directory
install: /usr/jails/newjail//boot/kernel/if_oce.ko.symbols: No such file or directory
install: /usr/jails/newjail//boot/kernel/if_vxlan.ko: No such file or directory
install: /usr/jails/newjail//boot/kernel/if_vxlan.ko.symbols: No such file or directory
install: /usr/jails/newjail//boot/kernel/mrsas_linux.ko: No such file or directory
install: /usr/jails/newjail//boot/kernel/mrsas_linux.ko.symbols: No such file or directory
install: /usr/jails/newjail//boot/kernel/pmspcv.ko: No such file or directory
install: /usr/jails/newjail//boot/kernel/pmspcv.ko.symbols: No such file or directory
install: /usr/jails/newjail//boot/kernel/uled.ko: No such file or directory
install: /usr/jails/newjail//boot/kernel/uled.ko.symbols: No such file or directory
install: /usr/jails/newjail//boot/kernel/virtio_console.ko: No such file or directory
install: /usr/jails/newjail//boot/kernel/virtio_console.ko.symbols: No such file or directory

Kernel updates have been installed.  Please reboot and run
"/usr/sbin/freebsd-update install" again to finish installing updates.
Installing updates... done.
No updates are available to install.
Run '/usr/sbin/freebsd-update fetch' first.
```


----------



## sidetone (Nov 14, 2015)

About the kernels, all jails share the same kernel as your host or base system. You wouldn't need to build a jail kernel. Ezjail isn't supposed to install a kernel in the base jail. Perhaps the fact that it tries is a bug that makes `freebsd-update` not fully compatible at the moment with `ezjail-admin`.



Longfellow said:


> I'm not sure what you mean by putting 10.2-RELEASE in the upgrade path


You were upgrading from 10.1 to 10.2 right, as in `[B]ezjail-admin[/B] [B]update[/B] [B]-U[/B] [B]-s[/B] [I]10.2-RELEASE[/I]` ?


----------



## ibgb (Jan 13, 2017)

sidetone said:


> You were upgrading from 10.1 to 10.2 right, as in `[B]ezjail-admin[/B] [B]update[/B] [B]-U[/B] [B]-s[/B] [I]10.2-RELEASE[/I]` ?



I think sidetone has it wrong. ezjail calls freebsd-update which can know the host version os, but not what is in the basejail, so you have to tell it what is in the basejail so it knows how to upgrade it. So for the OP, going from 10.1 > 10.2 he would tell it that the basejail is at 10.1

`[B]ezjail-admin[/B] [B]update[/B] [B]-U[/B] [B]-s[/B] [I]10.1-RELEASE[/I]`

Then it should go from 10.1 > 10.2 in the basejail.

The documentation does not say that freebsd-update spits out some spurious lines ( I think/hope they are spurious ) at the end, like below lines which I got:


```
/boot/kernel/systrace_linux.ko.symbols
To install the downloaded upgrades, run "/usr/sbin/freebsd-update install".
src component not installed, skipped
Installing updates...mkdir: /usr/jails/newjail//boot: No such file or directory
mtree: /usr/jails/newjail//boot/kernel: No such file or directory
mtree: /usr/jails/newjail//boot/kernel.old: No such file or directory
touch: /usr/jails/newjail//boot/kernel.old/.freebsd-update: No such file or directory
Could not create kernel backup directory
```

I think those lines are there because ezjail-admin just calls freebsd-update, but if I am wrong, I hope somebody corrects me and this post.

In the forums there the most questions about upgrading and ports; maybe better documentation?


----------



## getopt (Jan 13, 2017)

ibgb said:


> maybe better documentation


ezjail-admin(8) is very clear about `ezjail-admin update`.


> -s sourcedir | sourceosversion
> In the -b and -i case: Use the sources in sourcedir instead of /usr/src.  Variable:
> ''$ezjail_sourcetree''.
> 
> In the -U case: Pass this release tag to freebsd-update(8) as the source OS version of the basejail.


So you got it wrong.


ibgb said:


> some spurious lines ( I think/hope they are spurious ) at the end


These lines are generated because jails use the kernel of the jail-host, thus no kernel can be installed in a jail (in contrast to other virtualization methods). So the "spurious lines" can be ignored.


----------



## ibgb (Jan 13, 2017)

getopt said:


> ezjail-admin(8) is very clear about `ezjail-admin update`.
> 
> So you got it wrong.
> 
> These lines are generated because jails use the kernel of the jail-host, thus no kernel can be installed in a jail (in contrast to other virtualization methods). So the "spurious lines" can be ignored.



I think we are saying the same thing.

From the manual:
=========
To upgrade the basejail to a new version, first upgrade the host system as described in Section 23.2.3, “Performing Major and Minor Version Upgrades”. Once the host has been upgraded and rebooted, the basejail can then be upgraded. freebsd-update(8) has no way of determining which version is currently installed in the basejail, so the
original version must be specified. Use file(1) to determine the original version in the basejail:

#`file /usr/jails/basejail/bin/sh`
/usr/jails/basejail/bin/sh: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), ↺ dynamically linked (uses shared libs), for FreeBSD 9.3, stripped

Now use this information to perform the upgrade* from 9.3-RELEASE *to the current version of the host system:

`#ezjail-adminupdate-U -s 9.3-RELEASE`
=========

So this `ezjail-adminupdate-U -s 9.3-RELEASE` would upgrade the base jail from 9.3-RELEASE to whatever the current host version (10.1, etc.) is.

The OP was going from 10.1 to 10.2, so he would 
`# file /usr/jails/basejail/bin/sh`
 and get a 10.1-RELEASE for the basejail and then pass that version to 
`# ezjail-adminupdate-U -s 10.1-RELEASE`

*In the -U case: Pass this release tag to freebsd-update(8) as the source OS version of the basejail.*

So the OP would have 10.1-RELEASE in his basejail, correct? So to upgrade the basejail he would pass that 10.1-RELEASE with the -s option. Sidetone instructs the OP to pass a 10.2-RELEASE with the -s option.

So to upgrade a 10.1-RELEASE basejail to 10.2, which gets passed with the -s option?


----------



## mecano (May 22, 2018)

As stated as the man page and as you understood it, 10.1-RELEASE in that case. Read this https://forums.freebsd.org/threads/ezjail-and-major-host-upgrades.52203/#post-292852 for a more complete process.


----------

