Migration of Jail from one host to another?

Scott Lambert lambert at lambertfam.org
Wed Jul 2 20:55:02 UTC 2008


I'm probably doing this completely wrong.  I setup a couple of jails
using simple image files because I thought that would make migration
to another server more straightforward.  I am now trying to migrate my
first jail.

I am using the ezjail tools for creating and maintaining jails.

The existing jail host is 6.2-STABLE FreeBSD 6.2-STABLE #1: Sun Mar 11
21:46:01 CDT 2007, ezjail-2.0.1.

The new jail host is 7.0-STABLE FreeBSD 7.0-STABLE #0: Sat May 10
06:29:00 CDT 2008, ezjail-2.1.

I have created a test jail on the 7.0-STABLE box with ezjail-admin which
works perfectly, using what I believe were the exact same parameters
given, other than IP/hostname, when I created the 6.2-STABLE jail.

 # ezjail-admin create -i -s 1G test 192.168.8.237

I have moved over the fstab.migrate_jail file, and the
/u/l/e/ezjail/migrate_jail config file for the 6.2-STABLE jail to the
7.0-STABLE box and created an empty directory beside the 7.0 test jail's
empty directory.  I shut down the jail on the 6.2-STABLE host and
scp'd the image file to the 7.0-STABLE box.  I put it beside the empty
jail directory.  I made sure the fstab.test and the fstab.migrate_jail
look the same except for jail name changes.  I made sure the
/u/l/e/ezjail/test and /u/l/e/ezjail/migrate_jail files look the same
except for jail name changes.

 # more /etc/fstab.test
/home/ezjails/test.device /home/ezjails/test ufs rw 0 0
/home/ezjails/basejail /home/ezjails/test/basejail nullfs ro 0 0

 # more /etc/fstab.migrate_jail
/home/ezjails/migrate.jail.device /home/ezjails/migrate.jail ufs rw 0 0
/home/ezjails/basejail /home/ezjails/migrate.jail/basejail nullfs ro 0 0

 # more test_tcworks_net 
export jail_test_hostname="test"
export jail_test_ip="192.168.8.237"
export jail_test_rootdir="/home/ezjails/test"
export jail_test_exec="/bin/sh /etc/rc"
export jail_test_mount_enable="YES"
export jail_test_devfs_enable="YES"
export jail_test_devfs_ruleset="devfsrules_jail"
export jail_test_procfs_enable="YES"
export jail_test_fdescfs_enable="YES"
export jail_test_image="/home/ezjails/test.img"
export jail_test_imagetype="simple"
export jail_test_attachparams=""
export jail_test_attachblocking=""
export jail_test_forceblocking=""

 # more migrate_jail
export jail_migrate_jail_hostname="migrate.jail"
export jail_migrate_jail_ip="192.168.8.238"
export jail_migrate_jail_rootdir="/home/ezjails/migrate.jail"
export jail_migrate_jail_exec="/bin/sh /etc/rc"
export jail_migrate_jail_mount_enable="YES"
export jail_migrate_jail_devfs_enable="YES"
export jail_migrate_jail_devfs_ruleset="devfsrules_jail"
export jail_migrate_jail_procfs_enable="YES"
export jail_migrate_jail_fdescfs_enable="YES"
export jail_migrate_jail_image="/home/ezjails/migrate.jail.img"
export jail_migrate_jail_imagetype="simple"
export jail_migrate_jail_attachparams=""
export jail_migrate_jail_attachblocking=""
export jail_migrate_jail_forceblocking=""

14:35:33 Wed Jul 02 # egrep -v '^(#|$)' ../ezjail.conf 
ezjail_jaildir=/home/ezjails

 /usr/local/etc/rc.d/ezjail.sh start                
 ezjailConfiguring jails:.
Starting jails: testnetmount: /home/ezjails/migrate.jail.device : Operation not permitted
df: /home/ezjails/migrate.jail/dev: No such file or directory
mount: /home/ezjails/migrate.jail/dev: No such file or directory
/etc/rc.d/jail: WARNING: devfs_domount(): Unable to mount devfs on /home/ezjails/migrate.jail/dev
/etc/rc.d/jail: WARNING: devfs_mount_jail: devfs was not mounted on /home/ezjails/migrate.jail/dev
cd: can't cd to /home/ezjails/migrate.jail/dev
mount: /home/ezjails/migrate.jail/dev: No such file or directory
 cannot start jail "migrate_jail": 
jail: getpwnam: root: No such file or directory
.

 # ls -la /home/ezjails/
