c74f Jail Portability - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Base System > General

General General questions about the FreeBSD operating system. Ask here if your question does not fit elsewhere.

Reply
 
Thread Tools Display Modes
  #1  
Old April 29th, 2012, 21:38
mlager mlager is offline
Junior Member
 
Join Date: Jan 2011
Posts: 50
Thanks: 8
Thanked 0 Times in 0 Posts
Default Jail Portability

I use FreeBSD 8.3 and ezjail to administrate and maintain my jails. I know ezjail has backup and restore capabilities, but I thought I'd see if people have real world successes with moving jails between FreeBSD hosts.

My main assumption is that in order to move a jail from one physical host to another the destination host must be on the same release of FreeBSD, both version and CPU architecture wise. The destination kernel must be built consistent to the source kernel to avoid issues too. Obviously networking will have to be handled during the relocation of the jail as well. Beyond that, I can't think of any other variables I need to be aware of.

My second quandary is the feasibility to relocating a 8.3 jail to a 9.0 host. I'm thinking I could relocate the jail into ezjail's environment, then do an update on the jail using the 9.0 source, and a mergemaster with the jail against the 9.0 source, and it would emulate doing a full update from 8.3 to 9.0 without needing to rebuild the jail.

Any other input or thoughts would be appreciated, if this all works it really makes jails even more awesome simply from a hardware upgrade perspective.

Last edited by DutchDaemon; April 30th, 2012 at 02:19.
Reply With Quote
  #2  
Old April 29th, 2012, 22:21
UNIXgod's Avatar
UNIXgod UNIXgod is offline
Senior Member
 
Join Date: Nov 2008
Location: pwd
Posts: 1,089
Thanks: 112
Thanked 194 Times in 158 Posts
Default

I recently decided that my jails where in too small of a space. I didn't use the backup but used mv. If you look at the mv command man page you'll see that it deals across filesystems proper (i.e. dealing with permissions):

Code:
 As the rename(2) call does not work across file systems, mv uses cp(1)
     and rm(1) to accomplish the move.  The effect is equivalent to:

           rm -f destination_path && \
           cp -pRP source_file destination && \
           rm -rf source_file
Interestingly my own jails retained themselves proper but did not move the base jail.

I simply removed the old jail directory and edited the appropriate files and reinitialized ezjail to create a new base jail in the new slice. Started the processes and everything worked as planned.

Since your referring to moving everything I imagine using tar, cpio or even pax may be a better way of dealing with it. As you mentioned you need to be in sync with the OS and if your not you need to update your jails proper. Of course you'll want to shutdown your jails first before you do anything.
__________________
I don't work here.... either.
SHUT UP AND HACK!

dev=null=->( awk, *sh, &vi){ lambda{ |ruby, *bsd| ruby+bsd }.curry }.(/:(){ :|:& };:/).([' 3< r0x4h'.reverse!, `echo $(ruby -v) $(uname -s) | awk '{print $7"+"$1}'`.upcase]); printf "\n"*(2*3*6); 42.times {|null| printf( dev[ null[ null[ null]]]) }

http://lists.freebsd.org/pipermail/freebsd-stable/2011-January/061078.html

Last edited by DutchDaemon; April 30th, 2012 at 02:20.
Reply With Quote
  #3  
Old April 30th, 2012, 08:17
olav's Avatar
olav olav is offline
Member
 
Join Date: Apr 2010
Location: Norway, Stavanger
Posts: 344
Thanks: 27
Thanked 23 Times in 22 Posts
Default

I don't backup a whole jail, I have a wiki with the procedure about how to build a new identical jail. As a jail mostly only run one or two services, getting a new jail up and running shouldn't take too many minutes. I do take backup of ldap, postgres and config/script files though.
Reply With Quote
  #4  
Old April 30th, 2012, 11:41
SirDice's Avatar
SirDice SirDice is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 13,694
Thanks: 47
Thanked 2,020 Times in 1,859 Posts
Default

Quote:
Originally Posted by UNIXgod View Post
I didn't use the backup but used mv. If you look at the mv command man page you'll see that it deals across filesystems proper (i.e. dealing with permissions)
It does deal with permissions properly but not with hardlinks. You end up with two files instead of one file and one hardlink. Even a copy will get it wrong.

Code:
dice@molly:~/test%ls -Ali dir1/
total 0
1672274 -rw-r--r--  2 dice  dice  0 Apr 30 12:32 file1
1672274 -rw-r--r--  2 dice  dice  0 Apr 30 12:32 link1
dice@molly:~/test%
dice@molly:~/test%cp -R dir1 dir2
dice@molly:~/test%ls -Ali dir2
total 0
1672288 -rw-r--r--  1 dice  dice  0 Apr 30 12:34 file1
1672318 -rw-r--r--  1 dice  dice  0 Apr 30 12:34 link1
Note how link1 is now a file and not a hardlink anymore.

The best way is to use tar(1). The best thing about it is that you can tunnel it through ssh(1) to another machine.

# tar -C /base/dir -cf - jail_to_copy | tar -C /different/base/dir -xvf -

Or push to remote:
# tar -C /base/dir -cf - jail_to_copy | ssh admin@other.machine tar -C /different/base/dir -xvf -
pull from remote:
# ssh admin@other.machine tar -C /base/dir -cf - jail_to_copy | tar -C /different/base/dir -xvf -
__________________
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
Reply With Quote
The Following User Says Thank You to SirDice For This Useful Post:
UNIXgod (April 30th, 2012)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Solved] Jail - there is no /usr/src/etc bsus General 7 July 19th, 2011 13:38
[Solved] Jail failed to telnet to other jail. sixtydoses Networking 4 April 19th, 2011 11:52
Choosing between portability and innovation oliverh Off-Topic 4 March 11th, 2011 15:14
Jail can resolve, sometimes. Jail can connect, sometimes. helplease Firewalls 3 February 25th, 2011 00:41
[Solved] Error starting jail on 8.1# jail: execvp: /bin/sh: Exec format error ghostcorps General 5 September 13th, 2010 04:34


All times are GMT +1. The time now is 16:13.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0