What is the recommended way to clone a jail?

Status
Not open for further replies.

pvuchetich

Dabbler
Joined
Aug 23, 2012
Messages
17
Within FreeNAS, what is the preferred way to make a clone of a jail for modification and reuse as a new jail?

I've created a jail that I'd like to clone, then modify as a new jail. As a test case, I'll clone a minecraft server (to make a similar server with different application settings), so there is really little within the jail that is unique. All that are probably needed are a new LAN IP address and new minecraft server.properties file.

I've seen that there are tools, such as ezjail, that can handle jail management tasks, in addition to manually using ZFS for cloning and jail tools from the FreeBSD manual, but I wasn't sure what the preferred option is today within FreeNAS, using version 9.2.1.x.

The built in GUI tools were very great for creating the initial jail, but there didn't seem to be an easy way within the GUI to clone a jail. In this case, it isn't a big deal to manually build a new jail, but I would like to use this as an example for when I need to work with a jail running a service that has more complexity.
 

pvuchetich

Dabbler
Joined
Aug 23, 2012
Messages
17
Thanks Dru,
I've submitted feature request #5074 on the FreeNAS bug forum. https://bugs.freenas.org/issues/5074
I've put more detail in that about what I think the functionality would be, as well as use cases for home and business.
I was aware of Warden in PC-BSD, but I didn't realize it was also implemented in FreeNAS, so I'll try that out and report the outcome on this thread.
 

pvuchetich

Dabbler
Joined
Aug 23, 2012
Messages
17
Thanks - Warden was an effective method to cloning a jail:

Here are the steps I used for cloning a minecraft jail:

I set up a Minecraft Jail using the instructions here:
http://forums.freenas.org/index.php?threads/how-to-install-minecraft-server-in-a-jail.18246/

Just to ensure that not stopping the jail would be handled cleanly, I left the original jail running.
Login to FreeNAS server, working in the jails directory:

%su root
#warden list
ID AUTOSTART STATUS TYPE
---------------------------------------------------------------------------
minecraft-creative Enabled Running portjail

# warden export minecraft-creative
Stoppingthejail....Unmounting user-supplied file-systems
umount: fstab reading failure
Stopping jail with: /etc/rc.shutdown
...DoneCreating compressed archive of minecraft-creative... Please Wait...

This step created a minecraft-creative.wdn file, which was approximately 480 MB. in the /mnt/[pool]/jails file system, where [pool] is the name of my ZFS pool.

# warden import minecraft-creative.wdn --ipv4=10.10.10.81/255.255.255.0 --host=minecraft-survival
# warden list
ID AUTOSTART STATUS TYPE
---------------------------------------------------------------------------
minecraft-creative Enabled Running portjail
minecraft-survival Enabled Running standard
After editing the minecraft "server.properties" file, then starting the jail, the new minecraft server was operational on the LAN.
Since it copied the previous server files after the server had been running, there is some minecraft-specific cleanup that is appropriate before using the new jail (all of the instance-specific files should be in the /srv/minecraft directory per the referenced instructions). In general, application-specific cleanup would be dependent on how any given application manages its working data.
Initial impression: Positives about this method:
1. It creates a base jail (*.wdn file) that can be used to create any number of clones in the future.
2. It takes 2 commands (warden export...warden import)
3. It creates a file, which could be shared between servers
Initial impression: Negatives about this method:
1. It creates a file; may be more graceful to use ZFS snapshot (depending on the purpose another file may be positive or negative)
2. It requires stopping the jail (automatic as part of export step), although this is best practice when backing up an unknown server.
3. The warden export command takes awhile (it looks like it runs bsdtar on the jail file system, and maxes out one CPU thread for awhile on a low end server).
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
While that works, I'd technically label it as a "hack". You are doing things behind the back of the FreeNAS WebGUI, and that can cause unforeseen problems now or in the future. And when the WebGUI gets upset it sometimes pulls out the paddle with the rusty nail and spanks you with it. So its not something I'd recommend or ever endorse.

There is a ticket in the system to add a feature like this, but I'm not sure what the status of it is.
 

pvuchetich

Dabbler
Joined
Aug 23, 2012
Messages
17
I agree that this initial workaround is a hack (which is why I asked the question, and why I am trying it on a non-critical application), with the end goal of an elegant solution that can be incorporated into the FreeNAS GUI.
FreeNAS Feature #5074 was just submitted for a GUI-integrated solution, and is being evaluated for potential inclusion in the 9.2.2 release. That said, I think the best option for me is to see what I can do to support efforts on that new feature rather than tinker with various jail cloning methods.
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I would like to ask if there is any new guidance on this topic? I have built a new server and I want to migrate my existing jails to the new system.
They are both running the latest 9.10.1 release and both systems have the jail on a separate vdev from the storage.
I have done some reading on this, but I don't want to jump without asking because I don't want to risk loosing what I have built.
I have a Plex server in one jail and the other jail is a VirtualBox headless that contains 4 Linux VMs.
I could build it again, but I thought the reason that jails exist is to make it relatively easy to move to new hardware.
 
Joined
Dec 12, 2015
Messages
3
It looks like there may not be any additional information though. I had an idea. Maybe using a snapshot method as at least a backup in case you screw something up? What do you all think?
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I tried several methods of copying the jail over to the new server and although it did copy, I was not able to get it working properly on the new server.
As I wanted to get the old server decommissioned and complete the upgrade, I simply rebuilt what I needed in new jails on the new hardware platform. It was not horribly difficult, just time consuming and repetitive because I had done it all before on the previous server. I am sure there should be a better way, I just couldn't find it.
 
Status
Not open for further replies.
Top