How to move jails between pools?

dtom10

Explorer
Joined
Oct 16, 2014
Messages
81
Hello all,

I'm still working out how to move stuff in Freenas. I've been doing some cleanup and re-organizing. Moving stuff from two old servers into a new bigger one as well as upgrading to Freenas 11.2 which introduces a lot of changes.

One problem I have after re-creating old warden jails into new iocage ones is that I need to move them from one zpool to another. Is there a safe way to do that or just moving the /mnt/zpool/iocage dir is enough?

I don't want to re-create my only two jails, for now, just to have them off a pool that I plan to decommission.

Any help is appreciated!
 

tprelog

Patron
Joined
Mar 2, 2016
Messages
297
It may be possible just to zfs send | receive the iocage (and all child) datasets to the new zpool. Then simply iocage activate zpool_name. The tricky part would be the mount point for the iocage dataset. I think you can only have one zpool "activated" at a time for iocage and FreeNAS expects the dataset to be mounted at /mnt/iocage/. You may be able to just switch mount points around, if you prefer to have your old iocage dataset intact until the new location is running. I'm sure there's an easy and proper way to handle like this but I'm not sure what the exact steps would be.

I did successfully move jails between zpools but I was replacing drives (I had to take current drives out before I added the new drives) so, I exported --> imported my jails.

All the same here's the extra steps I took.

You'll need to stop the jails before they be exported:
iocage stop jail_name

Exporting jails will create a zip file `jail_name_date.zip` inside `/mnt/iocage/images/` :
iocage export jail_name

At this point I copied all exported jails to a safe place in a different zpool. The next command basically resets iocage. This will destroy all iocage data that has been created. Again make sure have backed-up your exported jails outside the iocage dataset before running this command
iocage clean -a

Next I reactivated iocage on it's new zpool. This creates the iocage dataset as well a sub-directories and child datasets
iocage activate new_zpool_name

You can also pre-fetch any releases at this point as well. If you don't do this now it will happen automatically next time you install a plugin or jail
iocage fetch 11.2-RELEASE

Finally copied by exported jails back into `/mnt/iocage/images/`, then restored them.
iocage import jail_name_date.zip

A few things I learned while doing this.
- You should let iocage activate create the dataset for you. This will correctly set the mount point to /mnt/iocage/
- If you create the iocage dataset manually or if it already exist then the mount point will be incorrect /mnt/zpool_name/iocage/. In this case you will need to manually change the mount point to be correct
- If you export a plugin -- It will be a jail when you import it again. (Nice trick to convert a plugin to a standard jail)
 

dtom10

Explorer
Joined
Oct 16, 2014
Messages
81
Thanks for the detailed explanation. I've done it the berrypicker way and seems to work. Created scaffold jails in the destination zpool then rsynced the /mnt/srczpool/iocage to /mnt/dstzpool/iocage.

So far so good. I still don't get why people insist on freebsd. It's not like I'm going to learn yet another wheel with different rims. Maybe I'm just a computer chad.
 

jdabb

Dabbler
Joined
Aug 4, 2019
Messages
42
i am trying to move my jails using this thread
https://www.ixsystems.com/community/threads/relocate-jails-to-ssd-helping-hdd-sleep.16955/

I successfully copied everything over but none of my jails seems to be working when I access them though the jail IP
this is what I did

i made sure I cd /mnt/ first
  1. Turn off all plugins (Plugins->Installed)
  2. Stop all jails (Jails->View Jails)
  3. Run these commands via CLI
  4. zfs snapshot -r Dexter/iocage@relocate
    zfs send -R Dexter/iocage@relocate | zfs receive -v ssd_pool/iocage
    zfs get -rH -o name -s received mountpoint ssd_pool/iocage | xargs -I {} sh -c "zfs set mountpoint=/{} {}; zfs mount {};"[/PANEL]
  5. Change the Jail Root to /mnt/ssd_pool (Jails->Configuration)
  6. Start jails/plugins
  7. Check that everything works and destroy the original jails dataset
