December 12, 2018

How to Rename a Jail Using ezjail on FreeBSD

FreeBSD Logo

This tutorial covers the steps to rename a jail using ezjail on FreeBSD. Instead of deleting and creating a new jail, you can rename an existing jail. This can safe you some time. If you do not use ezjail you can probably adjust the steps that it will work with your jail administration framework.

Root access is required to edit the following files and to execute commands. Log in as root (su) or simply prepend sudo to all commands that require root privileges.

Remove the old jail without deleting the files

Stop the old jail:

ezjail stop

Remove the jail from ezjail’s configuration:

ezjail-admin delete

Now the jail is no longer running but the files are still present on disk.
Check this with the ls command:

ls /usr/jails/

Note: Make sure to update your DNS as well.

Create the new jail

First we rename the directory of the old jail. This is not needed but the convention dictates that the jail directory name should reflect the hostname for that jail. At the end we will create the new jail. Navigate to the jails directory:

cd /usr/jails/

Rename the old jail directory:


Create the new jail:

ezjail-admin create -x

Start the new jail

Start the new jail with:

ezjail start

SSH to the renamed jail and check the hostname:

ssh -A new

Speak Your Mind