Admin... by accident!

You may have chosen to be an admin. I didn't!

  • Home
  • FreeBSD
  • GNU/Linux
  • Security
  • Network
  • Virtualization
  • Politics
  • Github
  • Donate
  • Me

How to import iocage jails to Bastille on FreeBSD 13

June 3, 2023 by Albert Valbuena

Being a fan and heavy user of FreeBSD jails, I’ve been using iocage for years now. However, iocage is not the only tool capable of making abstractions on top of the jail infrastructure in FreeBSD to make it easier to manage in a not just easier way, but quicker, centralized manner. Bastille is the other tool of choice for many FreeBSD users and it is also capable to import iocage jails to Bastille. This is a quick guide on how to do just that.

If you find the articles in Adminbyaccident.com useful to you, please consider making a donation.

Use this link to get $200 credit at DigitalOcean and support Adminbyaccident.com costs.

Get $100 credit for free at Vultr using this link and support Adminbyaccident.com costs.

Mind Vultr supports FreeBSD on their VPS offer.

Requirements:

  • A system with iocage installed on it. More of that in this article.
  • A system with bastille installed on it. More on that in this other article.
  • Some command line administration knowledge.
  • Patience.

Synopsis.

In this article I will describe the process of importing an already existing jail constructed using iocage. It assumes the reader has some FreeBSD knowledge and some iocage knowledge too.

The process can be described as exporting the jail from an iocage equipped system, copy it into the same system but into bastille’s structure or to a system equipped with bastille only. Then, the jail can be imported by bastille to later be finally configured manually if needed (e.g. network device config).

Step 0. Export the jail from the iocage system.

The first thing we need to do to import iocage jails to Bastille is extracting the jail out of the iocage running system. To accomplish that we need to stop the jail running and then export it. This can take from just a few minutes to a long hour or more depending on how much space is that jail taking on disc. Act accordingly.

To stop the jail, issue this next command:

$ sudo iocage stop <JAILNAME>

Once the jail is stopped, we can start exporting it.

$ sudo iocage export <JAILNAME>

This export action will create a .zip file inside the /zroot/iocage/images/ directory.

$ ls -al /zroot/iocage/images/

As the output, we should see the .zip file from the previous export.

Now, we can use this same zip file to be imported by bastille. We can either choose to use the same system with both tools installed (iocage and bastille), or one on each system and copy them via zfs send or ssh.

Step 1.- Import the jail to bastille.

This is the main point in this how to import iocage jails to Bastille on FreeBSD. Bastille, as iocage, has an export but also an import option. The only thing here is we need to place the .zip file from iocage to a specific location in the directory structure. Then we will import it using bastille.

As it can be seen below, we’ve pulled an image, a .zip file, from an already existing iocage system.

To place the .zip file we can either copy the file, or even better, move it from the current location to its destination.

As it can be seen the file has been moved into the backups folder in bastille. The ownership has also been slightly altered, so root is now the owner and not my username.

Now, let’s tackle the import, finally. We will issue this next command.

$ sudo bastille import /usr/local/bastille/backups/filename.zip

Ideally, as you can see in this terminal capture, we should have not only imported the .zip file from the iocage export, but the checksum iocage produces to provide an integrity check over the .zip file. If we, for whatever the reason haven’t imported that checksum file along the original compressed exported jail file, with option -f we can import the jail anyways.

To confirm the jail has been imported we can issue the list subcommand for bastille.

We are not finished yet. The jail was configured on a different system, with different networking settings. We need to make adjustments to that before starting up the recently imported jail.

Step 3.- Adjust the jail configuration.

This is another, very important step, in this how to import iocage jails to Bastille guide. The jail.conf file for the cloudflare named jail contains the network settings used in the previous system.

/usr/local/bastille/jails/cloudflare/jail.conf

This needs to be adjusted and reconfigured to adapt it into the receiver one.

