Creating and Using Oracle® Solaris Zones

Exit Print View

Updated: May 2015
 
 

How to Migrate A Non-Global Zone Using ZFS Archives

You must be the global administrator or a user with appropriate authorizations in the global zone to perform this procedure.

This example describes how to create an archive of a zone and then attach that archive to another system. It assumes that the administrator on the source and target hosts are able to access a shared NFS server for temporary file storage. In the event that shared temporary space is not available, other means, such as scp secure copy, a remote file copy program, can be used to copy the files between the source and target machines. The scp program requests passwords or passphrases if they are needed for authentication.

  1. Become an administrator.

    For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.2 .

  2. Shut down the zone to be migrated, my-zone in this procedure.
    host1# zoneadm -z my-zone shutdown
  3. (Optional) Detach the zone.
    host1# zoneadm -z my-zone detach

    The detached zone is now in the configured state. The zone will not automatically boot when the global zone next boots.

  4. Export the zone configuration.
    host1# mkdir /net/server/zonearchives/my-zone
    host1# zonecfg -z my-zone export > /net/server/zonearchives/my-zone/my-zone.zonecfg
  5. Create a gzip ZFS archive.
    host1# zfs list -H -o name /zones/my-zone
    rpool/zones/my-zone
    host1# zfs snapshot -r rpool/zones/my-zone@v2v
    host1# zfs send -rc rpool/zones/my-zone@v2v | gzip > /net/server/zonearchives/my-zone/my-zone.zfs.gz

    Use of compression is optional, but it is generally faster because less I/O is performed while writing and subsequently reading the archive. For more information, see Managing ZFS File Systems in Oracle Solaris 11.2 .

  6. On the new host, configure the zone.
    host2# zonecfg -z my-zone -f /net/server/zonearchives/my-zone/my-zone.zonecfg

    You will see the following system message:

    my-zone: No such zone configured
    Use 'create' to begin configuring a new zone.
  7. (Optional) View the configuration.
    host2# zonecfg:my-zone> info
    zonename: my-zone
    zonepath: /zones/my-zone
    autoboot: false
    pool:
    net:
             address: 192.168.0.90
             physical: net0
  8. Make any required adjustments to the configuration.

    For example, the network physical device is different on the new host, or devices that are part of the configuration might have different names on the new host.

    host2# zonecfg -z my-zone
    zonecfg:my-zone> select net physical=net0
    zonecfg:my-zone:net> set physical=net100
    zonecfg:my-zone:net> end
  9. Commit the configuration and exit.
    zonecfg:my-zone> commit
    zonecfg:my-zone> exit
  10. Install the zone on the new host by using one of the following methods. Use of the install subcommand is recommended.
    • Install the zone, performing the minimum updates required to allow the install to succeed:
      host2# zoneadm -z my-zone install -p -a /net/server/zonearchives/my-zone/my-zone.zfs.gz

      In this release, you can also attach the zone, performing the minimum updates required to allow the attach to succeed. If updates are allowed, catalogs from publishers are refreshed during a zoneadm attach.

      host2# zoneadm -z my-zone attach -u -a /net/server/zonearchives/my-zone/my-zone.zfs.gz
    • Install the zone, updating all packages in the zone to the latest version that is compatible with the global zone.
      host2# zoneadm -z my-zone install -U -p -a /net/server/zonearchives/my-zone/my-zone.zfs.gz

      In this release, you can also attach the zone, updating all packages in the zone to the latest version that is compatible with the global zone.

      host2# zoneadm -z my-zone install -U -a /net/server/zonearchives/my-zone/my-zone.zfs.gz
    • Attach the zone to the new host without updating any software.
      host2# zoneadm -z my-zone attach -a /net/server/zonearchives/my-zone/my-zone.zfs.gz

    Note -  Use of the install subcommand is recommended. In this release, you can also attach the zone, updating all packages in the zone to the latest version that is compatible with the global zone.

Troubleshooting

If a storage object contains any preexisting partitions, zpools, or UFS file systems, the install fails and an error message is displayed. To continue the installation and overwrite any preexisting data, use the –x option to zoneadm install.