total 2098282
drwxr-xr-x     9 root  wheel         512 Jul  2 14:27 .
drwxr-xr-x  3182 root  wheel       58368 Jun  3 22:58 ..
drwxr-xr-x     9 root  wheel         512 Jun  4 00:40 basejail
drwxr-xr-x     2 root  wheel         512 Jun  3 22:58 ezjailtemp
drwxr-xr-x     3 root  wheel         512 Jun  4 00:41 flavours
drwxr-xr-x     2 root  wheel         512 Jul  1 16:54 fulljail
lrwxr-xr-x     1 root  wheel          14 Jul  2 13:45 log -> ../var/run/log
drwxr-xr-x    12 root  wheel         512 Jun  4 00:41 newjail
drwxr-xr-x     2 root  wheel         512 Jul  1 17:43 migrate.jail
lrwxr-xr-x     1 root  wheel           8 Jul  2 14:27 migrate.jail.device -> /dev/md9
-rw-r--r--     1 root  wheel  1073741824 Jul  1 17:02 migrate.jail.img
drwxr-xr-x    13 root  wheel         512 Jul  2 13:46 test
lrwxr-xr-x     1 root  wheel           8 Jul  2 14:27 test.device -> /dev/md8
-rw-r--r--     1 root  wheel  1073741824 Jul  2 14:28 test.img

 # ls -la /home/ezjails/migrate.jail
total 4
drwxr-xr-x  2 root  wheel  512 Jul  1 17:43 .
drwxr-xr-x  9 root  wheel  512 Jul  2 14:27 ..

 # ls -la /home/ezjails/test
total 31
drwxr-xr-x  13 root  wheel      512 Jul  2 13:46 .
drwxr-xr-x   9 root  wheel      512 Jul  2 14:27 ..
drwxrwxr-x   2 root  operator   512 Jul  2 13:46 .snap
-r--r--r--   1 root  wheel     6188 Jul  2 13:46 COPYRIGHT
drwxr-xr-x   9 root  wheel      512 Jun  4 00:40 basejail
lrwxrwxrwx   1 root  wheel       13 Jul  2 13:46 bin -> /basejail/bin
lrwxrwxrwx   1 root  wheel       14 Jul  2 13:46 boot -> /basejail/boot
dr-xr-xr-x   5 root  wheel      512 Jul  2 14:27 dev
drwxr-xr-x  20 root  wheel     2048 Jul  2 13:50 etc
lrwxrwxrwx   1 root  wheel       13 Jul  2 13:46 lib -> /basejail/lib
lrwxrwxrwx   1 root  wheel       17 Jul  2 13:46 libexec -> /basejail/libexec
drwxr-xr-x   2 root  wheel      512 Jul  2 13:46 media
drwxr-xr-x   2 root  wheel      512 Jul  2 13:46 mnt
dr-xr-xr-x   1 root  wheel        0 Jul  2 14:31 proc
lrwxrwxrwx   1 root  wheel       16 Jul  2 13:46 rescue -> /basejail/rescue
drwxr-xr-x   2 root  wheel      512 Jul  2 13:46 root
lrwxrwxrwx   1 root  wheel       14 Jul  2 13:46 sbin -> /basejail/sbin
lrwxrwxrwx   1 root  wheel       11 Jul  2 13:46 sys -> usr/src/sys
drwxrwxrwt   6 root  wheel      512 Jul  2 14:27 tmp
drwxr-xr-x   4 root  wheel      512 Jul  2 13:46 usr
drwxr-xr-x  22 root  wheel      512 Jul  2 14:27 var

 # /usr/local/etc/rc.d/ezjail.sh stop 
rcorder: could not open log: No such file or directory
 ezjailStopping jails: test.tcworks.net.

The log symlink exists in the /u/l/e/ezjails directory on the 6.2-STABLE
host also, but I don't remember it messing with rcorder.  I can't just
run an ezjail.sh stop command on that host to test as I have other
production jails there.  I don't think it has anything to do with my
problem, but...

 # ls -la /home/ezjails/
total 2098282
drwxr-xr-x     9 root  wheel         512 Jul  2 14:32 .
drwxr-xr-x  3182 root  wheel       58368 Jun  3 22:58 ..
drwxr-xr-x     9 root  wheel         512 Jun  4 00:40 basejail
drwxr-xr-x     2 root  wheel         512 Jun  3 22:58 ezjailtemp
drwxr-xr-x     3 root  wheel         512 Jun  4 00:41 flavours
drwxr-xr-x     2 root  wheel         512 Jul  1 16:54 fulljail
lrwxr-xr-x     1 root  wheel          14 Jul  2 13:45 log -> ../var/run/log
drwxr-xr-x    12 root  wheel         512 Jun  4 00:41 newjail
drwxr-xr-x     2 root  wheel         512 Jul  1 17:43 migrate.jail
lrwxr-xr-x     1 root  wheel           8 Jul  2 14:27 migrate.jail.device -> /dev/md9
-rw-r--r--     1 root  wheel  1073741824 Jul  1 17:02 migrate.jail.img
drwxr-xr-x     2 root  wheel         512 Jul  2 13:46 test
-rw-r--r--     1 root  wheel  1073741824 Jul  2 14:32 test.img

I'm obviously missing something obvious here.  A clue-by-four to the
head would be much appreciated.

-- 
Scott Lambert                    KC5MLE                       Unix SysAdmin
lambert at lambertfam.org



More information about the freebsd-jail mailing list