[11.2] Migrating the iocage dataset to an other pool ?

seedz

Dabbler
Joined
May 2, 2018
Messages
39
Just to say I had to do the procedure again, as I changed SSDs for the jails + VMs

procedure worked fine on 11.2 release U1
the iocage fstab part was a bit tedious, but with some replace spam i got it working fast

tip : the only thing to do is, after changing your editor to nano,
do a search & replace for "/mnt/OldPathToIocage" with "/mnt/NewPathToIocage", then change all
for me, as i changed from an iocage pool located on a storage named IOCAGE to a storage called VM, it ended up as :
replacing "/mnt/IOCAGE" with "/mnt/VM"
I'm sure i could have used a script for this, but I was too lazy to come up with one as I had only 5 jails needing mounting points renaming
 

amlamarra

Explorer
Joined
Feb 24, 2017
Messages
51
So what's the consensus? Do the original instructions provided by Jurgen work?

Code:
iocage stop ALL
zfs unmount -f tank/iocage
zfs snapshot -r tank/iocage@migration
zfs send -R tank/iocage@migration | zfs receive -v dozer/iocage
iocage clean -a
zfs destroy -f tank/iocage
iocage activate dozer
zfs destroy -r dozer/iocage@migration
 

seedz

Dabbler
Joined
May 2, 2018
Messages
39
So what's the consensus? Do the original instructions provided by Jurgen work?

Code:
iocage stop ALL
zfs unmount -f tank/iocage
zfs snapshot -r tank/iocage@migration
zfs send -R tank/iocage@migration | zfs receive -v dozer/iocage
iocage clean -a
zfs destroy -f tank/iocage
iocage activate dozer
zfs destroy -r dozer/iocage@migration

Yep, they work fine.

You just have to modify your mount points if you used those
(can be mounting some part of your pools into jails, as well as the special mount points like the nullfs thingies in some of the plugins)
to do this, you can :
set nano as your editor
Code:
EDITOR=/usr/local/bin/nano; export EDITOR

then edit the fstab of your jails
Code:
iocage fstab -e yourjail
 

treboR2Robert

Dabbler
Joined
Sep 24, 2014
Messages
46
Thank you very much @seedz and everyone else who contributed

This thread saved my bacon :)

Love how you edited the 1st post and explained everything very well, i wish other people would do the same.

Thanks again !
 

equalunique

Cadet
Joined
Jul 22, 2019
Messages
2
Not really sure how to do is on this site, but this would be a good addition to the Jails & Plugins "Resources" section.
 

turanga

Cadet
Joined
Dec 12, 2019
Messages
1
This also worked great for me, but like 4xTroy I also had to use "zfs destroy -rf" on the old iocage. I think the guide should be revised so that:

zfs destroy -f tank/iocage

would actually be:

zfs destroy -rf tank/iocage

Thanks to seedz for the help here. It saved me a bunch of time and effort.
 

pappabees

Cadet
Joined
Dec 14, 2020
Messages
3
Hi !

At first this was a question, now this is how you should do it :
(less scrolling for new people, thanks to everyone who participated)

First, you migrate your pools like this :
Code:
iocage stop ALL
zfs unmount -f tank/iocage
zfs snapshot -r tank/iocage@migration
zfs send -R tank/iocage@migration | zfs receive -v dozer/iocage
iocage clean -a
zfs destroy -f tank/iocage
iocage activate dozer
zfs destroy -r dozer/iocage@migration

here, you should use your own pool names.
the old pool is named tank, the new one dozer

Then, you could need to edit your jail mount points.
To do this, you have to :
set nano as your editor (optional if you know how to search and replace with vi)
Code:
EDITOR=/usr/local/bin/nano; export EDITOR

then edit the fstab of your jails
Code:
iocage fstab -e yourjail

then do search and replace all with nano, searching with your old mountpoint /mnt/tank/iocage with /mnt/dozer/iocage

Tested on 11.2U1


(old post contents)
I have lots of jails set up for my uses that i'd like to transfer to a newly bought SSD from my HDD pool.
I've found several posts talking about changing the iocage dataset location doing a reset, but :
nowhere i read touches upon how to effectively transfer an active jail dataset without having to remake every one of them.

What i already did :
- copy the whole dataset to a save folder
- prepared the new pool

So, my questions are :
- is there an other way than doing an "iocage clean -a" / "iocage reset" / "iocage activate MYPOOL" to move the dataset ?
- doing that, what's the right way to go to not loose everything ?

I'm running FreeNAS-11.2-BETA3


so I just tried this and I can't do the iocage clean -a because it is no longer mounted. is there something missing here?
 

ere109

Contributor
Joined
Aug 22, 2017
Messages
190
I performed this, between yesterday and today. A few notes to share:
You have to be logged in as root. Logging in as myself and using sudo failed - permissions must not have been elevated enough.
The previous iocage failed to delete, may be resolved by turanga's post above (though I just deleted it in GUI).
Code:
EDITOR=/usr/local/bin/nano; export EDITOR

was ambiguous and did nothing, until I found THIS POST. In the end, I just navigated to each jail folder and manually ran nano fstab.

so I just tried this and I can't do the iocage clean -a because it is no longer mounted. is there something missing here?

I had the same problem, so it may be an issue with 11.3?

Thank you to @seedz. Awesome work, and is definitely still helping people.
 

RegularJoe

