Search code examples
freebsdjail

FreeBSD-11 EZJail install fails with tar unable to chdir


On a FreeBSD-11.1 host I removed an existing installation of ezjail using the following commands:

pkg remove ezjail
rm -rf /usr/local/etc/ezjail.conf
rm -rf /usr/local/etc/ezjail
chflags -R noschg /usr/jails
rm -rf /usr/jails
zfs destroy -r zroot/ezjail

I also checked for /etc/fstab.* and found none.

I then reinstalled ezjail using pkg and recreated the zfs ezjail partition:

zfs create -p zroot/ezjail

I also modified /usr/local/etc/ezjail.conf to use zfs:

ezjail_use_zfs="YES"
ezjail_use_zfs_for_jails="YES"
ezjail_jailzfs="zroot/ezjail"

However, when I run ezjail-admin install I get this error:

ezjail-admin install
base.txz                                      100% of   99 MB  621 kBps 02m45s
tar: could not chdir to '/usr/jails/fulljail'

ll /usr/jails
total 0

ll /usr/local/etc/ezjail
total 0

zfs list | grep jail
zroot/ezjail              176K   883G    88K  /zroot/ezjail
zroot/ezjail/fulljail      88K   883G    88K  /zroot/ezjail/fulljail

What has happened and how do I fix it?


Solution

  • This issue arose because the initial install of ezjail on this system did not use zfs. Consequently, the directories /usr/jails/fulljail and /usr/jails/newjail were created on the zroot/usr dataset. When I witched ezjail over to zfs I did not realise that this had happened. Somehow the existence of these two directories in zpool/usr conflicted with the same directories in zroot/ezjail under its mount point /usr/jails.

    This condition was only discovered after I had destroyed zroot/ezjail in preparation for a clean install of ezjail. My solution was to also remove these directories and the entire /usr/jail directory tree from zroot/usr before reinstalling ezjail with zfs enabled in /usr/local/etc/ezjail.conf.

    To lessen the pain of all this I made an archive of the jail first and recreated it from the archive following the ezjail reinstallation.