Project

General

Profile

Support #508

Migrating FreeNAS Jails

Added by Daniel Curtis over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Jails / Containers
Target version:
Start date:
12/21/2014
Due date:
% Done:

100%

Estimated time:
3.00 h
Spent time:

Description

I have been using FreeNAS in my production environment for a few years and one of the many useful features are the Jails. Along the way I added more drives and in more advanced configurations, like RAID1 and RAIDZ1. Unfortunately there are no helper scripts to assist in migrating jails from one location to another; depending on whether UFS or ZFS is used and whether the destination is local or remote will determine the methods available for migration.

UFS to UFS Jail Migration

This migration method uses the tried-and-true rsync tool.

Local to local

In this example I will be migrating the jails from /mnt/default to /mnt/jails.

  1. Begin by logging into the FreeNAS web panel and going to the Jails sections and turning of all jails
  2. Next open a Shell in the FreeNAS web panel
  3. Migrate the files to the new location:
    rsync -avh -n /mnt/default /mnt/jails
    
    • NOTE: Remove the -n to remove the dry-run option
  4. Now go to the Jails section again, then the Configuration tab.
  5. Change the Jail root from /mnt/default to /mnt/jails
  6. Reboot the FreeNAS

Local to remote

In this example I will be migrating the jails from the local /mnt/default location to the /mnt/jails remote location. In order for this to work the local root user's public key must be copied over to the remote root users SSH Public key field, otherwise the transfer will likely fail.

  1. Begin by logging into the local FreeNAS web panel and going to the Jails sections and turning of all jails
  2. Next open a Shell in the FreeNAS web panel
  3. Migrate the files to the new location:
    rsync -avh -n /mnt/default -e ssh 192.168.0.2:/mnt/jails
    
    • NOTE: Remove the -n to remove the dry-run option
  4. Now go to the Jails section on the remote FreeNAS, then the Configuration tab.
  5. Change the Jail root to /mnt/jails
  6. Reboot the FreeNAS

UFS to ZFS Jail Migration

This migration method uses the rsync tool as well; however this method require a little more finesse since the entire jails folder cannot be transfered at once, but rather each jail individually migrated.

Local to local

In this example I will be migrating a single jail, node3, from /mnt/master to /mnt/jails.

  1. Begin by logging into the FreeNAS web panel and going to the Jails sections and turning of all jails
  2. Then go to the Storage section, select the jails zvol and then Create ZFS Dataset named node3
  3. Next open a Shell in the FreeNAS web panel
  4. Migrate the files to the new location:
    rsync -avh -n /mnt/master/node3/ /mnt/jails/node3/
    rsync -avh -n /mnt/master/.node3.meta /mnt/jails/
    
    • NOTE: Remove the -n to remove the dry-run option
    • NOTE: Make sure to copy over the .node3.meta or else FreeNAS will not see the jails metadata
  5. Now go to the Jails section again, then the Configuration tab.
  6. Change the Jail root from /mnt/master to /mnt/jails
  7. Reboot the FreeNAS

NOTE: Repeat for each individual jail

Local to remote

In this example I will be migrating a single jail, node3, from /mnt/master to /mnt/jails. In order for this to work the local root user's public key must be copied over to the remote root users SSH Public key field, otherwise the transfer will likely fail.

  1. Begin by logging into the local FreeNAS web panel and going to the Jails sections and turning of all jails
  2. Then go to the Storage section on the remote FreeNAS, select the jails zvol and then Create ZFS Dataset named node3
  3. Next open a Shell in the FreeNAS web panel
  4. Migrate the files to the new location:
    rsync -avh -n /mnt/master/node3/ -e ssh 192.168.0.2:/mnt/jails/node3/
    rsync -avh -n /mnt/master/.node3.meta -e ssh 192.168.0.2:/mnt/jails/
    
    • NOTE: Remove the -n to remove the dry-run option
    • NOTE: Make sure to copy over the .node3.meta or else FreeNAS will not see the jails metadata
  5. Now go to the Jails section on the remote FreeNAS, then the Configuration tab.
  6. Change the Jail root to /mnt/jails
  7. Reboot the FreeNAS

ZFS to ZFS Jail Migration

This method uses the built-in ZFS send/receive function.

Local to local

In this example I will be migrating jails from /mnt/shared to /mnt/jails.

  1. Begin by logging into the FreeNAS web panel and going to the Jails sections and turning of all jails
  2. Go to the Storage section and select the shared zvol, then Create Snapshot named migrate
  3. Next open a Shell in the FreeNAS web panel
  4. Migrate the files to the new location:
    zfs send shared@migrate | zfs receive jails
    
    • NOTE: Remove the -n to remove the dry-run option
  5. Now go to the Jails section again, then the Configuration tab.
  6. Change the Jail root from /mnt/shared to /mnt/jails
  7. Reboot the FreeNAS

Local to remote

In this example I will be migrating jails from /mnt/shared to /mnt/jails. In order for this to work the local root user's public key must be copied over to the remote root users SSH Public key field, otherwise the transfer will likely fail.

  1. Begin by logging into the local FreeNAS web panel and going to the Jails sections and turning of all jails
  2. Go to the Storage section and select the shared zvol, then Create Snapshot named migrate
  3. Next open a Shell in the FreeNAS web panel
  4. Migrate the files to the new location:
    zfs send shared@migrate | ssh -i /data/ssh/replication 192.168.0.2 zfs receive jails
    
    • NOTE: Remove the -n to remove the dry-run option
  5. Now go to the Jails section on the remote FreeNAS, then the Configuration tab.
  6. Change the Jail root to /mnt/jails
  7. Reboot the FreeNAS

Resources

History

#1 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)
  • Status changed from New to Resolved
  • % Done changed from 0 to 100

#2 Updated by Daniel Curtis over 5 years ago

  • Description updated (diff)

#3 Updated by Daniel Curtis over 5 years ago

  • Status changed from Resolved to Closed

#4 Updated by Daniel Curtis over 5 years ago

  • Target version set to 5

#5 Updated by Daniel Curtis over 5 years ago

  • Category set to Jails / Containers
  • Target version changed from 5 to FreeNAS 9.x

Also available in: Atom PDF