As it can be seen in the image above, in the top half of the terminal capture we can see the network configuration inside the jail.conf file for the cloudflare jail. However, the current system’s network interface and address are quite different. The network configuration now has to be modified and match the receiving system.

This is how the jail.conf file corresponding to the cloudflare jail looks now.

Now that we have exported the jail from the iocage system, imported into bastille, and adjusted the configuration bits necessary to work on the new host, we can fire up the jail.

Step 4.- Start up the jail in bastille.

The easiest step in this how to import iocage jails to bastille on FreeBSD guide. To start up the jail in bastille we only need to issue this command.

$ sudo bastille start <JAILNAME>

And there it is listed, up and running.

You can now start using the jail as intended. Test routing, dns resolution, etc to make sure everything has been correctly done, but you surely should be able to use this iocage constructed jail in bastille.

Conclusion

Bastille is quite similar in terms of use and name conventions for subcommands to iocage. However, they have been constructed very differently. Iocage was built around the python programming language, whereas bastille has been built using plain shell scripts. Since the underlayer technology both are leveraging is FreeBSD Jails, the end result is quite similar.

I hope this helps anyone willing to use both tools interchangeably and use old iocage jails in Bastille without a hassle.

Thanks for reading this how to import iocage jails to Bastille on FreeBSD 13 guide.

If you find the articles in Adminbyaccident.com useful to you, please consider making a donation.

Use this link to get $200 credit at DigitalOcean and support Adminbyaccident.com costs.

Get $100 credit for free at Vultr using this link and support Adminbyaccident.com costs.

Mind Vultr supports FreeBSD on their VPS offer.

 

 

Filed Under: FreeBSD, How To's

Recent Posts

  • How to install Redis for WordPress on FreeBSD
  • How to compile cloudflared in FreeBSD 13/14
  • How to configure FreeBSD to use a webcam (version 12 and 13)
  • Symbolic and Hard Links in UNIX and Linux
  • How to import iocage jails to Bastille on FreeBSD 13
  • How to load and unload kernel modules in Linux
  • How to use find in GNU/Linux and FreeBSD
  • How to install Mate on FreeBSD 12/13
  • How to install Nessus 10 on FreeBSD 12
  • How to enable TLS traffic from the origin server on Cloudflare Argo Tunnel
  • How to use Cloudflare’s Argo Tunnel service to publish a website on FreeBSD 12/13
  • How to setup MariaDB master-slave replication on FreeBSD
  • How to upload a FreeBSD custom image on DigitalOcean
  • How to install Drupal 9 on FreeBSD 13.0
  • How to manage site visitors based on IP Geolocation
  • How to enable Geolocation in AWStats on FreeBSD 13.0
  • How to install AWStats on FreeBSD 13.0
  • How to configure Modsecurity 3 for WordPress on FreeBSD
  • How to configure Apache HTTP with a TLS reverse proxy backend on FreeBSD
  • How to detect a WAF – Web Application Firewall

Archives

  • November 2024
  • October 2024
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • April 2022
  • March 2022
  • October 2021
  • September 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • September 2018
  • June 2018
  • May 2018
  • April 2018
  • February 2018
  • January 2018
  • November 2017
  • April 2017

RSS Admin… by accident!

  • How to install Redis for WordPress on FreeBSD
  • How to compile cloudflared in FreeBSD 13/14
  • How to configure FreeBSD to use a webcam (version 12 and 13)
  • Symbolic and Hard Links in UNIX and Linux
  • How to import iocage jails to Bastille on FreeBSD 13
  • How to load and unload kernel modules in Linux
  • How to use find in GNU/Linux and FreeBSD
  • How to install Mate on FreeBSD 12/13
  • How to install Nessus 10 on FreeBSD 12
  • How to enable TLS traffic from the origin server on Cloudflare Argo Tunnel

Copyright © 2025 · Magazine Pro Theme on Genesis Framework · WordPress · Log in