my dataset looks correct

i can see in ssdpool/iocage/ > (jail stuff and other folders)

can anyone help me out.

i feel like the mount point is wrong as mentioned above by another poster but I am not sure how to I set the mount point

"- If you create the iocage dataset manually or if it already exist then the mount point will be incorrect /mnt/zpool_name/iocage/. In this case you will need to manually change the mount point to be correct "

Also, if I redid the copying of the jails and followed the above steps posted in this thread is there a way to export all jails or would I have to do it one by one?
 

tprelog

Patron
Joined
Mar 2, 2016
Messages
297
I think the mount point should be
Code:
/mnt/iocage/
 

jdabb

Dabbler
Joined
Aug 4, 2019
Messages
42
I thought I had the old setup as /mnt/Dexter/iocage and it was working fine the new copy I believe is now /mnt/ssd_pool/iocage but I will have to check to confirm both when I get home. so changing the mount point is as simple as moving it to /mnt/ ? or would I need to do this though a command.
 

tprelog

Patron
Joined
Mar 2, 2016
Messages
297
I had my iocage data set mounted inside another data set for a time as well. I think iocage works just fine but if I remember correctly it is FreeNAS that expects your jails to be at /mnt/iocage/.

I think to change the mount point you can use zfs set mountpoint but please confirm before you try that. I am just trying to remember off the top of my head so I'm not 100% positive. I am fairly certain it is zfs command though. I do not believe you should have to physically move any data sets around
 

tprelog

Patron
Joined
Mar 2, 2016
Messages
297
I was thinking also, when you listed your steps above you did not mention anywhere using the iocage activate command for your new jail data set. I am wondering if that may be the step you have missed rather than needing to change a mount point. Thinking about the mount point a little more I do recall it was specifically the FreeNAS GUI that wanted /mnt/iocage. I switched over to iocage while the new GUI was still in beta. At that time iocage required the command line to use but it did work if it was mounted inside another data set. As mentioned it was the FreeNAS GUI that had issues.
 

jdabb

Dabbler
Joined
Aug 4, 2019
Messages
42
isn't iocage activate zpool_name the same as click on the activate in the config setting for the pool after selecting the pool? if so i did do this I give it a try shouldn't hurt
 

tprelog

Patron
Joined
Mar 2, 2016
Messages
297
Yes it is the same thing. I have done this personally with jails in place and it has not hurt anything but I cannot say with 100% certainty that it is guaranteed to be safe. It may be wise if you can create a backup first, just in case.
 

bigdadda06

Dabbler
Joined
Aug 23, 2018
Messages
14
FYI
I was playing around with this process, to test the backup/restore process.
First I backed up the a jail on one server
I then copied that jail to another server, onto a pool with a different name.
I then used the web interface to create a test jail, to make sure it was all setup how it should be.
Then I imported my jail backup.
All that went OK, so then I attempted to start the jail.
But it wouldn't start, it kept complaining about not being able to see the mount point and referenced the old pool name.

I tried a few things, but ended up doing a search and replace within the fstab file in the /<pool>/iocage/jails/<jailname>
to replace the old pool name with the new one.
e.g. from /mnt/orginal-pool/iocage/jails/wwwhost to /mnt/new-pool/iocage/jails/wwwhost

then it started OK.
 

Slovak

Explorer
Joined
Sep 10, 2013
Messages
62
search and replace within the fstab file in the /<pool>/iocage/jails/<jailname>
to replace the old pool name with the new one.
e.g. from /mnt/orginal-pool/iocage/jails/wwwhost to /mnt/new-pool/iocage/jails/wwwhost

Same thing here. Created snapshot, zfs send | zfs receive, changed the "Choose Pool for Plugin and Jail Storage" in GUI to the new pool, and then edited /mnt/new-pool/iocage/jails/jail-name/fstab replacing old-pool with new-pool - except where mount points are still located on old-pool. All jails started with out an issue.
 

