bzerk




Moving Solaris 10 zones to another server
Moving Solaris 10 zones to another server
Ruben de Groot, 15-05-2009

This document describes shortly the steps to be taken when moving Solaris 10 zones from one "source" server to another "destination" server. Both servers are running ZFS filesystems, so we will use the zfs send/recv functionality. In this example there is just one zone for samba.

Preparation

Before we start, make sure there's enough space on the destination server.
source# tar cf - /etc/zones | ssh destination "cd /; tar xf -"

Filesystem layout
source# zfs list
NAME                              USED  AVAIL  REFER  MOUNTPOINT
rpool                            55.2G   238G  35.5K  /rpool
rpool/ROOT                       3.42G   238G    18K  legacy
rpool/ROOT/s10x_u6wos_07b        3.42G   238G  3.36G  /
rpool/ROOT/s10x_u6wos_07b/var    68.5M   238G  68.5M  /var
rpool/swap                       2.00G   240G    16K  -
rpool/zones                      15.0G   238G  29.5K  /zones
rpool/zones/samba                12.9G   238G  12.6G  /zones/samba
rpool/zones/samba/local           294M   238G   294M  /usr/local

Zone configuration

Note the extra dataset "rpool/zones/samba/local", which is mounted on /usr/local inside the zone. We will use this information later. source# more /etc/zones/samba.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE zone PUBLIC "-//Sun Microsystems Inc//DTD Zones//EN" "file:///usr/share/lib/xml/dtd/zonecfg.dtd.1"> <!-- DO NOT EDIT THIS FILE. Use zonecfg(1M) instead. --> <zone name="samba" zonepath="/zones/samba" autoboot="true"> <inherited-pkg-dir directory="/lib"/> <inherited-pkg-dir directory="/platform"/> <inherited-pkg-dir directory="/sbin"/> <inherited-pkg-dir directory="/usr"/> <dataset name="rpool/zones/samba/local"/> <network address="10.10.10.73" physical="bge0" defrouter="10.10.10.1"/> </zone>
Snapshot source server and do an initial copy

With the zones on the source server still running, we take a snapshot and send the data to the destination:
source# for fs in rpool/zones rpool/zones/samba rpool/zones/samba/local; do
>	zfs snapshot ${fs}@migrate
>	zfs send ${fs}@migrate | ssh destination pfexec zfs recv -F ${fs}
>done
source#
This may take a while. When finished, the first thing to do on the destination server is to make these filesystems read-only, otherwise we won't be able to do an incremental send/receive on them:
destination# for fs in rpool/zones rpool/zones/samba rpool/zones/samba/local; do
>	zfs set readonly=on ${fs}
>done
destination#
The final copy

The next steps will result in some downtime. But, depending on the amount of changes since taking the previous snapshot, this will normally not be more then a few minutes.
First we stop the zone on the source server
source# zlogin samba shutdown
Or if that does not work:
source# zoneadm -z samba halt
Then we detach the zone on the source server to prevent it accidentally booting up again.
source# zoneadm -z samba detach
Now we take a final snapshot and send the incremental data over to the destination server
source# for fs in rpool/zones rpool/zones/samba rpool/zones/samba/local; do
>	zfs snapshot ${fs}@migrate2
>	zfs send -i ${fs}@migrate ${fs}@migrate2 | ssh destination pfexec zfs recv ${fs}
>done
source#
Bringing up the zone on the destination server

Back on the destination server, we can now make the filesystems read-write again and then attach the zones
Finally, we set up the /usr/local mountpoint inside the zone.
destination# for fs in rpool/zones rpool/zones/samba rpool/zones/samba/local; do
>	zfs set readonly=off ${fs}
>done
destination# zoneadm -z samba attach -u
destination# zoneadm -z samba boot
destination# zlogin samba zfs set mountpoint=/usr/local rpool/zones/samba/local

That's it. The zone has now been moved.