Solaris x86 root filesystem mirroring

Preamble

This document is directed to give idea how to create mirroring of root filesystem in Solaris x86 with the help of Solaris Volume Manager. Here will be used already installed OS and all the work will be done without need of reinstall


Prerequisites

1. First we should be sure have two identical harddisks in the server
 # format
 Searching for disks...done
 AVAILABLE DISK SELECTIONS:
       0. c0d0 <DEFAULT cyl 1563 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@7,1/ide@0/cmdk@0,0
       1. c0d1 <DEFAULT cyl 1563 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@7,1/ide@0/cmdk@1,0
 Specify disk (enter its number): ^C
2. Its need to create small slice for metadb information (usually slice 7) like:
   partition> p
 Current partition table (unnamed):
 Total disk cylinders available: 1563 + 2 (reserved cylinders)

 Part      Tag    Flag     Cylinders        Size            Blocks
   0       root    wm     518 - 1562        8.01GB    (1045/0/0) 16787925
   1       swap    wu       3 -  133        1.00GB    (131/0/0)   2104515
   2     backup    wm       0 - 1562       11.97GB    (1563/0/0) 25109595
   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 unassigned    wm     134 -  135       15.69MB    (2/0/0)       32130
   8       boot    wu       0 -    0        7.84MB    (1/0/0)       16065
   9 alternates    wu       1 -    2       15.69MB    (2/0/0)       32130
3. Next step is to create the same partitions on the second disk. To avoid human error it is much better to use some kind of automations:
 prtvtoc /dev/rdsk/c0d0s2 > /tmp/c0d0s2.toc
 fmthard -s /tmp/c0d0s2.toc /dev/rdsk/c0d1s2
4. Then we should identify the partitions need to be mirrored:
 # egrep "ufs|swap" /etc/vfstab|grep "/dev/dsk"
 /dev/dsk/c0d0s1 -       -       swap    -       no      -
 /dev/dsk/c0d0s0 /dev/rdsk/c0d0s0        /       ufs     1       no      -


LVM

1. Let’s create few copies of metadb on the partitions we create for this puspose:
 # metadb -a -f -c 2 c0d0s7 c0d1s7
2. It’s time to put our disks where OS reside under management of SVM
 # metainit -f d10 1 1 c0d0s0
 d10: Concat/Stripe is setup
 # metainit -f d11 1 1 c0d0s1
 d11: Concat/Stripe is setup
 # metainit d0 -m d10
 d0: Mirror is setup
 # metainit d1 -m d11
 d1: Mirror is setup
 # metaroot d0 
3. Check newly created devices:
 # ls -l /dev/md/rdsk
 total 8
 lrwxrwxrwx   1 root     root          36 Aug 30 18:29 d0 -> ../../../devices/pseudo/md@0:0,0,raw
 lrwxrwxrwx   1 root     root          36 Aug 30 18:29 d1 -> ../../../devices/pseudo/md@0:0,1,raw
 lrwxrwxrwx   1 root     root          37 Aug 30 18:28 d10 -> ../../../devices/pseudo/md@0:0,10,raw
 lrwxrwxrwx   1 root     root          37 Aug 30 18:28 d11 -> ../../../devices/pseudo/md@0:0,11,raw
 # ls -l /dev/md/dsk
 total 8
 lrwxrwxrwx   1 root     root          36 Aug 30 18:29 d0 -> ../../../devices/pseudo/md@0:0,0,blk
 lrwxrwxrwx   1 root     root          36 Aug 30 18:29 d1 -> ../../../devices/pseudo/md@0:0,1,blk
 lrwxrwxrwx   1 root     root          37 Aug 30 18:28 d10 -> ../../../devices/pseudo/md@0:0,10,blk
 lrwxrwxrwx   1 root     root          37 Aug 30 18:28 d11 -> ../../../devices/pseudo/md@0:0,11,blk
4. Make appropriate changes in /etc/vfstab to get boot from mirror, not standard disks
 # egrep "ufs|swap" /etc/vfstab|grep "/dev/md/dsk"
 /dev/md/dsk/d1  -       -       swap    -       no      -
 /dev/md/dsk/d0  /dev/md/rdsk/d0 /       ufs     1       no      -
5. The next step is to flush cache buffers and reboot
 # sync;sync;sync
 # reboot
6. It is time to put second disk under management of SVN
 # metainit -f d20 1 1 c0d1s0
 d20: Concat/Stripe is setup
 # metainit -f d21 1 1 c0d1s1
 d21: Concat/Stripe is setup
7. And to add them to created previously mirrors. Be aware process of synchronisation will continue in background and you can check the process
 # metattach d0 d20
 d0: submirror d20 is attached
 # metattach d1 d21
 d1: submirror d21 is attached
8. Check the process of building mirrors and wait till they finnish
 # metastat
 d1: Mirror
     Submirror 0: d11
       State: Okay
     Submirror 1: d21
       State: Resyncing
     Resync in progress: 96 % done
     Pass: 1
     Read option: roundrobin (default)
     Write option: parallel (default)
     Size: 2104515 blocks (1.0 GB) 

 d11: Submirror of d1
     State: Okay
     Size: 2104515 blocks (1.0 GB)
     Stripe 0:
         Device   Start Block  Dbase        State Reloc Hot Spare
         c0d0s1          0     No            Okay   Yes 


 d21: Submirror of d1
     State: Resyncing
     Size: 2104515 blocks (1.0 GB)
     Stripe 0:
         Device   Start Block  Dbase        State Reloc Hot Spare
         c0d1s1          0     No            Okay   Yes
 

 d0: Mirror
     Submirror 0: d10
       State: Okay
     Submirror 1: d20
       State: Resyncing
     Resync in progress: 13 % done
     Pass: 1
     Read option: roundrobin (default)
     Write option: parallel (default)
     Size: 16787925 blocks (8.0 GB) 

 d10: Submirror of d0
     State: Okay
     Size: 16787925 blocks (8.0 GB)
     Stripe 0:
         Device   Start Block  Dbase        State Reloc Hot Spare
         c0d0s0          0     No            Okay   Yes


 d20: Submirror of d0
     State: Resyncing
     Size: 16787925 blocks (8.0 GB)
     Stripe 0:
         Device   Start Block  Dbase        State Reloc Hot Spare
         c0d1s0          0     No            Okay   Yes


 Device Relocation Information:
 Device   Reloc  Device ID
 c0d1   Yes      id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=01000000000000000001
 c0d0   Yes      id1,cmdk@AVMware_Virtual_IDE_Hard_Drive=00000000000000000001


Boot

1. Next step is to check if partition on second disk is active
 # fdisk /dev/rdsk/c0d1p0
             Total disk size is 1566 cylinders
             Cylinder size is 16065 (512 byte) blocks

                                               Cylinders
      Partition   Status    Type          Start   End   Length    %
      =========   ======    ============  =====   ===   ======   ===
          1       Active    Solaris2          1  1565    1565    100


 SELECT ONE OF THE FOLLOWING:
    1. Create a partition
    2. Specify the active partition
    3. Delete a partition
    4. Change between Solaris and Solaris2 Partition IDs
    5. Exit (update disk configuration and exit)
    6. Cancel (exit without updating disk configuration)
 Enter Selection: 5
2. And to add boot record to the second disk to make it bootable
 # /sbin/installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0d1s0
 stage1 written to partition 0 sector 0 (abs 16065)
 stage2 written to partition 0, 233 sectors starting at 50 (abs 16115)
