Updated 22 March 2010
Linux Logo

Remove Zone Completely


Description:
  • This procedure describes how to remove a Solaris Zone
Prerequisites:
  • Super user access
  • Access to the global zone server
Notes:
  • Must be root to remove a zone.
  • Back up any data that is needed from that zone.
  • List all zones and their status.
  • Be sure no one is logged into the zone to be removed. No warnings are given to users logged into a zone when it is halted. It is a good idea to log into the zone and run the 'who' command to see if anyone is logged in.
References:

Step Action Description
1 Use zoneadm list to show status of current zone
# /usr/sbin/zoneadm list -vi
  On the global zone, use the zoneadm list -vi to show current status of configured zones
global# /usr/sbin/zoneadm list -vi
  ID NAME             STATUS         PATH                           BRAND    IP
   0 global           running        /                              native   shared
   1 utility          running        /zones/utility                 native   shared
   2 myzone           running        /zones/myzone                  native   shared
   3 rlogic           running        /zones/rlogic                  native   shared
   5 bigzone          running        /export/home/bigzone           native   shared
global# 
2 Use zoneadm -z <zonename> halt to stop the Running Zone to be deleted
# /usr/sbin/zoneadm -z <zonename> halt
 
  • Use standard administrative processes to verify that the zone to be remove has no current logins or access.
  • On the global zone, perform zoneadm -z <zonename> halt to stop a running zone
  • Use /usr/sbin/zoneadm list -vi to verify the zone status prior to the zone halt and afterwards.
global# /usr/sbin/zoneadm list -vi
  ID NAME             STATUS         PATH                           BRAND    IP
   0 global           running        /                              native   shared
   1 utility          running        /zones/utility                 native   shared
   2 rlogic           running        /zones/rlogic                  native   shared
   5 selfzone         running        /export/home/selfzone          native   shared
global# zoneadm -z selfzone halt
global# /usr/sbin/zoneadm list -vi
  ID NAME             STATUS         PATH                           BRAND    IP
   0 global           running        /                              native   shared
   1 utility          running        /zones/utility                 native   shared
   2 rlogic           running        /zones/rlogic                  native   shared
   - selfzone         installed      /export/home/selfzone          native   shared
global#

You can also use shutdown to perform the same function.

  • The zlogin -C <zonename> command can be used to login into the zone as root.
  • Stop the running OS by using shutdown.
  • Return to the global zone with "~."
  • Check zone status again with /usr/sbin/zoneadm list -vi
global# zlogin -C myzone
[Connected to zone 'myzone' console]myzone console login: root
Password:
Last login: Fri Jul 14 08:04:53 on pts/2
Aug 30 15:08:17 myzone login: ROOT LOGIN /dev/console
Sun Microsystems Inc.   SunOS 5.11      snv_23  October 2007
You have new mail.
myzone# shutdown -i0 -g0 -y
Shutdown started.    Wed Aug 30 15:48:42 PDT 2006
Broadcast Message from root (console) on myzone Wed Aug 30 15:48:42...
THE SYSTEM bigzone IS BEING SHUT DOWN NOW ! ! !
Log off now or risk your files being damaged
Changing to init state 0 - please wait
showmount: bigzone: RPC: Program not registered
# svc.startd: The system is coming down.  Please wait.
svc.startd: 61 system services are now being stopped.
svc.startd: The system is down.
[NOTICE: Zone halted]
~.
[Connection to zone 'myzone' console closed]
global# /usr/sbin/zoneadm list -vi
  ID NAME             STATUS         PATH                           BRAND    IP
   0 global           running        /                              native   shared
   1 utility          running        /zones/utility                 native   shared
   3 rlogic           running        /zones/rlogic                  native   shared
   5 bigzone          running        /export/home/bigzone           native   shared
   - myzone           installed      /zones/myzone                  native   shared
global#
3 Use zoneadm -z <zonename> with the uninstall option to remove the zone data
# zoneadm -z <zonename> uninstall
Use zoneadm -z <zonename> uninstall to remove the zone data and filesystem.
global# zoneadm -z myzone uninstall
Are you sure you want to uninstall zone myzone (y/[n])? y
global# /usr/sbin/zoneadm list -vi
  ID NAME             STATUS         PATH                           BRAND    IP
   0 global           running        /                              native   shared
   1 utility          running        /zones/utility                 native   shared
   3 rlogic           running        /zones/rlogic                  native   shared
   5 bigzone          running        /export/home/bigzone           native   shared
global# ls /etc/zones
bigzone.xml      rlogic.xml       utility.xml
index            SUNWblank.xml
myzone.xml       SUNWdefault.xml
global#

At this point, the zone is in the configured state. Its configuration file still exists in the /etc/zone directory.

4 Use zonecfg -z <zonename> delete to remove zone configuration file and record
# zonecfg -z <zonename> delete
To remove it completely from the system use zonecfg -z <zonename> delete. This will delete the configuration file in the /etc/zones directory and update the index file.
global# zonecfg -z myzone delete
Are you sure you want to delete zone myzone (y/[n])? y
global# ls /etc/zones
bigzone.xml      rlogic.xml       SUNWdefault.xml
index            SUNWblank.xml    utility.xml
global#

This will not remove the initial zone directory. Use rm -r to delete the zone directory.

global# ls /zones
bigzone  myzone      rlogic      utility
global# rm -r /zones/myzone
global# ls /zones
lqwt1_zone  rlogic      utility
global#
Click for more info