Solaris zone cheat sheet

Zone States

ConfiguredConfiguration has been completed and storage has been committed. Additional configuration is still required.
IncompleteZone is in this state when it is being installed or uninstalled.
InstalledThe zone has a confirmed configuration, zoneadm is used to verify the configuration, Solaris packages have been installed, even through it has been installed, it still has no virtual platform associated with it.
Ready (active)Zone’s virtual platform is established. The kernel creates the zsched process, the network interfaces are plumbed and filesystems mounted. The system also assigns a zone ID at this state, but no processes are associated with this zone.
Running (active)A zone enters this state when the first user process is created. This is the normal state for an operational zone.
Shutting down + Down (active)Normal state when a zone is being shutdown.

Files and Directories

zone config file/etc/zones
zone index/etc/zones/index

Note: used by /lib/svc/method/svc-zones to start and stop zones

Cheat sheet

Creating a zonezonecfg -z <zone>see creating a zone for a more details
deleting a zone from the global ssytem## halt the zone first, then uninstall it
zoneadm -z <zone> halt
zoneadm -z <zone> uninstall

## now you can delete it
zonecfg -z <zone> delete -F
Display zones current configurationzonecfg -z <zone> info
Display zone namezonename
Create a zone creation filezonecfg -z <zone> export
  
Verify a zonezoneadm -z <zone> verify
Installing a zonezoneadm -z <zone> install
Ready a zonezoneadm -z <zone> ready
boot a zonezoneadm -z <zone> boot
reboot a zonezoneadm -z <zone> reboot
halt a zonezoneadm -z <zone> halt
uninstalling a zonezoneadm -z <zone> uninstall -F
Veiwing zoneszoneadm list -cv
  
login into a zonezlogin <zone>
login to a zones consolezlogin -C <zone> (use ~. to exit)
login into a zone in safe mode (recovery)zlogin -S <zone>
  
add/remove a package (global zone)# pkgadd -G -d . <package>

If the -G option is missing the package will be added to all zones
add/remove a package (non-global zone)# pkgadd -Z -d . <package>If the -Z option is missing the package will be added to all zones
Query packages in all non-global zones# pkginfo -Z
query packages in a specified zone# pkginfo -z <zone>
  
lists processes in a zone# ps -z <zone>
list the ipcs in a zone# ipcs -z <zone>
process grep in a zone# pgrep -z <zone>
list the ptree in a zone# ptree -z <zone>
Display all filesystems# df -Zk
display the zones process informtion# prstat -Z# prstat -z <zone>
Note:-Z reports information about processes and zones
-z reports information about a particular zone

Solaris 11 Zone copy using Unified Archives

Create the archive

# archiveadm create -r -z zone2 /archives/zone2.uar

in the target system, the zpool should already exist, then we create the zone and use the archive to install the zone.

# zonecfg -z zone2 create -a /root/zone2.uar
# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / solaris share
zone2 configured /zone2pool solaris excl

# zoneadm -z zone2 uninstall
# zoneadm -z zone2 install -a /root/zone2.uar

if “install” fails try this script:

#!/bin/bash

Z=$1
set -x

pkg -R /zones/$Z/root set-publisher -G http://sunutil5:10000/ solaris
pkg -R /zones/$Z/root variant -H variant.arch
pkg -R /zones/$Z/root set-property use-system-repo true
pkg -R /zones/$Z/root publisher -H -F tsv
pkg -R /zones/$Z/root refresh –full
pkg -R /zones/$Z/root uninstall VRTSvlic VRTSperl
zoneadm -z $Z attach -u


# zoneadm -z zone2 boot

Solaris 11 iscsi client

# iscsiadm add discovery-address 192.168.5.100:3260
# iscsiadm add static-config iqn.2022-02.lan.hoshi:solaris01,192.168.5.100
# iscsiadm list target -v iqn.2022-02.lan.hoshi:solaris01,192.168.5.100
# iscsiadm modify discovery -t enable
# iscsiadm modify discovery –static enable
# devfsadm -i iscsi

from:

https://docs.oracle.com/cd/E23824_01/html/821-1459/fnnop.html#gkgng

https://docs.oracle.com/cd/E18752_01/html/817-5093/fncpi.html

Solaris 11, error labeling disk

If you get this error while labeling a disk inside “format”:

format> la
 WARNING - This disk may be in use by an application that has
 modified the fdisk table. Ensure that this disk is
 not currently in use before proceeding to use fdisk.

Issue the “fdisk” command inside format

format> fdisk
 No fdisk table exists. The default partition for the disk is:

a 100% "SOLARIS System" partition

Type "y" to accept the default partition, otherwise type "n" to edit the
 partition table.

After this, you can label the disk

Solaris 11 + AD 2016/2019

IDMU=Identity Management for Unix has been deprecated from AD, the last AD version to support it is 2012, but the RFC 2307(unix) attributes still exist in AD, we just need to edit them manually in ADUC=Active Directory Users and Computers manually for each user, via Advanced Options. See the link below :

https://www.ibm.com/docs/en/spectrum-scale/5.0.5?topic=imwr2a-configuring-id-mappings-in-active-directory-users-computers-windows-server-2016-subsequent-versions

These are the attributes to edit:

Field on IMU Unix Attributes tabRFC2307 AD attribute
UIDuidNumber
Logon ShellloginShell
Home DirectoryunixHomeDirectory
Primary group name or group identifier (GID)primaryGroupID

Connect to WPA Wifi AP in Solaris 11

Very few network cards are supported, in this case i have an Ateros chipset card i plugged off from an acer aspire one

root@solaris01:~# dladm show-phys
LINK MEDIA STATE SPEED DUPLEX DEVICE
net0 Ethernet unknown 100 full bfe0
net1 WiFi up 54 unknown arn0

Create the ip address object

root@solaris01:~# ipadm create-ip net1

Verify the nic has been created as an ipadm object

root@solaris01:~# ipadm show-if
IFNAME CLASS STATE ACTIVE OVER
lo0 loopback ok yes --
net0 ip ok yes --
net1 ip ok yes --

Scan wifi networks

root@solaris01:~# dladm scan-wifi
LINK ESSID BSSID SEC STRENGTH MODE SPEED
net1 DunderMifflin 4:95:e6:de:d6:f1 wpa excellent n 54Mb

Create the encrypted object to store the wpa key

root@solaris01:~# dladm create-secobj -c wpa mykey
provide value for mykey:
confirm value for mkey:

Connect to the network

root@solaris01:~# dladm connect-wifi -e DunderMifflin -k mykey
root@solaris01:~# ipadm create-addr -T dhcp net1

Enable root SSH Login in Oracle Solaris 11

1. Change the file /etc/ssh/sshd_config PermitRootLogin yes with PermitRootLogin no and save file.

    vi /etc/ssh/sshd_config  

  PermitRootLogin yes

2. Comment out the “CONSOLE=/dev/console” line in /etc/default/login.

    vi /etc/default/login

  #CONSOLE=/dev/console

3.Remove “;type=role” from the root entry in /etc/user_attr or use the below command.

 rolemod -K type=normal root

4. Restart the Services.

#svcadm restart svc:/network/ssh:default

Create Solaris 11 Zone

zpool create zone1pool /dev/dsk/c3d0s4
zfs create zone1pool/zone1
zfs set mountpoint=none zone1pool
zfs set mountpoint=/zone01 zone1pool/zone1


zonecfg -z zone01
Use ‘create’ to begin configuring a new zone.
zonecfg:zone01> create -b
create: Using system default template ‘SYSdefault’
zonecfg:zone01> set zonepath=/zone01
zonecfg:zone01> set autoboot=true
zonecfg:zone01> set bootargs=”-m verbose”
zonecfg:zone01> verify
zonecfg:zone01> commit
zonecfg:zone01> exit


zoneadm list -icv
zoneadm -z zone01 install
zoneadm list -icv
zfs list | grep -i zone
zoneadm -z zone01 boot
zlogin -C zone01