3. Add new item in the boot menu (/boot/grub/menu.lst) to have alternative way to boot
 title Alternate boot
 root (hd1,0,a)
 kernel /platform/i86pc/multiboot
 module /platform/i86pc/boot_archive
4. Check if the new item is added to the boot menu
 # bootadm list-menu
 The location for the active GRUB menu is: /boot/grub/menu.lst
 default 0
 timeout 10
 0 Solaris 10 5/08 s10x_u5wos_10 X86
 1 Solaris failsafe
 2 Alternate boot
5. That’s all, you have already mirrored root partition (plus swap)


Conclusion

In the document are not mentioned all the options and possibilities of SVM, but only short set, need to done the work. For further information, please consult official Oracle documentation.

Sample configuration of DHCP server on Solaris

Preamble

This document is intended to show how to create DHCP server on Solaris using only command line tools. Of course exist GUI tool, named dhcpmgr, located in /usr/sadm/admin/bin directory, but first usually system administrators prefer and do they work via command line and second graphical environment can be inappropriate in some situations because of security, bandwidth or other reasons.


Installation

1. For our installation we will assume our domain is example.com and default gateway is 10.0.1.1
2. First step is to configure server itself, defining directory where the files will be located, type of repository (can be text files, binary files or NIS+ repository), lease time and default gateway. IN this example will be used domain example.com, text files as repository and leased time 2 days
# dhcpconfig -D -p /var/dhcp -r SUNWfiles -d example.com -l 172000 -a 10.0.1.1
Created DHCP configuration file.
Created dhcptab.
Added "Locale" macro to dhcptab.
Added server macro to dhcptab - sol3.
DHCP server started.
3. Next we should create network from where the IP addresses will be leased.
# pntadm -C 10.0.1.0
4. Just in case let check the list of configured networks
# pntadm -L
10.0.1.0
5. Lets put in repository addresses from 10.0.1.64 to 10.0.1.79 to be managed by DHCP server
# for i in `echo "echo 10.0.1.{64..79}"|bash`; do  pntadm -r SUNWfiles -p /var/dhcp -A $i 10.0.1.0; done
6. And check what the situation with addresses is.
# pntadm -P 10.0.1.0
Client ID       Flags   Client IP       Server IP       Lease Expiration                Macro           Comment
01000C2913E7E8  00      10.0.1.79       10.0.1.12       08/31/2008                      UNKNOWN
00              00      10.0.1.78       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.77       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.76       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.75       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.74       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.73       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.72       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.71       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.70       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.69       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.68       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.67       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.66       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.65       10.0.1.12       Zero                            UNKNOWN
00              00      10.0.1.64       10.0.1.12       Zero                            UNKNOWN
7. For our surprise someone already lease 10.0.1.79, so our server work


Conclusion

In the document are not mentioned many of the options of the user programs, but you can take a look in appropriate man pages, official SUN documentation and related papers

Sample NIS implementation on Solaris

Preamble

This document is intended to give idea about sample implementation of NIS. In the document will be used commands and files as they are in Solaris 10. For your flavour of UNIX or Linux refer to the documentation.


Implementation

1. We should set in the beginning the domain name of our new NIS domain. Here will be used domain name “example”, for your configuration, consult your infrastructure manager and documentation. With command domainname we can set the domain, but until next reboot, so better edit file /etc/defaultdomain and put in to the file the name of your domain. Be careful to set the same name as you enter in domainname command.
# domainname example
# domainname > /etc/defaultdomain
2. It’s very wise to define dedicated repository for NIS files instead of using original files of the machine. This can help in case of problems with NIS server and avoid potential risk, based on usage of the same root password on all NIS clients. And in some circumstances it’s good to have local users like sys, adm, mail, so we should exclude them from passwd file. For this purpose we will set up directory, named nisfiles and /etc look a fine container for the directory.
# mkdir /etc/nisfiles
3. Here is the example list of files to be copied in our NIS repository: auto_home auto_master bootparams ethers group hosts ipnodes netgroup netmasks networks passwd protocols rpc services shadow user_attr publickey timezone
4. Next step is to go in directory /var/yp and edit Makefile. Change the line DIR =/etc to be DIR =/etc/nisfiles and if need the line started with all: to define services will be served by NIS. The actual creation of map files can be done via command make or ypinit –m
# ypinit -m
In order for NIS to operate sucessfully, we have to construct a list of the
NIS servers.  Please continue to add the names for YP servers in order of
preference, one per line.  When you are done with the list, type a <control D>
or a return on a line by itself.
        next host to add:  sol1
        next host to add:  ^D
The current list of yp servers looks like this:
sol1
Is this correct?  [y/n: y]
Installing the YP database will require that you answer a few questions.
Questions will all be asked at the beginning of the procedure.
Do you want this procedure to quit on non-fatal errors? [y/n: n]
OK, please remember to go back and redo manually whatever fails.  If you
don't, some part of the system (perhaps the yp itself) won't work.
The yp domain directory is /var/yp/example
There will be no further questions. The remainder of the procedure should take
5 to 10 minutes.
Building /var/yp/example/ypservers...
Running /var/yp /Makefile...
updated passwd
updated group
updated hosts
updated ipnodes
updated networks
updated rpc
updated services
updated protocols
/var/yp/example/mail.aliases: 12 aliases, longest 10 bytes, 138 bytes total
/usr/lib/netsvc/yp/mkalias /var/yp/`domainname`/mail.aliases /var/yp/`domainname`/mail.byaddr;
updated aliases
updated publickey
updated netid
/usr/sbin/makedbm /etc/nisfiles/netmasks /var/yp/`domainname`/netmasks.byaddr;
updated netmasks
updated timezone
updated auto.master
updated auto.home
updated ageing
updated auth_attr
updated exec_attr
updated prof_attr
updated user_attr
updated audit_user
updated bootparams
updated ethers
updated netgroup
sol1 has been set up as a yp master server without any errors.
If there are running slave yp servers, run yppush now for any data bases
which have been changed.  If there are no running slaves, run ypinit on
those hosts which are to be slave servers.
5. Edit /var/yp/securenets to add networks, to be served by server. Record should look like
255.255.255.0  10.0.1.0
6. It’s time to start (restart) our NIS server and check if it running
# svcadm restart nis/server
# svcs -av|grep nis
disabled       -              7:25:29      - svc:/network/rpc/nisplus:default
disabled       -              7:25:30      - svc:/system/patch-finish:delete
online         -              8:16:53     96 svc:/network/nis/xfr:default
online         -              8:16:54     97 svc:/network/nis/passwd:default
online         -              8:16:54     99 svc:/network/nis/update:default
online         -              8:31:58    102 svc:/network/nis/client:default
online         -              8:36:49    103 svc:/network/nis/server:default
# ps -efl|grep yp
 0 S   daemon   149     1   0  40 20        ?   1075        ? 07:25:42 ?           0:00 /usr/lib/crypto/kcfd
 0 S     root  2404     1   0  40 20        ?   1289        ? 08:36:49 ?           0:00 /usr/lib/netsvc/yp/ypserv
 0 S     root  1429     1   0  40 20        ?   1302        ? 08:16:54 ?           0:00 /usr/lib/netsvc/yp/ypxfrd
 0 S     root  1443     1   0  40 20        ?    468        ? 08:16:54 ?           0:00 /usr/lib/netsvc/yp/rpc.ypupdated
 0 S     root  1436     1   0  40 20        ?   1288        ? 08:16:54 ?           0:00 /usr/lib/netsvc/yp/rpc.yppasswdd -m
 0 S     root  2390     1   0  40 20        ?    526        ? 08:31:58 ?           0:00 /usr/lib/netsvc/yp/ypbind
