Project

General

Profile

Support #508

Updated by Daniel Curtis about 10 years ago

{{>toc}} 

 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. 

 h2. UFS to UFS Jail Migration 

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

 h3. Local to local 

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

 # Begin by logging into the FreeNAS web panel and going to the Jails sections and +turning of all jails+ 
 # Next open a *Shell* in the FreeNAS web panel 
 # Migrate the files to the new location: 
 <pre> 
 rsync -avh -n /mnt/default /mnt/jails 
 </pre> 
 #* NOTE: Remove the -n to remove the dry-run option 
 # Now go to the *Jails* section again, then the *Configuration* tab. 
 # Change the *Jail root* from @/mnt/default@ to @/mnt/jails@ 
 # *Reboot* the FreeNAS 

 h3. 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. 

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

 h2. 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. 

 h3. Local to local 

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

 # Begin by logging into the FreeNAS web panel and going to the Jails sections and +turning of all jails+ 
 # Then go to the *Storage* section, select the +jails+ zvol and then *Create ZFS Dataset* named +node3+ 
 # Next open a *Shell* in the FreeNAS web panel 
 # Migrate the files to the new location: 
 <pre> 
 rsync -avh -n /mnt/master/node3/ /mnt/jails/node3/ 
 rsync -avh -n /mnt/master/.node3.meta /mnt/jails/ 
 </pre> 
 #* 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 
 # Now go to the *Jails* section again, then the *Configuration* tab. 
 # Change the *Jail root* from @/mnt/master@ to @/mnt/jails@ 
 # *Reboot* the FreeNAS 

 NOTE: Repeat for each individual jail 

 h3. Local to remote 

 In this example I will be migrating a single jail, node3, from @/mnt/master@ to @/mnt/jails@. In @/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. 

 # Begin by logging into the local FreeNAS web panel and going to the Jails sections and +turning of all jails+ 
 # Then go to the *Storage* section on the remote FreeNAS, select the +jails+ zvol and then *Create ZFS Dataset* named +node3+ 
 # Next open a *Shell* in the FreeNAS web panel 
 # Migrate the files to the new location: 
 <pre> 
 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/ 
 </pre> 
 #* 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 
 # Now go to the *Jails* section on the remote FreeNAS, then the *Configuration* tab. 
 # Change the *Jail root* to @/mnt/jails@ 
 # *Reboot* the FreeNAS 

 h2. ZFS to ZFS Jail Migration 

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

 h3. Local to local 

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

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

 h3. 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. 

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

 h2. Resources 

 * http://olddoc.freenas.org/index.php/Replication_Tasks

Back