Non-global Solaris zone migration to another machine
I had task to migrate Nagios with NagiosGrapher (running on Sparc zone) to another machine (SunFire X4200, yes i386 platform). Trus me, it was pain in the neck.
First I manually migrated "Nagios sparc zone" to test i386 platform and then it was simple doing migration from there to production platform (another X4200 with same Solaris release and additional patches).
So in this page I just explain how to migrate non-global zone between 2 totally identical systems.
System Serbia has zone France. France zone will be migrated to system Japan and will have new zone name India!
1. Configure whole root zone France to Serbia
{serbia}/zones> mkdir france
{serbia}/> zonecfg -z france
france: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:france> create
zonecfg:france> set zonepath=/zones/france
zonecfg:france> add net
zonecfg:france:net> set physical=e1000g0
zonecfg:france:net> set address=192.168.20.222
zonecfg:france:net> end
zonecfg:france> verify
zonecfg:france> commit
zonecfg:france> exit
Since zone is whole root, remove inherited dirs
{serbia}/zones> zonecfg -z france
zonecfg:france> remove inherit-pkg-dir dir=/lib
zonecfg:france> remove inherit-pkg-dir dir=/platform
zonecfg:france> remove inherit-pkg-dir dir=/sbin
zonecfg:france> remove inherit-pkg-dir dir=/usr
zonecfg:france> verify
zonecfg:france> commit
zonecfg:france> exit
{serbia}/zones> zonecfg -z france info
zonename: france
zonepath: /zones/france
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
net:
address: 192.168.20.222
physical: e1000g0
defrouter not specified
2. Install the zone
{serbia}/zones> zoneadm -z france install
A ZFS file system has been created for this zone.
Preparing to install zone .
Creating list of files to copy from the global zone.
Copying <48022> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <455> packages on the zone.
Initialized <455> packages on zone.
Zone is initialized.
The file contains a log of the zone installation.
The zone size is:
{serbia}/zones/france> du -sh .
680M .
{serbia}/zones/france> zoneadm list -vi
ID NAME STATUS PATH BRAND IP
0 global running / native shared
- france installed /zones/france native shared
3. Boot the zone, but first place sysidcfg file in /zones/france/root/etc/
#The sysidcfg file:
#--------------------
system_locale=en_US
timezone=US/Pacific
timeserver=localhost
#name_service=DNS
# {domain_name=googlux.com
# name_server=xxx.xxx.xxx.xxx}
name_service=NONE
nfs4_domain=genesyslab.com
service_profile=limited_net
terminal=vt100
security_policy=NONE
root_password=NP
network_interface=primary { hostname=france
netmask=255.255.255.0
protocol_ipv6=no
ip_address=192.168.20.222
default_route=192.168.20.1}
{serbia}/> zoneadm -z france boot
{serbia}/> zoneadm list -vi
ID NAME STATUS PATH BRAND IP
0 global running / native shared
1 france running /zones/france native shared
4. Login to zone's console and make sure it works well.
{serbia}/> zlogin -C france
[Connected to zone 'france' console]
france console login:
or login to zone's terminal session
{serbia}/> zlogin france
[Connected to zone 'france' pts/2]
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
# pwd
/
# hostname
*************************************************
Migration to the another machine
*************************************************
1. Now, when having zone, let's migrate it to another machine.
Halt and Detach the zone
{serbia}/> zoneadm -z france halt
{serbia}/> zoneadm list -vi
ID NAME STATUS PATH BRAND IP
0 global running / native shared
- france installed /zones/france native shared
{serbia}/> zoneadm -z france detach
{serbia}/> zoneadm list -vi
ID NAME STATUS PATH BRAND IP
0 global running / native shared
2. Migrate zone path to the new host
{serbia}/zones> rsync -avH france japan:/zones/
3. Rename {japan}/zones/france to /zones/india and adjust sysidcfg file as below
network_interface=primary { hostname=india
netmask=255.255.255.0
protocol_ipv6=no
ip_address=192.168.24.35
default_route=192.168.24.1}
4. Configure zone on the new system
{japan}/tmp> zonecfg -z india
india: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:india> create -a /zones/india
zonecfg:india> info ---> see zone info
zonename: india
zonepath: /zones/india
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
net:
address: 192.168.20.222 ----> change IP
physical: e1000g0
defrouter not specified
zonecfg:india> select net physical=e1000g0
zonecfg:india:net> set address=192.168.24.35
zonecfg:india:net> end
zonecfg:india> commit
zonecfg:india> exit
5. Attach the zone
{japan}/tmp> zoneadm -z india attach
{japan}/tmp> zoneadm list -vi
ID NAME STATUS PATH BRAND IP
0 global running / native shared
- india installed /zones/india native shared
6. Boot the zone
{japan}/tmp> zoneadm -z india boot
{japan}/tmp> zoneadm list -vi
ID NAME STATUS PATH BRAND IP
0 global running / native shared
3 india running /zones/india native shared
{japan}/tmp> zlogin -C india
[Connected to zone 'india' console]
france console login: --------------> hostname has to be changed
7. Login to zone and change hostname to /etc/hosts and /etc/nodename. Done.