7. Then we should set your server as client. This is usual situation and only in special circumstances you should set one machine only as NIS server, but not client. When you configure other servers as clients do not forget to set /etc/defaultdomain and nsswitch.conf files
# ypinit -c
In order for NIS to operate sucessfully, we have to construct a list of the
NIS servers.  Please continue to add the names for YP servers in order of
preference, one per line.  When you are done with the list, type a <control D>
or a return on a line by itself.
        next host to add:  sol1
        next host to add:  ^D
The current list of yp servers looks like this:
sol1
Is this correct?  [y/n: y]
8. And now is time to check if everything works fine. There is in /etc/nisfiles/hosts record for host m1, but not in /etc/inet/hosts:
# getent hosts m1
10.0.1.51       m1
# ypcat hosts
127.0.0.1       localhost
10.0.1.10       sol1 loghost
10.0.1.53       m3
10.0.1.52       m2
10.0.1.51       m1


Conclusion

Of course this short document do not cover all aspects and details of NIS, so it is strictly recommended to read and understand the documentation for your OS and special notes, related to NIS client and server.

Quick guide for installation Glassfish on Solaris

Preamble

One of the tasks of UNIX/Linux administration is the installation of software. In this article we will discuss the installation of Glassfish - a Java application server from Oracle on the Solaris platform:-


Prerequisites

For the installation we will need Solaris OS installed and a JDK . For an example manual on how to install Solaris, see. In this example we will use JDBC connection to an Oracle database. For the Oracle client we could choose Instant Client or the full Installation, because, in our case, we will only need ojdbc14.jar to be in the Glassfish /lib directory. But I strictly recommend installing the full Oracle client, (Administrator), because there are a lot of helpful utilities such as sqlplus, tnsping which can help resolve oracle (and other) connectivity problems there. Also recommended is to install its own version of JDK (as described in the remarks here:  This will help you have a nonchangeable environment to run the application server. However it will add some system administration overhead. But it will increase the reliability of our environment.


Installation process

  1. Install Oracle client
    (below we assume the installation base is in /opt/oracle and the installation of the client is in the directory: /opt/oracle/product/10.2.0/client_1 and the version of Oracle client is 10.2)
  2. Create a user to run our application server:
    useradd -d /opt/Glassfish -k /etc/skel -m Glassfish
    Of course it is possible to run Glassfish as root, but for security reasons, the separation of duties and privileges is strictly recommended to run software under its own user. On the above command ignore the error, related to the length of the user name.
  3. Download and extract JDK for example in /etc/Glassfish/java
  4. Download Glassfish software and put the archive in /opt
    Do not forget to change ownership of the file and to remove it after installation
  5. Set the environment variables for Glassfish user:
    JAVA_HOME=/opt/Glassfish/java
    ORACLE_BASE=/opt/oracle
    ORACLE_HOME=${ORACLE_BASE}/product/10.2.0/client_1
    ORACLE_SID=ORCL
    LD_LIBRARY_PATH=${ORACLE_HOME}/lib:/lib:/usr/lib
    CLASSPATH=${ORACLE_HOME}/jre:${ORACLE_HOME}/jlib:${ORACLE_HOME}/rdbms/jlib
    ANT_HOME=/opt/Glassfish/lib/ant
    PATH=${JAVA_HOME}/bin:${ANT_HOME}/bin:$PATH
    export JAVA_HOME ORACLE_BASE ORACLE_HOME LD_LIBRARY_PATH CLASSPATH ANT_HOME PATH

  6. switch to Glassfish user
  7. run installation of Glassfish
    java -Xmx256m -jar Glassfish-installer-v2-b58g.jar
    (the name of Glassfish installation file is just an example, your may vary)
  8. go to Glassfish home directory
  9. add executable mode to ant
    chmod -R +x lib/ant/bin
  10. run ant to accomplish configuration of Glassfish
    lib/ant/bin/ant -f setup.xml
    (if server will be in cluster instead of setup.xml use setup-cluster.xml)
  11. Voila! You have installed the Glassfish Java application server

Prepare sample jumpstart server

Introduction

This guide is directed to create very sample JumpStart server for almost unattended installation of Solaris.


Steps

  1. Create directory where will be created image of CD or DVD for installation - /export/install
  2. Go to cdrom directory contain tools /cdrom/sol_10_606_x86/Solaris_10/Tools
  3. Run setup_install_server with parameter directory, created at point 1 - ./setup_install_server /export/install This process can take long time, but you can continue with the rest of process meanwhile
  4. Let's prepare file sysidcfg with answers of questions during installation for creating automatic installation
    • Create directory for storing configuration files /export/config
    • Create sysidcfg file, where netmask_value – usually this is netmask of the server i.e. Server and client are in the same network, gateway – just set the same default gateway as server (see above), for name_service set none. It's possible to define DNS, NIS, etc., but you can configure them later. For the timezone value, enter time zone for your location. Time zone files are located in directory tree below /usr/share/lib/zoneinfo. For me the zone is Europe/Sofia. Set locale value as you prefer. You can choose en_US.UTF-8 which is enough common for many purposes and do not interfere with not localized software. For the timeserver_IP value, enter the IP address of the system that will provide the time-of-day to the JumpStart client. This string (y5KqWP1EnT5Es) for root_password is hash of my password, you should set your
  5. Next step is to create rules and profile files for clients in the same directory
    • Sample rules file looks like(see examples), where hostname is keyword, c1 is just name of client, and p1 is filename of profile, applied to this client. First dash mean no pre-installation script, second dash mean no post-installation script
    • Create profile file, where install_type is actually type of installation :-), system_type is standalone (let's make thinks sample), partitioning is explicit to force repartitioning of disks, filesys describe filesystems to be created. In my case I use IDE harddisks, if you have SCSI, set in appropriate way. Cluster mean which cluster of packages to install. In my case - everything
    • Add record in /etc/inet/hosts for client (same host name as in rules file)
    • Add record in /etc/ethers in format (see ecamples)
    • Copy utility for checking if profile and rules files are ok: cp /export/install/Solaris_10/Misc/jumpstart_sample/check /export/config
    • run check utility: cd /export/config; ./check
    • everything is OK continue, otherwise correct the error and start program again
    • Run add_install_client (see examples), where -c is for place where rules and profile files reside, -p is for place where sysidcfg file next is hostname of client and at the end architecture of client
    • After this export config directory: share -o ro /export/config
    • For x86 installation you should create a grub floppy and edit GRUB menu to contain the following entry (see examples)
    • After this reboot client machine with this floppy and voila – you have installed Solaris over the network :-)


Examples

sysidcfg file:
network_interface=primary {protocol_ipv6=no
netmask=255.255.255.0
default_route=192.168.30.1}
security_policy=none
name_service=none
timezone=Europe/Sofia
system_locale=en_US.UTF-8
timeserver=192.168.30.1
root_password=y5KqWP1EnT5Es



sample profile file:
install_type initial_install
system_type standalone
partitioning explicit
filesys c0d0s0 free /
filesys c0d0s1 512 swap
cluster SUNWCXall



Grub entry:
title Solaris netinstall
rarp
kernel /I86PC.Solaris_10-1/multiboot kernel/unix -B install_media=192.168.30.2:/export/install
module /I86PC.Solaris_10-1/x86.miniroot



