Thursday, 27 October 2016

Removing a zpool from a Solaris 11 zone

In this article I'll demonstrate how to remove a zpool assigned to a local zone. The zone needs to be in shutdown state for this to work.

I've shutdown the zone & entered zonecfg interface:

root@global:/etc/zones# zonecfg -z localzone

To view the assigned zpools type:

zonecfg:localzone> info zpool
zpool:
        name: dpool01
        storage: dev:/dev/dsk/c0t60002AC0000000000000453B0000935Dd0
zpool:
        name: dpool02
        storage: dev:/dev/dsk/c0t60002AC0000000000000453E0000935Dd0
zpool:
        name: expdmp
        storage: dev:/dev/dsk/c0t5000CCA0705EDCCCd0
zpool:
        name: expdmp1
        storage: dev:/dev/dsk/c0t60002AC000000000000045440000935Dd0

I need to remove expdmp. So I typed remove zpool name=expdmp but it gave me an error:

zonecfg:localzone> remove zpool name=expdmp
Zone localzone already installed; remove zpool not allowed in 'installed' state.
Use 'zoneadm mark' to mark the zone 'unavailable' or detach the zone
before removing a 'zpool' resource.
zonecfg:localzone> exit

So, I had to detach the zone.

root@global:/etc/zones# zoneadm -z localzone detach
Exported zone zpool: localzone_rpool
Exported zone zpool: localzone_dpool01
Exported zone zpool: localzone_dpool02
Exported zone zpool: localzone_expdmp
Exported zone zpool: localzone_expdmp1

Then remove the zpool:

root@global:/etc/zones# zonecfg -z localzone
zonecfg:localzone> remove zpool name=expdmp
zonecfg:localzone> verify
zonecfg:localzone> commit
zonecfg:localzone> exit

Once done, attach the zone & boot it.

root@global:/etc/zones# zoneadm -z localzone attach
Imported zone zpool: localzone_rpool
Imported zone zpool: localzone_dpool01
Imported zone zpool: localzone_dpool02
Imported zone zpool: localzone_expdmp1
Progress being logged to /var/log/zones/zoneadm.20161018T124012Z.localzone.attach
    Installing: Using existing zone boot environment
      Zone BE root dataset: localzone_rpool/rpool/ROOT/solaris-0
                     Cache: Using /var/pkg/publisher.
  Updating non-global zone: Linking to image /.
Processing linked: 1/1 done
  Updating non-global zone: Auditing packages.
No updates necessary for this image.

  Updating non-global zone: Zone updated.
                    Result: Attach Succeeded.
Log saved in non-global zone as /zones/localzone/root/var/log/zones/zoneadm.20161018T124012Z.localzone.attach
You have new mail in /var/mail/root

root@global:/etc/zones# zoneadm -z localzone boot

No comments:

Post a Comment

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...