Patron
Joined
Aug 19, 2013
Messages
330
Then, you could need to edit your jail mount points.
To do this, you have to :
set nano as your editor (optional if you know how to search and replace with vi)
Code:
EDITOR=/usr/local/bin/nano; export EDITOR

then edit the fstab of your jails
Code:
iocage fstab -e yourjail

then do search and replace all with nano, searching with your old mountpoint /mnt/tank/iocage with /mnt/dozer/iocage

to find all your jail configs that reference your old mount point you would go into your iocage folder and do a
Code:
grep -Ir "/mnt/tank/iocage" *


Once that is done you can use the UNIX command "sed" to search and replace the old location with the new location. I am doing this now on my setup as I am moving my iocage to a NVME disk. I wish we had the option in the GUI to do this and fix all the paths. I am running TrueNAS Core 12.0-U2

I will post my grep/sed commands after my move.
 

rmccullough

Patron
Joined
May 17, 2018
Messages
269
I didn't follow the instructions exactly, but I think I may have a slightly different setup.


I did not execute the 2 zfs destroy commands.


However, my iocage does not seem to reside at /mnt/tank/iocage. Instead, mine seems to show up at /mnt/iocage.


Also, now I have iocage listed in both of my pools, and it almost appears as if they are somehow linked. I tried to run the zfs destroy -f tank/iocage after completing everything and it was getting stuck saying:

Code:
root@freenas[/mnt]# zfs destroy -f tank/iocage

cannot destroy 'tank/iocage': filesystem has children

use '-r' to destroy the following datasets:

...



So I added the -r flag and tried again with this result:

Code:
root@freenas[/mnt]# zfs destroy -rf tank/iocage

cannot destroy 'tank/iocage/jails/organizr': dataset is busy



Very odd. So I went and looked at the jail and it said organizr was corrupt. I deleted the jail and the volume from my tank pool and it disappeared from my dozer pool.

I feel like I am all messed up here. My jails show that it is using the dozer pool, but I don't really trust that now.

How can I figure this out and free up the space on my tank pool? I would really like to take advantage of the faster performance of the mirrored NVMe drives I just added.
 

no1jam

Cadet
Joined
Feb 22, 2021
Messages
6
+watching this thread, I have a feeling it may come it handy!
 

IMreymundo

Cadet
Joined
Dec 21, 2020
Messages
2
So I got to "iocage activate tank" and I get the error "ZFS dataset "tank/iocage" is locked". What do I do to fix this??
 

OliverPA

Cadet
Joined
Feb 29, 2016
Messages
3
While I do have backups of the jails I didn't like the order in the first post where iocage clean and zfs destroy are used to remove the old iocage dataset before the new one is proven to work.
Instead I used the order below and it all worked well. I figured once iocage activate points to dozer the old iocage dataset is just a dataset and I shouldn't need iocage to clean it up but zfs destroy should be enough once I'm ready for it. And if it were to complain about deleting the old iocage dataset then this should indicate that something is erroneously pointing to the old one that should be pointing to the new.

There were no issues with locking, etc. The fstab editing part was tricky because lots of mount points were used and I didn't trust a simple search&replace. As a benefit of the effort I found a few mount points that weren't necessary anymore :smile:

Code:
iocage stop ALL
zfs unmount -f tank/iocage
zfs snapshot -r tank/iocage@migration
zfs send -R tank/iocage@migration | zfs receive -v dozer/iocage
iocage activate dozer
iocage fstab -e jailname... for each jail
reboot
iocage start jailname... for each jail & verify it's working as before
zfs destroy -r dozer/iocage@migration
zfs destroy -f tank/iocage
 

akeetley

Cadet
Joined
Jun 27, 2021
Messages
2
This post worked successfully for me up until the very end. Running TrueNas12.0U4, i did 4 jails, and they all started with working mountpoints etc. However it appears that user permissions are such that I can't access a console from inside the Truenas interface

Accessing the Shell Via the TrueNas Jail Menu Interface produces an error of:

Command: login -p -f root failed!
Console failed!
The cause could be bad permissions for /mnt/#Pool/iocage/jails/#jail

Console, SSH, and Jexec from the main shell all produce failure or error, but this particular jail is a Plex Server and it's still working fine except for an inability to add or remove data from the library. Definitely something happened with the users when i moved it from one pool to another.

What am I missing?
 

akeetley

Cadet
Joined
Jun 27, 2021
Messages
2
This post worked successfully for me up until the very end. Running TrueNas12.0U4, i did 4 jails, and they all started with working mountpoints etc. However it appears that user permissions are such that I can't access a console from inside the Truenas interface

Accessing the Shell Via the TrueNas Jail Menu Interface produces an error of:

Command: login -p -f root failed!
Console failed!
The cause could be bad permissions for /mnt/#Pool/iocage/jails/#jail

Console, SSH, and Jexec from the main shell all produce failure or error, but this particular jail is a Plex Server and it's still working fine except for an inability to add or remove data from the library. Definitely something happened with the users when i moved it from one pool to another.

What am I missing?
The solution appears to be DO NOT PUT THE POOL IN A FOLDER THAT HAS ITS OWNERSHIP CHANGED VIA SCRIPT EVERY 30 min. Ooops!
 

ahoggie

Cadet
Joined
Apr 10, 2023
Messages
1
The solution appears to be DO NOT PUT THE POOL IN A FOLDER THAT HAS ITS OWNERSHIP CHANGED VIA SCRIPT EVERY 30 min. Ooops!
I've made a similar mistake - what was your fix? Really don't want to give up on my jail
 
Top