/etc/ethers in format:
MAC_ADDRESS hostname


Run add_install_client
./add_install_client -c t1:/export/config -p t1:/export/config t3 i86pc

Implement IPMP on Solaris

Preamble

This document is intended to give fast overview and sample way to implement IPMP on SUN Solaris. IPMP play very important role in SUN strategy to provide high availability in Solaris. Basic idea is to have IP address why “switch” between physical interfaces in case of fail of one of them

Prerequisites

1. To implement IPMP you need to have on the machine 2 NICs with unique MAC addresses
2. NICs in IPMP group should have same media type (i.e. Ethernet or ATM for example)
3. NICs should be be connected to the same switch or hub. In case of switch check if they are in same VLAN (if configured)
4. Loaded ip module to the interface
# ifconfig e1000g2 modlist
0 arp
1 ip
2 e1000g
5. If you do not have it execute
# ifconfig e1000g2 modinsert ip
6. Working gateway for IPs used in IPMP group

Setup

1. set in /etc/hostname.e1000g2 and /etc/hostname.e1000g3 the appropriate parameters for to attach interfaces to the group named test and set additional IP address
# cat /etc/hostname.e1000g2
sun3-2-1 netmask + broadcast + failover group test up addif sun3-2  netmask + broadcast + -failover deprecated  up
# cat /etc/hostname.e1000g3
sun3-2-2 netmask + broadcast + failover group test up
2. activate the interfaces
# ifconfig e1000g2 plumb
# ifconfig e1000g3 plumb
# ifconfig e1000g2 `cat /etc/hostname.e1000g2 `
Setting netmask of e1000g2 to 255.255.255.0
Created new logical interface e1000g2:1
Setting netmask of e1000g2:1 to 255.255.255.0
# ifconfig e1000g3 `cat /etc/hostname.e1000g3 `
Setting netmask of e1000g3 to 255.255.255.0
3. Check what's happen with interfaces and IPs
# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
e1000g1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.168.1.88 netmask ffffff00 broadcast 192.168.1.255
        ether 0:c:29:b2:8f:92
e1000g2: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 12
        inet 10.0.1.12 netmask ffffff00 broadcast 10.0.1.255
        groupname test
        ether 0:c:29:b2:8f:9c
e1000g2:1: flags=9040843<UP,BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPv4,NOFAILOVER> mtu 1500 index 12
        inet 10.0.1.32 netmask ffffff00 broadcast 10.0.1.255
e1000g3: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 10
        inet 10.0.1.22 netmask ffffff00 broadcast 10.0.1.255
        groupname test
        ether 0:c:29:b2:8f:b0


Final notes

Of course the above example give just very brief explanation and sample configuration. For more information take a look on the official Oracle  documentations.

Install Solaris from flash archive

Preamble

This document is created to show how to install Solaris OS from flash archive. This process is helpful in case of need to install many similar machines and/or speedup process of implementation of new system with all required software, patches, applications. Other purpose is to prepare fast recovery of important system(s) in DR plan.


Implementation

1. First step is to create repository for flash archive. For this purpose can be used a local filesystem or NFS share. Be aware that you need enough disk space to holding the archive.
# mkdir -p /export/flash
2. Next we should create flash archive of the system. This can be long process depend of amount of data on the system, speed of disks and processor(s). On average PC system it can take up to 30 minutes (or more)
# flarcreate -n flash_archive_root -c -R / -x /export/flash /export/flash/inst_x86
Full Flash
Checking integrity...
Integrity OK.
Running precreation scripts...
Precreation scripts done.
Determining the size of the archive...
5359636 blocks
The archive will be approximately 1.46GB.
Creating the archive...
5359636 blocks
Archive creation complete.
Running postcreation scripts...
Postcreation scripts done.
Running pre-exit scripts...
Pre-exit scripts done.
3. Let’s check the archive
# flar -i /export/flash/inst_x86
archive_id=3eb5bd4ed799d662b120834f7f4de81e
files_archived_method=cpio
creation_date=20080831081410
creation_master=sol2
content_name=flash_archive_root
creation_node=sol2
creation_hardware_class=i86pc
creation_platform=i86pc
creation_processor=i386
creation_release=5.10
creation_os_name=SunOS
creation_os_version=Generic_127128-11
files_compressed_method=compress
files_archived_size=1574745535
files_unarchived_size=2744133632
content_architectures=i86pc
4. For the purpose of install it’s need to export via NFS the directory, so check if NFS server is started and start if not and export directory
# svcs -va|grep nfs
online         -              8:52:09     45 svc:/network/nfs/cbd:default
online         -              8:52:09     46 svc:/network/nfs/status:default
online         -              8:52:09     47 svc:/network/nfs/mapid:default
online         -              8:52:10     49 svc:/network/nfs/nlockmgr:default
online         -              8:52:43      - svc:/network/nfs/rquota:default
online         -              8:52:43      - svc:/network/nfs/client:default
online         -             12:18:20    115 svc:/network/nfs/server:default 
# share -o ro /export/flash/
5. Then start new system, follow the installation process and at the moment of choose installation media select NFS, then enter the location of archive in form
server:/path/to/directory
and the choose the archive you will use or
server:/path/to/flash/archive
Wait a while and you have freshly installed copy of the system from which we create flash archive


Conclusion

Of course this document show only in brief steps to accomplish the task and do not go in deep in to the details, but give overview of the process. For further information about flash archives, installation process, NFS management, etc. refer to official SUN documentation and related papers.

Practical guide for minimalistic Solaris installation

Preamble

When you install Solaris (and any other UNIX/Linux) in generally there are 2 ways: make full install of all packages from media and install as little as possible. Each of the ways have pros and cons, but discussion about this is outside the theme of this text. This article is directed to create custom, minimalistic installation of Solaris 10. For security resons we will use ssh as “communication” way, for support of international charsets we will install en_US.UTF-8 codepage, but for compatibility will set the default language to C




Installation

We will start core installation and after this add the packages and clusters: SUNWCssh, SUNWladm, SUNWxcu6. Of course is possible to add the packages and clusters on time of the installation and get ssh key generation done on the time of first boot. But for demonstration we will do this work on “hard” way i.e. install packages and generate keys by hand. Do not forget to edit your /etc/ssh/sshd_config file to enable root logins via ssh. I know this can is security problem, but for tests is OK. As Software Group choose Core Group. Set disk map as follow
/ - 2048
/opt – 2048
swap - =RAM
/home – 64
The above disk layout is just example, for your installation follow rules, defined in your company or by policies from product you want to install later (for filesystems sizing take a look here: Suggestions_and_ideas_about_filesystem_sizing_on_Solaris)




Install additional packages (SUNWCssh, SUNWladm, SUNWxcu6)

Mount CDROM (DVDROM) and install package. Be aware the order is important.
mount –o ro –F hsfs /dev/dsk/c1t0d0s0 /mnt
cd /mnt/Solaris_10/Products
pkgadd –d . SUNWsshcu SUNWsshr SUNWsshu SUNWsshdr SUNWsshdu 
pkgadd –d . SUNWxcu4 SUNWxcu6
pkgadd –d . SUNWladm



Generate ssh server keys

cd /etc/ssh
ssh-keygen –t rsa –f ssh_host_rsa_key
ssh-keygen –t dsa –f ssh_host_dsa_key
svcadm enable ssh
In process of generation when ask for password just press enter. The length of the keys is 768 bits. Change it in case of need.




