May 312013
 

ezjail is my tool of choice for managing jails. I’ve been using it since 2008. Today, I want to do something which ezjail won’t do for me, but will allow me to do. I created a bunch of jails for a Bacula tutorial at BSDCan. Now that I have that server safely home again, I need to add more services to this jail server. My main development machine is acting up. It is several years old, has 40G disks in it. Everything on that server needs to go into another server.

I want to change several things about the existing bacula jails:

  1. name
  2. ip address
  3. mount point

All of these items are related. The bacula101 jail is mounted at /usr/local/jails/bacula101. It has IP address ending with 101. So we need to adjust several things:

  1. /usr/local/etc/bacula101 needs to be renamed and its contents updated
  2. /etc/fstab.bacula101 needs to be renamed and contents updated
  3. the ZFS file system needs to be renamed
  4. the ZFS file system’s mount point needs to be changed

I will not show the changing of the IP address on the network adaptor. You’ll need to do that on your own.

Let’s go!

First!

First, stop the jail you are trying to adjust:

/usr/local/etc/rc.d/ezjail-admin stop bacula101

ezjail configuration file

The first step I took was altering the ezjail configuration file. In this step, I rename the file:

cd /usr/local/etc/ezjail
mv -i bacula101 bacula151

Here’s the contents of that file before my changes:

# To specify the start up order of your ezjails, use these lines to
# create a Jail dependency tree. See rcorder(8) for more details.
#
# PROVIDE: standard_ezjail
# REQUIRE: 
# BEFORE: 
#

export jail_bacula101_hostname="bacula101"
export jail_bacula101_ip="10.0.44.101"
export jail_bacula101_rootdir="/usr/local/jails/bacula101"
export jail_bacula101_exec_start="/bin/sh /etc/rc"
export jail_bacula101_exec_stop=""
export jail_bacula101_mount_enable="YES"
export jail_bacula101_devfs_enable="YES"
export jail_bacula101_devfs_ruleset="devfsrules_jail"
export jail_bacula101_procfs_enable="YES"
export jail_bacula101_fdescfs_enable="YES"
export jail_bacula101_image=""
export jail_bacula101_imagetype="zfs"
export jail_bacula101_attachparams=""
export jail_bacula101_attachblocking=""
export jail_bacula101_forceblocking=""
export jail_bacula101_zfs_datasets=""
export jail_bacula101_cpuset=""
export jail_bacula101_fib=""
export jail_bacula101_parentzfs="system/usr/local/jails"
export jail_bacula101_parameters=""
export jail_bacula101_post_start_script=""

And with my changes:

# To specify the start up order of your ezjails, use these lines to
# create a Jail dependency tree. See rcorder(8) for more details.
#
# PROVIDE: standard_ezjail
# REQUIRE:
# BEFORE:
#

export jail_bacula151_hostname="bacula151"
export jail_bacula151_ip="10.55.0.151" 
export jail_bacula151_rootdir="/usr/local/jails/bacula151"
export jail_bacula151_exec_start="/bin/sh /etc/rc"
export jail_bacula151_exec_stop=""
export jail_bacula151_mount_enable="YES"
export jail_bacula151_devfs_enable="YES"
export jail_bacula151_devfs_ruleset="devfsrules_jail"
export jail_bacula151_procfs_enable="YES"
export jail_bacula151_fdescfs_enable="YES"
export jail_bacula151_image=""
export jail_bacula151_imagetype="zfs"
export jail_bacula151_attachparams=""
export jail_bacula151_attachblocking=""
export jail_bacula151_forceblocking=""
export jail_bacula151_zfs_datasets=""
export jail_bacula151_cpuset=""
export jail_bacula151_fib=""
export jail_bacula151_parentzfs="system/usr/local/jails"
export jail_bacula151_parameters=""
export jail_bacula151_post_start_script=""

ezjail fstab file

In this step, we alter the fstab file for this jail.

cd /etc
mv -i fstab.bacula101 fstab.bacula151

Here is the before and after of that file:

/usr/local/jails/basejail /usr/local/jails/bacula101/basejail nullfs ro 0 0

And after:

/usr/local/jails/basejail /usr/local/jails/bacula151/basejail nullfs ro 0 0

rename the ZFS file system

zfs rename system/usr/local/jails/bacula101 system/usr/local/jails/bacula151

change the ZFS file system mount point

zfs set mountpoint=/usr/local/jails/bacula151 system/usr/local/jails/bacula151

Notice that we are referring to the new file system name here, not the old one.

start the jail

Everything should just work:

/usr/local/etc/rc.d/ezjail start bacula151

If it doesn’t, check the logs:

less /usr/local/jails/bacula151/var/log/messages

Hope that helps.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

  One Response to “ezjail – renaming, moving, and renumbering”

  1. Perfect, thanks for this. Been looking to do the same.