How to uninstall a Solaris zone in an incomplete state
Have you ever fallen into a trap of cloning a zone and for one reason or another the cloning fails which leaves the clone in an incomplete state? Well I have, and the most common cause was not providing enough diskspace for the cloned zone :-(
# zoneadm -z perky clone pinky Copying /zones/pinky...zoneadm: zone 'perky': 'copy' failed with exit code 255. The copy failed. More information can be found in /var/log/zoneAAABtaajS # tail /var/log/zoneAAABtaajS cpio: Cannot open/create "/zones/perky/dev/arp", errno 28, No space left on device cpio: Cannot open/create "/zones/perky/dev/.devlink_db_lock", errno 28, No space left on device cpio: Cannot open/create "/zones/perky/dev/.devlink_db", errno 28, No space left on device cpio: Cannot open/create "/zones/perky/dev/.devfsadm_dev.lock", errno 28, No space left on device cpio: Cannot create directory "/zones/perky/dev", errno 28, No space left on device cpio: Cannot chown() "/zones/perky/dev", errno 2, No such file or directory cpio: Unable to reset modification time for "dev", errno 2, No such file or directory cpio: Cannot chmod() "/zones/perky/dev", errno 2, No such file or directory 11730288 blocks 78907 error(s)
If we checkout the zone, we see that my new zone (perky) is in an incomplete state:
# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / native shared 13 cobra running /zones/cobra native shared 14 asp running /zones/asp native shared - pinky installed /zones/pinky native shared - perky incomplete /zones/perky native shared
The only solution I've found to clear an incomplete zone is to force an uninstall of the zone:
# zoneadm -z perky uninstall -F WARNING: Unable to completely remove /zones/perky because it contains additional user data. Only the standard directory entries have been removed.
and finally delete the zone:
# zonecfg -z perky delete Are you sure you want to delete zone perky (y/[n])? y
and start again, once I've generated enough disk space for the new clone :-)