Bikerchris

Patron
Joined
Mar 22, 2020
Messages
210
I tried a few things, but ended up doing a search and replace within the fstab file in the /<pool>/iocage/jails/<jailname>
to replace the old pool name with the new one.
e.g. from /mnt/orginal-pool/iocage/jails/wwwhost to /mnt/new-pool/iocage/jails/wwwhost

then it started OK.
Thanks for the fstab hint, changing that to the new jail location worked perfectly for me. :cool:
 

Berkyjay

Contributor
Joined
Nov 7, 2015
Messages
100
Help!

I've followed the steps above, but when I go to import my backup zip file it gives me a "file not found" error.

Code:
root@freenas:/ # iocage import plex-plexpass_2020-09-08.zip
plex-plexpass_2020-09-08.zip not found!
root@freenas:/ # iocage import /mnt/Media2/iocage/images/plex-plexpass_2020-09-08.zip
/mnt/Media2/iocage/images/plex-plexpass_2020-09-08.zip not found!
root@freenas:/ # iocage import /mnt/Media2/iocage/images/plex-plexpass_2020-09-08.zip
/mnt/Media2/iocage/images/plex-plexpass_2020-09-08.zip not found!
root@freenas:/ # iocage import plex-plexpass_2020-09-08.zip
plex-plexpass_2020-09-08.zip not found!
root@freenas:/ # cd /mnt/Media2/iocage/images/
root@freenas:/mnt/Media2/iocage/images # ls
plex-plexpass_2020-09-08.zip
root@freenas:/mnt/Media2/iocage/images # iocage import plex-plexpass_2020-09-08.zip
plex-plexpass_2020-09-08.zip not found!
root@freenas:/mnt/Media2/iocage/images #


Am I missing a step here?
 
Joined
Jul 10, 2016
Messages
521
Do not specify the zip extension, i.e. execute iocage import plex-plexpass_2020-09-08
 

Berkyjay

Contributor
Joined
Nov 7, 2015
Messages
100
@Jurgen Segaert I have a question about importing. How long does this process usually take. I set it off close to an hour ago and it's still running. I also am not able to access my server via the web gui which has me worried.

EDIT:

I noticed that my zip file is 21GB. Will that large a file cause issues with the import?

EDIT 2:

Now it seemed to error out:

Code:
root@freenas:~ # iocage import plex-plexpass_2020-09-08
Importing dataset: plex-plexpass
Importing dataset: plex-plexpass/root
cannot receive: failed to read from stream
Killed
 
Last edited:
Joined
Jul 10, 2016
Messages
521
I exported my own plexmediaserver jail as a test, and the zipfile was 1.1 GB. Note that I store my media and metadata outside of the jail on the main pool.

The export and import takes less than a minute.

If you have media files and/or metadata stored within your jail, they may all be part of the zipfile, and that may explain the much larger size. If that's the case, you may want to use your pool migration exercise as an opportunity to separate the plex-application from the plex-data to make upgrades and migrations easier in the future.

This is a great reference: https://www.ixsystems.com/community/threads/scripted-plex-installation.79725/
 

Berkyjay

Contributor
Joined
Nov 7, 2015
Messages
100
I exported my own plexmediaserver jail as a test, and the zipfile was 1.1 GB. Note that I store my media and metadata outside of the jail on the main pool.

The export and import takes less than a minute.

If you have media files and/or metadata stored within your jail, they may all be part of the zipfile, and that may explain the much larger size. If that's the case, you may want to use your pool migration exercise as an opportunity to separate the plex-application from the plex-data to make upgrades and migrations easier in the future.

This is a great reference: https://www.ixsystems.com/community/threads/scripted-plex-installation.79725/

Well, the good news is I did backup my "Plex Media Server" directory so my data was't lost. So thanks for the link. Hopefully it will help me restore my Plex server without any lost DB data.
 
Top