Install additional packages

pkgadd -d . SUNWctpls
pkgadd -d . SUNWmfrun
pkgadd -d . SUNWxwrtl
pkgadd -d . SUNWxwice
pkgadd -d . SUNWxwfnt
pkgadd -d . SUNWxwplr
pkgadd -d . SUNWxwplt
pkgadd -d . SUNWbtool
pkgadd -d . SUNWarc
pkgadd -d . SUNWhea
pkgadd -d . SUNWtoo
pkgadd -d . SUNWlibmr
pkgadd -d . SUNWlibm
pkgadd -d . SUNWlibms
pkgadd -d . SUNWsprot
pkgadd -d . SUNWi1of
pkgadd -d . SUNWi1cs
pkgadd -d . SUNWeurf
pkgadd -d . SUNWi15rf
pkgadd -d . SUNWi15cs
pkgadd -d . SUNWxwfnt
pkgadd -d . SUNWadmfr
pkgadd -d . SUNWadmc
pkgadd -d . SUNWadmfw
pkgadd -d . SUNWadmr
pkgadd -d . SUNWadmap
Part of the packages are need for i18n support, part are need for installing and running java, the rest are need for proper Oracle (database server/client) installation. Of course you can decide for self, but most of them are need for installation and running almost every additional software. Again be aware the order is important.



install java SDK packages

