Moving Solaris zones

While messing around with zones and ZFS last weekend, I decided to create a new ZFS file system called /zones to store my zones. The /zones file system would be created as a striped ZFS file system, allowing me to take advantage of ZFS’s data checksumming, compression, snapshots and zone cloning features. Since I already had one zone installed in /zones, I needed to migrate the zone to another location while I setup the new ZFS file system. There are numerous ways to do this, but I decided to use the zoneadm “move” option since it was designed for this purpose.

To begin the migration, I ran the zoneadm utility to halt the zone I wanted to migrate:

$ zoneadm -z centos halt

Once the zone was halted, I executed zoneadm with the "move" option and
the location where I wanted the zone moved:

$ zoneadm -z centos move /zones/centos

Moving across file systems; copying zonepath /zones/centos...
Cleaning up zonepath /zones/centos...

Now that the zone was in a safe temporary place, I ran the zpool utility to create a 2 disk striped pool (the underlying storage is RAID protected, so there is no need to protect the pool a second time):

$ zpool create zones c1d0 c1d1

$ zpool status -v

pool: zones
state: ONLINE
scrub: none requested

zones ONLINE 0 0 0
c1d0 ONLINE 0 0 0
c1d1 ONLINE 0 0 0

errors: No known data errors

Now that I had a file system to store all of my zones, I once again used the zoneadm “move” option to move the zone back to it’s rightful home:

$ zoneadm -z centos move /zones/centos

cannot create ZFS dataset zones/centos: 'sharenfs' must be a string
Moving across file systems; copying zonepath /centos...
Cleaning up zonepath /centos...

I am a big fan of zones, and they are an ideal solution for server consolidation projects!

This article was posted by Matty on 2006-09-27 23:18:00 -0400 EDT