Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

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

seedz

Member
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

Member
Joined
Feb 24, 2017
Messages
44
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

Member
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

Member
Joined
Sep 24, 2014
Messages
43
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

Newbie
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

Newbie
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

Newbie
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

Member
Joined
Aug 22, 2017
Messages
161
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

Senior Member
Joined
Aug 19, 2013
Messages
305
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

Member
Joined
May 17, 2018
Messages
220
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

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

IMreymundo

Newbie
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??
 
Top