When you need java (JRE/JDK) you can install it on 2 different ways: from standard packages and download and install from Oracle site. If you need to track changes and patch it the simplest way is to use java, bundled in installation. But if you need to run some specific version for some software you can download it from Oracle site (see remark #1), copy it on special place (even under directory tree of the product and set JAVA_HOME and PATH variables.
pkgadd -d . SUNWj5rt
pkgadd -d . SUNWj5man
pkgadd -d . SUNWj5cfg
pkgadd -d . SUNWj5dev

 

Final notes

This article give you just start point. For your product maybe you will need additional packages. The advantage of this type of installation is you have less packages to care (change, patch) about, you get only 500 MB disk space of installation, you get only 30 processes (may vary) started and only 150 MB memory used (may vary too).




Remarks

1. On the Oracle Java site you can see two kind of packages: jdk-6u4-solaris-i586.sh and jdk-6u4-solaris-i586.tar.Z (names are just examples). Difference between them is the first archive (.sh) after agree with license create directory with java files you can move (directory) wherever you want (see listing).
# ls -l
drwxrwxr-x  10 root     root         687 Dec 14 15:08 jdk1.6.0_04
The second archive (tar.Z) create few directories, containing packages you can install with pkgadd program (see listing).
# ls -l
-r--r--r--   1 10       143         4140 Dec 14 17:15 COPYRIGHT
-r--r--r--   1 10       143        14097 Dec 14 17:15 LICENSE
-r--r--r--   1 10       143        28599 Dec 14 17:15 README.html
drwxr-xr-x   4 10       143          226 Dec 14 17:14 SUNWj6cfg
drwxr-xr-x   4 10       143          226 Dec 14 17:14 SUNWj6dev
drwxr-xr-x   4 10       143          226 Dec 14 17:14 SUNWj6dmo
drwxr-xr-x   4 10       143          226 Dec 14 17:14 SUNWj6jmp
drwxr-xr-x   4 10       143          226 Dec 14 17:14 SUNWj6man
drwxr-xr-x   4 10       143          226 Dec 14 17:14 SUNWj6rt
drwxrwxr-x   4 10       143          226 Dec 14 17:14 SUNWjavadb-client
drwxrwxr-x   4 10       143          226 Dec 14 17:14 SUNWjavadb-common
drwxrwxr-x   4 10       143          226 Dec 14 17:14 SUNWjavadb-core
drwxrwxr-x   4 10       143          226 Dec 14 17:14 SUNWjavadb-demo
drwxrwxr-x   4 10       143          226 Dec 14 17:14 SUNWjavadb-docs
drwxrwxr-x   4 10       143          226 Dec 14 17:14 SUNWjavadb-javadoc

How to create package in Solaris

For this example I will be use apache web server, compiled from source and created as package

Create directory structure for package. For me /usr/src sound's good, but you can do it using your home directory
 

# cd /usr/src
# mkdir RTNapache InfoPath

Create in InfoPath directory file pkginfo with content
 

ARCH=i386
CATEGORY=application
NAME=Apache httpd server
PKG=RTNapache
VERSION=2.2.4
DESC=The Apache Project is a collaborative software development effort 
aimed at creating a robust, commercial-grade, featureful, and 
freely-available source code implementation of an HTTP (Web) server.
VENDOR=Apache License Version 2.0, January 2004 http://www.apache.org/licenses/


- ARCH is architecture you build this package. Can be sparc, i386 or ppc
- CATEGORY describe with keywords in which category is the package
- NAME define brief name of our package
- PKG is the name of package. Here is interest the fact 1st 4 letters should be unique
- VERSION is the version of package. In this case this is the version of Apache httpd server
- DESC is extensive text about the package
- VENDOR describe the copyright of the package



Configure, compile and install the software on original place
 

# ./configure --prefix=/opt/RTNapache --enable-so –enable-mods-shared=most
# make
# make install
# cd /opt/RTNapache/
# mv  * /usr/src/RTNapache/
# cd ..
# rmdir RTNapache

Do some changes to be sure server will work fine
 

Change index.html in /usr/src/RTNapache/htdocs to represent the situation with compiled software
Change in /usr/src/RTNapache/conf/httpd.conf: 
- comment ServerAdmin line
- set ErrorLog to be /var/adm/httpd because /opt is not the proper place for log files
- set CustomLog to be /var/adm/httpd (same reason as above)
Change permition of /usr/src/RTNapache/htdocs to be 755 to let user daemon to read web server content
Change ownership of /usr/src/RTNapache to be root:root

Create in InfoPath directory file, named prototype. To make it by hand is very hard, so we will use tool, named pkgproto executing
 

# pkgproto ./RTNapache > InfoFiles/prototype

Add record to prototype file for creation of /var/adm/httpd directory
 

# echo "d none /var/adm/httpd 0644 root root" >> InfoFiles/prototype

Add record to prototype file with information about pkginfo file
 

# echo "i pkginfo=/usr/src/InfoFiles/pkginfo" >>InfoFiles/prototype

Create the package
 

#  pkgmk -f InfoFiles/prototype -b /usr/src

Let's get little info about this new package
 

# cd /var/spool/pkg
# pkginfo -d .
application RTNapache Apache httpd server

Now in directory /var/spool/pkg we get our package and we can pack it as tar, transfer somewhere and install

Play with soft partitions on Solaris part 4

Grow soft partition on the fly

1. Create random file and calculate checksum

# cd /oradata
# dd if=/dev/urandom of=file bs=1024 count=1024
1024+0 records in
1024+0 records out

# digest -a md5 file
f0252c61cab0d92ae0b91206af72f85d


2. Grow d51 partition by 1 GB and grow the filesystem

# metattach d51 1g
d51: Soft Partition has been grown
# growfs -M /oradata /dev/md/rdsk/d51
/dev/md/rdsk/d51:       8388608 sectors in 2048 cylinders of 128 tracks, 32 sectors
        4096.0MB in 82 cyl groups (25 c/g, 50.00MB/g, 8192 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 102464, 204896, 307328, 409760, 512192, 614624, 717056, 819488, 921920,
 7375136, 7477568, 7580000, 7682432, 7784864, 7887296, 7989728, 8092160,
 8194592, 8297024



3. See the mounted soft partitions and check if the file is the same

# df -k|grep md
/dev/md/dsk/d51      4109006    5145 4042237     1%    /oradata
/dev/md/dsk/d52      1488991    1521 1427911     1%    /oralogs
# digest -a md5 file
f0252c61cab0d92ae0b91206af72f85d




Conclusion

In few sample steps we create volumes and filesystems, grow it without disrupting normal work of the system and applications. This example show the power of Solaris Volume manager, but of course do not cover many of the options and details you will need in daily work. For more information about the subject is strictly recommended to read official SUN documentation and related papers.

Play with soft partitions on Solaris part 3

Creation of soft partitions

1. Create on soft partition of 3 gigabytes with name d51 and another with size 1.5G and name d52

# metainit d51 -p d5 3g
d51: Soft Partition is setup
# metainit d52 -p d5 1500m
d52: Soft Partition is setup



2. Check the status of d52 for example

# metastat d52
d52: Soft Partition
    Device: d5
    State: Okay
    Size: 3072000 blocks (1.5 GB)
        Extent              Start Block              Block count
             0                  6291520                  3072000

d5: RAID
    State: Okay
    Interlace: 32 blocks
    Size: 33091584 blocks (15 GB)
Original device:
    Size: 33094272 blocks (15 GB)
        Device     Start Block  Dbase        State Reloc  Hot Spare
        c1t0d0s0        330        No         Okay   Yes
        c1t1d0s0        330        No         Okay   Yes
        c1t2d0s0        330        No         Okay   Yes
        c1t3d0s0        330        No         Okay   Yes
        c1t4d0s0        330        No         Okay   Yes

Device Relocation Information:
Device   Reloc  Device ID
c1t0d0   Yes    id1,sd@SATA_____VBOX_HARDDISK____VB302359a4-9d8f686a
c1t1d0   Yes    id1,sd@SATA_____VBOX_HARDDISK____VB5a844d32-bae9afe7
c1t2d0   Yes    id1,sd@SATA_____VBOX_HARDDISK____VBb0b0a9e8-72b6d075
c1t3d0   Yes    id1,sd@SATA_____VBOX_HARDDISK____VBc7fe9534-5a7df964
c1t4d0   Yes    id1,sd@SATA_____VBOX_HARDDISK____VB09918bf7-59adb880



3. Create filesystems


# newfs /dev/md/rdsk/d51
Warning: setting rpm to 60
newfs: construct a new file system /dev/md/rdsk/d51: (y/n)? y
/dev/md/rdsk/d51:       6291456 sectors in 1536 cylinders of 128 tracks, 32 sectors
        3072.0MB in 62 cyl groups (25 c/g, 50.00MB/g, 8192 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 102464, 204896, 307328, 409760, 512192, 614624, 717056, 819488, 921920,
 5326496, 5428928, 5531360, 5633792, 5736224, 5838656, 5941088, 6043520,
 6145952, 6248384
 

# newfs /dev/md/rdsk/d52
Warning: setting rpm to 60
newfs: construct a new file system /dev/md/rdsk/d52: (y/n)? y
/dev/md/rdsk/d52:       3072000 sectors in 750 cylinders of 128 tracks, 32 sectors
        1500.0MB in 33 cyl groups (23 c/g, 46.00MB/g, 11264 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 94272, 188512, 282752, 376992, 471232, 565472, 659712, 753952, 848192,
 2167552, 2261792, 2356032, 2450272, 2544512, 2638752, 2732992, 2827232,
 2921472, 3015712



4. Then create mountpoints, mount filesystems and check the mount

# mkdir /oradata /oralogs
# mount /dev/md/dsk/d51 /oradata
# mount /dev/md/dsk/d52 /oralogs
# df -k|grep md
/dev/md/dsk/d51      3081231    3089 3016518     1%    /oradata
/dev/md/dsk/d52      1488991    1521 1427911     1%    /oralogs

Play with soft partitions on Solaris part 2

2. Create solaris partition on the disks
# fdisk -W /tmp/partition /dev/rdsk//c1t0d0p0
# fdisk -F /tmp/partition /dev/rdsk//c1t1d0p0
# fdisk -F /tmp/partition /dev/rdsk//c1t2d0p0
# fdisk -F /tmp/partition /dev/rdsk//c1t3d0p0
# fdisk -F /tmp/partition /dev/rdsk//c1t4d0p0



3. We will populate this disk map over the rest of the disks in automatic way to avoid human errors

# prtvtoc /dev/rdsk/c1t0d0s2 > /tmp/c1t0d0s2.toc
# fmthard -s /tmp/c1t0d0s2.toc /dev/rdsk/c1t1d0s2
fmthard:  New volume table of contents now in place
# fmthard -s /tmp/c1t0d0s2.toc /dev/rdsk/c1t2d0s2
fmthard:  New volume table of contents now in place
# fmthard -s /tmp/c1t0d0s2.toc /dev/rdsk/c1t3d0s2
fmthard:  New volume table of contents now in place
# fmthard -s /tmp/c1t0d0s2.toc /dev/rdsk/c1t4d0s2
fmthard:  New volume table of contents now in place


4. And create 2 copies of metadb on each of the 4 disks

# metadb -a -f -c 2 c1t0d0s7 c1t1d0s7 c1t2d0s7 c1t3d0s7 c1t4d0s7


5. Create RAID 5 array

# metainit d5 -r c1t0d0s0 c1t1d0s0 c1t2d0s0 c1t3d0s0 c1t4d0s0
d5: RAID is setup
6. And check the status of array
# metastat d5
d5: RAID
    State: Okay
    Interlace: 32 blocks
    Size: 33091584 blocks (15 GB)
Original device:
    Size: 33094272 blocks (15 GB)
        Device     Start Block  Dbase        State Reloc  Hot Spare
        c1t0d0s0        330        No         Okay   Yes
        c1t1d0s0        330        No         Okay   Yes
        c1t2d0s0        330        No         Okay   Yes
        c1t3d0s0        330        No         Okay   Yes
        c1t4d0s0        330        No         Okay   Yes

Device Relocation Information:
Device   Reloc  Device ID
c1t0d0   Yes    id1,sd@SATA_____VBOX_HARDDISK____VB302359a4-9d8f686a
c1t1d0   Yes    id1,sd@SATA_____VBOX_HARDDISK____VB5a844d32-bae9afe7
c1t2d0   Yes    id1,sd@SATA_____VBOX_HARDDISK____VBb0b0a9e8-72b6d075
c1t3d0   Yes    id1,sd@SATA_____VBOX_HARDDISK____VBc7fe9534-5a7df964
c1t4d0   Yes    id1,sd@SATA_____VBOX_HARDDISK____VB09918bf7-59adb880

Play with soft partitions on Solaris part 1

Preamble

This manual is directed to show with practical example how to use soft partitions under Solaris. The advantages of soft partitions compared to standard Solaris slices are possibility to create up to 8192 partitions compared to 7 in slices and grow on the fly the partitions without disrupting normal operations. Of course last one is true only in case of use filesystem over the soft partition, but this is usual situation, raw partitions are in use much rare. Example will be based on soft partitions reside over 5 harddisks, each with size of 4 GB, binded in RAID 5 array.

Prerequisites

1. First lets create partitions on the disks using s7 with size of 40 MB for metadb and s0 the rest for RAID 5 volume

bash-3.2# format
Searching for disks...
Inquiry failed for this logical diskdone


AVAILABLE DISK SELECTIONS:
       0. c0d0 <ATA    -VBOX HARDDISK  -1.0 cyl 4174 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
       1. c1t0d0 <ATA    -VBOX HARDDISK  -1.0  cyl 2045 alt 2 hd 128 sec 32>
          /pci@0,0/pci8086,2829@d/disk@0,0
       2. c1t1d0 <ATA    -VBOX HARDDISK  -1.0  cyl 2045 alt 2 hd 128 sec 32>
          /pci@0,0/pci8086,2829@d/disk@1,0
       3. c1t2d0 <ATA    -VBOX HARDDISK  -1.0  cyl 2045 alt 2 hd 128 sec 32>
          /pci@0,0/pci8086,2829@d/disk@2,0
       4. c1t3d0 <ATA    -VBOX HARDDISK  -1.0  cyl 2045 alt 2 hd 128 sec 32>
          /pci@0,0/pci8086,2829@d/disk@3,0
       5. c1t4d0 <ATA    -VBOX HARDDISK  -1.0  cyl 2045 alt 2 hd 128 sec 32>
          /pci@0,0/pci8086,2829@d/disk@4,0


We select disk 1 allocated on controller 1         
Specify disk (enter its number): 1
selecting c1t0d0
[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
        fdisk      - run the fdisk program
        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
        !<cmd>     - execute <cmd>, then return
        quit


Next step is to allocate the partition for Solaris on the disk       
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.
y

Enter in to the partition menu
format> pa


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
        !<cmd> - execute <cmd>, then return
        quit


Create huge slice with number 0 for the array
partition> 0
Part      Tag    Flag     Cylinders        Size            Blocks
  0 unassigned    wm       0               0         (0/0/0)          0

Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:
Enter new starting cyl[0]:1
Enter partition size[0b, 0c, 0e, 0.00mb, 0.00gb]: 2030


Allocate the rest of the diskspace in slice with number 7 for metadb

partition> 7
Part      Tag    Flag     Cylinders        Size            Blocks
  7 unassigned    wm       0               0         (0/0/0)          0

Enter partition id tag[unassigned]:
Enter partition permission flags[wm]:

Enter new starting cyl[0]:2031
Enter partition size[0b, 0c, 20e, 0.00mb, 0.00gb]: 2043e
Print the partition table

partition> p
Current partition table (unnamed):
Total disk cylinders available: 2044 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
  0 unassigned    wu       1 - 2030        3.96GB    (2030/0/0) 8314880
  1 unassigned    wu       0               0         (0/0/0)          0
  2     backup    wu       1 - 2044        3.99GB    (2044/0/0) 8372224
  3 unassigned    wu       0               0         (0/0/0)          0
  4 unassigned    wu       0               0         (0/0/0)          0
  5 unassigned    wu       0               0         (0/0/0)          0
  6 unassigned    wu       0               0         (0/0/0)          0
  7 unassigned    wu    2031 - 2043       26.00MB    (13/0/0)     53248
  8       boot    wu       0 -    0        2.00MB    (1/0/0)       4096
  9 unassigned    wu       0               0         (0/0/0)          0


And label and quit from format program 
partition> la
Ready to label disk, continue? y
partition> q


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
        fdisk      - run the fdisk program
        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
        !<cmd>     - execute <cmd>, then return
        quit
format> q

Creation of sample zone in Solaris for hosting apache, part 2

For next example let's create another zone, named apache2, but this time we will use apache server from Solaris and config file from previous zone

# cp /zones/apache-zone.cfg /zones/apache2-zone.cfg

  • edit file and change zonepath and IP address
  • next will use this config file to initialize new zone

# zonecfg -z apache2 -f /zones/apache2-zone.cfg
# zoneadm -z apache2 install
# zoneadm -z apache2 boot

  •     add own users w3 with group w3 and create and edit config file. Do not forget to change IP address apache will listen and /etc/hosts for FQDN of host

# cp /etc/apache2/httpd.conf-example /etc/apache2/httpd.conf
# groupadd w3
# useradd -g w3 w3


  •     create directory /var/run/apache2, because it do not exist, but it's need to keep apache pid file or make some changes in apache config file

mkdir -p /var/run/apache2


  •     start server and test if it's work

# /usr/apache2/bin/apachectl start
# ps -efl|grep http
0 S     root  4520  4062   0  50 20 dbbabae0    253 d6860820 09:44:33 pts/2       0:00 grep http
0 S       w3  4516  4513   0  40 20 dbbaaa20   1456 d5465384 09:44:23 ?           0:00 /usr/apache2/bin/httpd -k start
0 S     root  4513  3924   0  40 20 dbba9100   1421 d5ebbd16 09:44:22 ?           0:00 /usr/apache2/bin/httpd -k start
0 S       w3  4517  4513   0  40 20 e8df5ae8   1456 d5465384 09:44:23 ?           0:00 /usr/apache2/bin/httpd -k start
0 S       w3  4518  4513   0  40 20 e8df5288   1456 d5465384 09:44:23 ?           0:00 /usr/apache2/bin/httpd -k start
0 S       w3  4514  4513   0  40 20 e8df4a28   1456 d5465384 09:44:23 ?           0:00 /usr/apache2/bin/httpd -k start
0 S       w3  4515  4513   0  40 20 e8df41c8   1456 d5465384 09:44:23 ?           0:00 /usr/apache2/bin/httpd -k start

# telnet 192.168.30.101 80
Trying 192.168.30.101...
Connected to 192.168.30.101.
Escape character is '^]'.
get
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>501 Method Not Implemented</title>
</head><body>

Method Not Implemented

get to /index.html.en not supported.

<address>Apache/2.0.55 (Unix) DAV/2 Server at 192.168.30.101 Port 80</address>
</body></html>
Connection to 192.168.30.101 closed by foreign host.


    and now we have 2 zones and 2 different web servers

Creation of sample zone in Solaris for hosting apache, part 1

Let's use ZFS for storage of zones to help better disk management

zpool create -f zones c0d1
zfs create zones/apache
mount
 /zones on zones read/write/setuid/devices/exec/atime/dev.......
 /zones/apache on zones/apache read/write/setuid/devices/exec/atime/dev.......


Change the mode of directory because of need of zone management software

bash-3.00# chmod 700 /zones/apache
Create zone, named apache

bash-3.00# zonecfg -z apache
apache: No such zone configured

Use 'create' to begin configuring a new zone.

  •     we start with initial creation of zone

zonecfg:apache> create

  •     set the path where zone will reside

zonecfg:apache> set zonepath=/zones/apache

  •     set autoboot flag to boot when server boot

zonecfg:apache> set autoboot=true

  •     add network IP and physical interface. Do not forget to set netmask

zonecfg:apache> add net
zonecfg:apache:net> set address=192.168.30.100/24
zonecfg:apache:net> set physical=pcn0
zonecfg:apache:net> end


  •     add external directory /opt to be part of zone (just in case)

zonecfg:apache> add inherit-pkg-dir
zonecfg:apache:inherit-pkg-dir> set dir=/opt
zonecfg:apache:inherit-pkg-dir> end


  •     get the config info about the zone (on screen)

zonecfg:apache> info
zonepath: /zones/apache
autoboot: true
pool:
inherit-pkg-dir:
       dir: /lib
inherit-pkg-dir:
       dir: /platform
inherit-pkg-dir:
       dir: /sbin
inherit-pkg-dir:
       dir: /usr
inherit-pkg-dir:
       dir: /opt
net:
       address: 192.168.30.100/24
       physical: pcn0


  •     commit all the changes we made

zonecfg:apache> commit

  •     export the config for future usage or just for backup. Do not put it in /tmp, because on each boot this filesystem is purged

zonecfg:apache> export -f /zones/apache-zone.cfg

  •     and exit from the program

zonecfg:apache> exit

    Now let's install the software in zone (this operation will take a while)

bash-3.00# zoneadm -z apache install
Preparing to install zone <apache>.
Creating list of files to copy from the global zone.
Copying <2361> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <968> packages on the zone.
Initializing package <372> of <968>: percent complete: 38%......


    Little check of situation
  •     diskspace

bash-3.00# df -k /zones/apache/
Filesystem            kbytes    used   avail capacity  Mounted on
zones/apache         12321792   70034 12251635     1%    /zones/apache


  •     status of zones

bash-3.00# zoneadm list -v
 ID NAME             STATUS         PATH
  0 global           running        /


  •     boot our new zone

bash-3.00# zoneadm -z apache boot

  •     and check again zones status

bash-3.00# zoneadm list -v
 ID NAME             STATUS         PATH
  0 global           running        /
  2 apache           running        /zones/apache


    Some preparation tasks
  •     login in to the zone

bash-3.00# zlogin  apache
[Connected to zone 'apache' pts/2]
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005


  •     create some directories where we will place web server (we aware directories /lib, /opt, /platform, /sbin and /usr are mounted from global zone as readonly, but / (root) not so we put there our apache)

# mkdir -p /www/src

  •     copy the software (from other terminal :-)

bash-3.00# cd /zones/apache/root/www/src/
bash-3.00# cp /tmp/httpd-2.2.4.tar.gz .


  •     decompress and untar the archive (from with in zone)

# cd /www/src
# gzip -d httpd-2.2.4.tar.gz|tar
# tar xvf httpd-2.2.4.tar


  •     * configure and compile the software (its take a while)

# cd  httpd-2.2.4
# ./configure --prefix=/www --enable-so –enable-mods-shared=all

<cut long listing>

# make

<cut long listing>

# make test

`test' is up to date.

# make install

<cut long listing>


  •     create user to manage files

# groupadd w3
# useradd -g w3 w3
# chown -R w3:w3 /www/htdocs

  •     edit /www/conf/httpd.conf to change User and Group from daemon to w3
  •     edit /etc/hosts to add line like this

192.168.30.100 apache.example.net apache

    let's run the http server

# /www/bin/apachectl start
    check if the server is running
  •     check process

# ps -efl|grep htt
0 S       w3 22380 22377   0  40 20 d39c2008   1136 d54cfd5c 01:24:41 ?           0:00 /www/bin/httpd -k start
0 S       w3 22381 22377   0  40 20 d4e80940   1136 d54cfd5c 01:24:41 ?           0:00 /www/bin/httpd -k start
0 S       w3 22378 22377   0  40 20 d4e73270   1136 d54cfd5c 01:24:41 ?           0:00 /www/bin/httpd -k start
0 S       w3 22379 22377   0  40 20 d4e70890   1136 d54cfd5c 01:24:41 ?           0:00 /www/bin/httpd -k start
0 S     root 22377  5541   0  40 20 d4e70030   1103 d49abb16 01:24:40 ?           0:00 /www/bin/httpd -k start
0 S     root 22384 15053   1  50 20 d5182a18    253 d6880300 01:25:21 pts/2       0:00 grep htt
0 S       w3 22382 22377   0  40 20 d5181958   1136 d54cfd5c 01:24:41 ?           0:00 /www/bin/httpd -k start

  •     check service

# telnet 192.168.30.100 80
Trying 192.168.30.100...
Connected to 192.168.30.100.
Escape character is '^]'.
GET

<html><body>
It works!
</body></html>

Connection to 192.168.30.100 closed by foreign host.

So our apache is running and working :-)

Getting started using Solaris part 3

Examples

    Let's login in to the system:

$ ssh root@192.168.8.128 

Password: 
Last login: Mon Mar 31 11:39:29 2008 Sun Microsystems Inc. SunOS 5.11 snv_70b October 2007
#

    Next will be interest to check the user we are:

# id 
uid=0(root) gid=0(root)

    See where we are (path)

# pwd 
/

    Check the values of some variables

# echo $PATH "\n" $TERM 

/usr/sbin:/usr/bin 
cygwin

    set the value of variable TERM

# TERM=vt100;export TERM

    List the content of current directory

# ls -l 
total 346 
lrwxrwxrwx 1 root root 9 Nov 1 12:20 bin -> ./usr/bin 
drwxr-xr-x 6 root sys 512 Nov 1 13:00 boot 
drwxr-xr-x 2 root root 512 Nov 6 11:07 cdrom 
drwxr-xr-x 67 root sys 4096 Nov 1 13:31 dev 
drwxr-xr-x 2 root sys 512 Mar 31 11:38 devices 
drwxr-xr-x 91 root sys 4608 Mar 31 11:40 etc 
<SNIP> 
drwxr-xr-x 4 root root 512 Nov 1 12:20 system 
drwxrwxrwt 6 root sys 299 Mar 31 11:39 tmp 
drwxr-xr-x 38 root sys 1024 Nov 1 13:07 usr 
drwxr-xr-x 44 root sys 1024 Nov 5 14:35 var

    go to directory using absolute path and the relative path

# cd /var/adm 
# cd ../tmp 
# pwd 
/var/tmp

    examine the content of file

# cat /etc/nsswitch.conf
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
<SNIP>
passwd: files
group: files
hosts: files
dns # Added by DHCP
ipnodes: files
networks: files
protocols: files
netmasks: files
bootparams: files


    Let see the IP settings

# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
e1000g0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.0.2.10 netmask ffffff00 broadcast 10.0.2.255
        ether 8:0:27:13:f7:38



    and routing table

# netstat -rn

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface
-------------------- -------------------- ----- ----- ---------- ---------
default              10.0.2.2             UG        1          0
10.0.2.0             10.0.2.10            U         1          0 e1000g0
224.0.0.0            10.0.2.10            U         1          0 e1000g0
127.0.0.1            127.0.0.1            UH        1         40 lo0



    Get the list of opened ports

# netstat -a |grep LISTEN
      *.sunrpc             *.*                0      0 49152      0 LISTEN
      *.ssh                *.*                0      0 49152      0 LISTEN
<SNIP>
localhost.32807            *.*                0      0 49152      0 LISTEN
localhost.32808            *.*                0      0 49152      0 LISTEN
localhost.32809            *.*                0      0 49152      0 LISTEN
localhost.32810            *.*                0      0 49152      0 LISTEN
      *.ssh                             *.*                             0      0 49152      0 LISTEN
      *.32794                           *.*                             0      0 49152      0 LISTEN



    stop the sendmail (because we will not use this server for this purpose)

# svcadm disable sendmail

    and check again for daemon listening on port 25

# netstat -an|grep 25|grep tcp
#




Conclusion

Above you see only very brief overview of the functions, commands and details of Solaris operating system. If you need more indeep knowledge go to SUN doc site Solaris 10 Operating System, search for information, spread in Internet. check and apply for courses in your area, play with x86 version, using virtual machine, ask questions.

Compressed tar archive

There are some cases when you want to create compressed tar archive but you do not have enough disk space to keep original files and tar arc...