Powered By Blogger

Thursday, January 20, 2011

Creating a Zone in Solaris 10

To view a list and status of currently installed zones:
------------------------------------------------------

# zoneadm list -vi

ID NAME STATUS PATH
0 global running /
1 jumpstart running /u01/zones/jumpstart


To create a new zone:
--------------------

# zonecfg -z
(if the zone has not been configured at all previously, you will receive:

No such zone configured
Use 'create' to begin configuring a new zone.
)
a full example of zone creation for a zone called 'zone1':
---------------------------------------------------------

# zonecfg -z zone1
zone1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:zone1> create
zonecfg:zone1> set zonepath=/u01/zones/zone1
zonecfg:zone1> set autoboot=true
zonecfg:zone1> add fs
zonecfg:zone1:fs> set dir=/opt
zonecfg:zone1:fs> set special=/opt
zonecfg:zone1:fs> set type=lofs
zonecfg:zone1:fs> add options [ro,nodevices]
zonecfg:zone1:fs> end
zonecfg:zone1> verify
zonecfg:zone1> add net
zonecfg:zone1:net> set address=10.67.1.151/24
zonecfg:zone1:net> set physical=eri0
zonecfg:zone1:net> end
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> exit

# zoneadm -z zone1 install
Preparing to install zone .
Creating list of files to copy from the global zone.
Copying <1887> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <951> packages on the zone.
Initialized <951> packages on zone.
Zone is initialized.
Installation of <1> packages was skipped.
Installation of these packages generated warnings:
The file contains a log of the zone installation.
# zoneadm -z zone1 boot
# zlogin -e \@ -C zone1 # -e sets the escape sequence for console session
[Connected to zone 'zone1' console]

To Delete a Zone Permanently:
----------------------------

zoneadm -z halt
zoneadm -z uninstall
zonecfg -z delete

To Delete a zone in a weird state:
---------------------------------

If the install get interrupted, or the configuration has problems, the zone can end up in an incomplete
state. In this state, it is difficult to uninstall or delete, or continue the configuration. To remove
the incomplete zone and start fresh, do the following:

1. remove the zone entry in /etc/zones/index:

global:installed:/
zone1:installed:/u01/zones/zone1
zone2:installed:/u01/zones/zone2
zone3:incomplete:/u01/zones/zone3 <-----------

2. delete the xml file associated with the zone under /etc/zones

3. delete the directory associated with the zone (if it has been created)

How to install a Linux zone under Solaris 10

1. Make sure you have Solaris 10 for X86 Update 4 (or later) installed, as this supports Linux zones.

2. Obtain a distribution copy of CentOS or RedHat ES linux v3.5 to 3.8, and a copy of Adobe Reader v7 for Linux here

3. Install a zone as follows (use the appropriate values for your system):-

# mkdir -p /Zones/Linux
# chmod 700 /Zones/Linux
# zonecfg -z linux
linux: No such zone configured
Use 'create' to begin configuring a new zone.

zonecfg:linux> create -t SUNWlx
zonecfg:linux> add net
zonecfg:linux:net> set physical=bfe0
zonecfg:linux:net> set address=192.168.200.31
zonecfg:linux:net> end
zonecfg:linux> set zonepath=/Zones/Linux
zonecfg:linux> verify
zonecfg:linux> commit
zonecfg:linux> exit

# zoneadm -z linux install


Please insert any supported Linux distribution disc, or a
supported Linux distribution DVD in the removable media
drive and press .


4. Continue with installation until it completes, then boot the new linux zone:-

# zoneadm -z linux boot


5. Now log in to the new zone:-

# zlogin -C linux

How to Install solaris 10 zones using veritas file system.

0[root@testserver(global):~]# format
Searching for disks...done


AVAILABLE DISK SELECTIONS:
0. c0t0d0
/pci@83,4000/FJSV,ulsa@2,1/sd@0,0
1. c0t1d0
/pci@83,4000/FJSV,ulsa@2,1/sd@1,0
2. c6t60060E8004EA68000000EA6800000788d0
/scsi_vhci/ssd@g60060e8004ea68000000ea6800000788
3. c6t60060E8004EA69000000EA690000312Ed0
/scsi_vhci/ssd@g60060e8004ea69000000ea690000312e
Specify disk (enter its number): 2
selecting c6t60060E8004EA68000000EA6800000788d0
[disk formatted]


FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
! - execute , then return
quit
format> p


PARTITION MENU:
0 - change `0' partition
1 - change `1' partition
2 - change `2' partition
3 - change `3' partition
4 - change `4' partition
5 - change `5' partition
6 - change `6' partition
7 - change `7' partition
select - select a predefined table
modify - modify a predefined partition table
name - name the current table
print - display the current table
label - write partition map and label to the disk
! - execute , then return
quit
partition> p
Current partition table (original):
Total disk cylinders available: 2238 + 2 (reserved cylinders)

Part Tag Flag Cylinders Size Blocks
0 unassigned wm 0 0 (0/0/0) 0
1 unassigned wm 0 0 (0/0/0) 0
2 backup wu 0 - 2237 8.20GB (2238/0/0) 17187840
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 - wu 0 - 2237 8.20GB (2238/0/0) 17187840

/usr/lib/vxvm/bin/vxdisksetup -i Disk_1

vxdg init test_zone-001 adddisk=Disk_1

vxassist -g test_zone-001 make testzone 8g

mkfs -F vxfs /dev/vx/rdsk/test_zone-001/testzone

vi /etc/vfstab
/dev/vx/dsk/test_zone-001/testzone /dev/vx/rdsk/test_zone-001/testzone /zone/test-zone vxfs 1 yes -

mkdir -p /zone/test-zone

mount -a

df -h
zonecfg -z test-zone
zonecfg:test-zone>create
zonecfg:test-zone>set zonepath=/zone/test-zone
zonecfg:test-zone>verify
zonecfg:test-zone>commit
zonecfg:test-zone>exit
chmod 700 /zone/test-zone
zoneadm -z test-zone install
zoneadm -z test-zone boot

0[root@testserver(global):~]# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
1 test-zone running /zone/test-zone native shared

0[root@testserver(global):~]# zlogin test-zone
[Connected to zone 'test-zone' pts/1]
Last login: Thu Jan 20 05:12:46 on pts/1
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
# df -h
Filesystem size used avail capacity Mounted on
/ 8.0G 159M 7.4G 3% /
/dev 8.0G 159M 7.4G 3% /dev
/lib 24G 1.6G 22G 7% /lib
/platform 24G 1.6G 22G 7% /platform
/sbin 24G 1.6G 22G 7% /sbin
/usr 24G 1.6G 22G 7% /usr
proc 0K 0K 0K 0% /proc
ctfs 0K 0K 0K 0% /system/contract
mnttab 0K 0K 0K 0% /etc/mnttab
objfs 0K 0K 0K 0% /system/object
swap 9.0G 248K 9.0G 1% /etc/svc/volatile
fd 0K 0K 0K 0% /dev/fd
swap 9.0G 0K 9.0G 0% /tmp
swap 9.0G 0K 9.0G 0% /var/run