A: ezjail to qjail migration
Sergei G
sergeig.public at gmail.com
Fri Feb 5 18:20:23 UTC 2016
FYI
If for watever (in)sane reason you need to migrate your ezjail installation
to qjail, here is what appears have worked for me.
* stop jails
* pkg remove ezjail
* comment out your jail related, IP management related /etc/rc.conf entries
* move content of /usr/jails/ to some other location. I moved it to /mnt,
because of the file system remount.
* pkg install qjail (not qjail2)
* qjail install
Actual jail migration
I created a Makefile (it is my personal preference due to ease of named
parameters, auto quit on error and ability to create new task quickly) in
/usr/jails
Here is a relevant Makefile content:
name=noname
lip=254
oldjails=oldjails
oldname=$(name)
n=n
default:
cat Makefile
# create jail
create:
qjail create -n bce0 -4 192.168.3.$(lip) $(name)
# make sync oldname=... name=... n=
old=/mnt/$(oldname)
sync:
rsync -aAXSH$(n)v --log-file=sync-$(name).log
--exclude-from=sync-excl.txt $(old)/etc $(old)/root $(old)/tmp $(old)/usr
$(old)/var $(name)
# push update to jail
s-resolv:
-rm $(name)/etc/resolv.conf
cp flavors/hnet/etc/resolv.conf $(name)/etc/resolv.conf
And important rsync exclusions file:
cat sync-excl.txt
/sbin
/libexec
/sys
/lib
/usr/libdata
/usr/libexec
/usr/src
/usr/include
/usr/bin
/usr/share
/usr/sbin
/usr/lib32
/usr/lib
/usr/ports
/bin
/etc/rc.conf
/etc/periodic.conf
/etc/resolv.conf
For example, if I have wiki-hnet jail in /mnt/wiki-hnet-old and I want to
create a new jail wiki-hnet on the same 192.168.3.11 IP I will do:
1. create qjails jail with:
make create lip=11 name=wiki-hnet
2. now I need to merge content of wiki-hnet-old jail from
/mnt/wiki-hnet-old into new jail:
test run: make sync oldname=wiki-hnet-old name=wiki-hnet
real run: make sync oldname=wiki-hnet-old name=wiki-hnet n=
That uses rsync to copy files, but excludes list of shared jailed
directories. Last 3 items in sync-excl.txt are files that I added, because
of my configuration differences and need to do manual merge.
I had to copy reolv.conf file enough times that there is a custom make
target for that:
make s-resolv name=wiki-hnet
which copies content from flavor directory.
The variables have defaults to prevent destruction in case you forget a
value.
It seems to work for me on fully updated FreeBSD 10.2 release.
More information about the freebsd-questions
mailing list