Archive

Archive for December, 2010

Create a Solaris zone(under Sun Solaris)

December 30th, 2010 No comments

root@beisoltest03 / # zonecfg -z red
red: No such zone configured
Use ‘create’ to begin configuring a new zone.
zonecfg:red> create
zonecfg:red> info
zonename: red
zonepath:
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
zonecfg:red> add net
zonecfg:red:net> set address=10.240.3.212
zonecfg:red:net> set physical=e1000g1
zonecfg:red:net> set defrouter=10.240.3.254
zonecfg:red:net> end
zonecfg:red> verify
zonepath cannot be empty.
red: Required resource missing
zonecfg:red> set zonepath=/zone/red
zonecfg:red> verify
zonecfg:red> exit

it’s ready, let’s check

root@beisoltest03 / # zonecfg -z red
zonecfg:red> info
zonename: red
zonepath: /zone/red
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
net:
address: 10.240.3.212
physical: e1000g1
defrouter: 10.240.3.254

Now install it

root@beisoltest03 / # zoneadm -z red install
Preparing to install zone <red>.
Creating list of files to copy from the global zone.
Copying <7792> files to the zone.

Now give it life

root@beisoltest03 / #zoneadm -z red boot

root@beisoltest03 / #zlogin -C red

Welcome to new world .

PS: Other commands that will be used in future:
zoneadm list -cv
Boot the zone called \jubail”
zoneadm -z jubail boot
Delete zone and con guration from system
zoneadm -z jubail uninstall -F
Login to the console of the jubail zone from the global zone
zlogin -C jubail (Exit from session with ~. escape sequence)
Halt the jubail zone (no shutdown scripts will be run)
zoneadm -z jubail halt
Shutdown the jubail zone from the global zone
zlogin jubail shutdown -i0 -g0 -y
List what zone you are currently in
zonename
View zone performance statistics (from global zone)
prstat -Z

Categories: Unix Tags:

Solaris /var full resolution

December 28th, 2010 No comments

Using df -h to see the summary usage of partition:

df -h
/dev/md/dsk/d3 3.9G 3.6G 298M 93% /var

Then using du -sh ./* | sort,and you may find that directory /var/adm employs much of the space:

/var/adm 1.5GB

And go further to the directory,you may find the file /var/adm/wtmpx employs much of the directory size:

1.4G /var/adm/wtmpx

Here goes the resolution:

echo “” > /var/adm/wtmpx

If you want to delete any file(s),you must firstly see if any processes using them.You can do this check through command lsof:

lsof | grep wtmpx

If no process using the file,you can now using rm -i command to delete the file at ease and recreate the file,chmod it latter:

rm -i /var/adm/wtmpx
touch /var/adm/wtmpx && chmod 644 /var/adm/wtmpx

Categories: Unix Tags:

How to Shut Down or Reboot a Solaris System

December 27th, 2010 No comments

Solaris is usually used as a server operating system. Because of this, you want to make sure that you shut the system down as gracefully as possible to ensure there isn’t any data loss.

For every application that is installed on your server, you should make sure that you have the correct scripts in /etc/rc(x).d to gracefully shut down the service.

Shutdown
You have more than one command option that you can use. The best command is this, executed as root:
shutdown -y -i5 -g0
This will immediately shut the system down. You can also use the older command that still works:
sync;sync;init 5
You can even use:

poweroff
Reboot
If you are trying to reboot the system as opposed to turning it off, you could use:
shutdown -y -i6 -g0
Or:
sync;sync;init 6
Or even:
reboot
So many commands to do the same thing… almost seems silly.

Categories: Unix Tags:

Using shell read command to read first several lines from specified file

December 26th, 2010 No comments

The following bash shell script will read first 2 lines from /etc/fstab and then bind each one to the corresponding variable $line1 & $line2. In the script, we will use Redirecting Input & Shell Builtin Commands of the bash shell.
#!/bin/bash
# Reading lines in /etc/fstab.
File=/etc/fstab
{ read line1;read line2; } < $File
echo “First line in $File is:”
echo “$line1″
echo
echo “Second line in $File is:”
echo “$line2″

PS:

You can also use awk to read specified line from a file, e.g.

awk ‘{if(NR==’1′){print}}’ a.txt

This will print the first line of a.txt.