Thursday, August 21, 2008

MOUNTING ISO IMAGE UNDER SOLARIS/LINUX/AIX

Mounting ISO images on SOLARIS

To mount /local/sparc.iso file under /mnt directory.
Issue the following commands.

# lofiadm -a /local/sparc.iso /dev/lofi/1
# mount -F hsfs -o ro /dev/lofi/1 /mnt
to unmount
# umount /mnt
# lofiadm -d /dev/lofi/1

Mounting ISO images on LINUX
mount -o loop /path/to/file.iso /path/to/mount/point
Mounting ISO images on AIX

There is a known problem with mounting ISO images on the AIX platform. To workaround the problem, complete the following instructions:

  1. Obtain the size of the image.

    For example:

    # ls -al total 731594 drwxr-xr-x   2 root     system          512 Aug 18 11:33 . drwxr-xr-x   6 root     system          512 Aug 18 11:32 .. -rw-r--r--   1 root     system    374575104 Apr 29 02:59                                              fim_console_rios_aix_5.iso 
  2. Identify the nearest multiple of 128 MB that will provide enough space for the image. In the above example, the image is approximately 374 MB, so use 384 MB as an image size.

    Make a logical volume of this size. Ensure that there is enough space on the physical volume. For example, hdisk0.

    # mklv -y cdlv -s n -L /dev/cdlv rootvg 384M hdisk0

    If the command fails, increase the volume size by a multiple of 128.

  3. Use thedd command to create a pseudo-device. Ensure that the partition has enough space for the pseudo-device. In the following example command, the pseudo-device is /dev/cdlv.
    # dd if=/opt/software/iso/fim_console_rios_aix_5.iso of=/dev/cdlv

    Note that this command may take a long time and will create two dd processes.

  4. Mount the device like a CD-ROM in AIX. Ensure that the mount point exists.
    # mount -v cdrfs -o ro /dev/cdlv /mnt/iso
  5. Change directory into /mnt/iso.

OR

=> chfs: Changes attributes of a file system.
=> mount: Mount a file system
=> rmfs : Remove a file system

First Create a filesystem with crfs command:
#/usr/sbin/crfs -v jfs -g rootvg -a size=800 -m/cd1iso -Ano -pro -tno -a frag=4096 -a nbpi=4096 -a ag=8

This command creates the /cd1iso file system on the rootvg volume group.

Now dd the "iso" image into rlv00
# dd if=image.iso of=/dev/rlv00 bs=10M

Use chfs to change the attributes of a file system:
# chfs -a vfs=cdrom cd1iso
# mount /cd1iso
# cd /cd1iso

When done, remove the filesystem/unmount, enter:
# rmfs /cd1iso

This removes the /cd1iso file system, its entry in the /etc/filesystems (created using chfs command) file, and the underlying logical volume.

Monday, August 11, 2008

Determine if your OS is 64-bit or 32-bit?

Windows:
Run> msinfo32.exe

Windows

Click Start -> Run, and type dxdiag. If a Windows dialog box is displayed asking if you want to verify your drivers, you can safely click no and continue. When the program has finished loading, you should see something similar to one of the following images:
The Operating System line, refers to Windows x64 or 64-bit edition. The last window specifies the processor Itanium, which is a 64-bit processor.

Macintosh

You must be running Mac OS X 10.5 (Leopard) or newer and have a Core 2 Duo or G5 processor for 64-bit support.* To determine if your computer meets both requirements, select About This Mac from the Apple menu. A window will appear from which you can determine the version of Mac OS X and the processor type installed on your computer.
* A 64-bit version of Stata 10 for the Macintosh is expected to be available during the second half of 2008. An announcement will be made once it is available.

Unix (IBM-AIX, Sun Solaris)

  • IBM-AIX

    The getconf command will return the configuration of your machine. Since you are looking only for the kernel parameters, you should type
[cph@anna ~]$ getconf -a | grep KERN
KERNEL_BITMODE: 64
If that fails or does not return a result, try the file command.
[cph@anna ~]$ file /usr/lib/boot/unix*
/usr/lib/boot/unix: 64-bit XCOFF executable or object module not stripped
/usr/lib/boot/unix_64: 64-bit XCOFF executable or object module not stripped
/usr/lib/boot/unix_mp: executable (RISC System/6000) or object module not stripped
/usr/lib/boot/unix_up: executable (RISC System/6000) or object module not stripped
[cph@ozona ~]$ file /usr/lib/boot/unix*
/usr/lib/boot/unix: symbolic link to /usr/lib/boot/unix_up.
/usr/lib/boot/unix_kdb: executable (RISC System/6000) or object module not stripped
/usr/lib/boot/unix_up: executable (RISC System/6000) or object module not stripped
We can see that 'anna' is a 64-bit capable platform, and 'ozona' is only 32-bit.
Sun Solaris

eden:/home/cph: isainfo -v
64-bit sparcv9 applications
32-bit sparc applications
You can see that this Solaris machine is capable of running 32-bit as well as 64-bit applications. If isainfo fails, running a 64-bit application on your Sun will generally not be possible, unless of course isainfo is not in your path or has not been installed. You can also use the uname command to glean more information:
eden:/home/cph: uname -a
SunOS eden 5.8 Generic_108528-05 sun4u sparc SUNW,Ultra-5_10
lagrange:/usr/users/cph: uname -a
SunOS lagrange 5.5.1 Generic_103640-29 sun4u sparc SUNW,Ultra-1
How to check Solaris kernel on x86 (Intel) platform :
bash-3.00# uname –m
i86pc
bash-3.00# /usr/bin/isainfo -kv
32-bit i386 kernel modules

Linux

Linux users should type the uname command. Depending on the platform, you may see
[cph@gaylord ~]$ uname -a
Linux gaylord.stata.com 2.6.11-1.27_FC3 #1 Tue May 17 20:24:57 EDT 2005 x86_64 x86_64 x86_64 GNU/Linux
[cph@caddo ~]$ uname -a
Linux caddo.stata.com 2.6.9-5.0.5.EL #1 SMP Fri Apr 8 14:20:58 EDT 2005 ia64 ia64 ia64 GNU/Linux
[cph@tango ~]$ uname -a
Linux tango.stata.com 2.6.10-1.771_FC2smp #1 SMP Mon Mar 28 01:10:51 EST 2005 i686 i686 i386 GNU/Linux
In the above listing, 'gaylord' (x86_64 GNU/Linux) and 'caddo' (ia64 GNU/Linux) are 64-bit compliant. 'tango' (i386 GNU/Linux) is only a 32-bit platform

Different RUN levels in Linux,Solaris and AIX

RedHat Linux - Run Levels
0: Halt
1: Single user mode
2: Multiuser, without NFS
3: Full multiuser mode
4: Unused
5: X11
6: Reboot
Solaris - Run Level
S: Single user state (useful for recovery)
0: Access Sun Firmware ( ok> prompt)
1: System administrator mode
2: Multi-user w/o NFS
3: Multi-user with NFS ( default run level)
4: Unused
5: Completely shutdown the host (like performing a power-off @ OBP) [ thanks to Marco ]
6: Reboot but depend upon initdefault entry in /etc/inittab
AIX - Run Levels
0-1: Reserved for future use
2: Multiuser mode with NFS resources shared (default run level)
3-9: Defined according to the user's preferences
m,M,s,S: Single-user mode (maintenance level)
a,b,c: Starts processes assigned to the new run levels while leaving the existing processes at the current level running
Q,q: init command to reexamine the /etc/inittab file
Command to see Run level:-
$ who -r
Output:
. run-level 3 Mar 3 14:04 3 0 S
Solaris/Linux changing runlevels after bootup
You need to use init command, for example change runlevel to 2.
# /sbin/init 2
Solaris changing the default runlevel
An entry with initdefault (in /etc/inittab file) is scanned only when init is initially invoked. init uses this entry to determine which run level to enter initially.
Open /etc/inittab file:
# vi /etc/inittab
Find out this entry:
is:3:initdefault:
Change is:3 to number you want, don't use S, 0, 6 ;). Save file.

Renaming or moving a solaris host

Follow these steps to rename the system:
  • Change the name in /etc/nodename.
  • Change the name in /etc/hostname.xl0 (where xl0 is the name of your network interface)
  • Change the name in /etc/hosts.
  • /etc/dumpadm.conf
  • Move Crash Area
    mv /var/crash/OLDNAME /var/crash/NEWNAME
  • Run the command: hostname new_hostname
Moving to a New Network


Naming Services
Ensure your server has entries in naming services (such as DNS, NIS and LDAP) on the new network. Don't forget to remove the entries on the old network once the server has moved.

Disconnect from Old Network

IP Networking

  • Update IP address(es) in: /etc/hosts, /etc/inet/ipnodes(This is new in Solaris 10) and /etc/hostname.*.
  • Edit /etc/netmasks to reflect the new network.
  • Update the default router (gateway) in /etc/defaultrouter.
  • Update any static routes. You can view the current routing table with netstat -r.

DNS Resolver & Domain Configuration

The domain, name servers and domain searches path are all configured in /etc/resolv.conf. You also need to update /etc/defaultdomain if present (used by NIS, NIS+ and LDAP).

Network Time Configuration

If you use ntpd, you can update the time server in /etc/inet/ntp.conf.

Update Mail (MTA) Configuration

If you use a smarthost this is probably as simple as updating the DS line in /etc/mail/sendmail.cf (this file is generated, so you should update the template in /etc/mail/cf then regenerate it, rather than edit it directly). For more complex configurations refer to the Sendmail documentation: man sendmail.cf is a good start.

NFS Mounts

If your server automatically mounts network shares on other servers you should check they're available on the new network. If they're not, it's best to comment out references to them in /etc/vfstab.

Profile Configuration

You may have web proxies, CVS server roots etc. configured in profile files. It's a good idea to check /etc/.profile, /etc/skel and the profile files of any users.

Connect to New Network

Reboot the Server or Solaris 10 you can use: svcadm restart svc:/network/physical.
Once the server is up on the new network, you should test it thoroughly and ensure monitoring systems can see it

Reboot the server or do the following if you are on console-

OR--
bash-2.05# ifconfig ce0(interface) down
bash-2.05# ifconfig ce0 10.129.0.48 netmask 255.255.0.0
bash-2.05# ifconfig ce0 up

Saturday, August 9, 2008

Replacing Mirrored Root disk in Solaris

1. Collect output from the following:

# metastat

# metastat -p

# metadb –i

2. To identify the disk to be replaced:

Examine the "metadb -i" output. You should see a "W" in the flags field associated with slice 7 of the disk experiencing write errors. Another indication is to look at the output from the “format” command.

For this example, we will assume the failed disk device is c1t0d0 and c1t1d0 is the good mirror

3. Delete any metadevice state database replicas that are on the 'bad' disk:

# metadb -d c1t0d0s4

# metadb -i (to make sure they have been deleted)

4. State of the submirrors:

The “metastat” command output reports that all submirrors on the bad disk are at a State of “Needs maintenance”. This indicates that DiskSuite has automatically disabled the submirrors, so there is no need to “metadetach” the submirrors.

Note : if you see any replica in OK state. Then we need to detach the submirror first ( with metaclear/ metadetach )

5. Physically replace the failed hot-swappable disk.

6. Partition the new disk: Easiest way to do this is to copy the partition table from the root mirror (c1t1d0s2) to the new disk

(c0t0d0s2) with the following dd command: ( I would prefer to take a back up of

# dd if=/dev/rdsk/c1t1d0s2 of=/dev/rdsk/c1t0d0s2 count=16

# dd if=/dev/rdsk/(original good disk slice 2) of=/dev/rdsk/( new replaced disk slice 2) count=16

OR

USE prtvtoc /dev/dsk/c1t1d0s2 | fmthard -s - /dev/rdsk/c1t0d0s2

Verify the partition table was copied correctly using the format utility. Type "format", select the corresponding disk number from the disk selection menu, then type "p", then "p" again to view the partition table. Compare and make sure the partition tables match EXACTLY.

7. Run newfs on all the newly created slice and then fsck to verify every thins is ok )

8. Recreate the metadevice state database replicas that were deleted in step 3 from c0t0d0s7:

# metadb -a -f -c 3 /dev/dsk/c1t0d0s4

# metadb -i (verify the creation)

9. Re-enable the submirrors:

# metareplace –e d0 c1t0d0s0 (d0 is / and c1t0d0s0 is device associated w/ d10 submirror)

# metareplace –e d1 c1t0d0s0 (d1 is /swap and c1t0d0s1 is device associated w/ d11 submirror)

# metareplace –e d3 c1t0d0s0 (d3 is /var and c1t0d0s0 is device associated w/ d13 submirror)

# metareplace –e d6 c1t0d0s0 (d6 is /usr and c1t0d0s0 is device associated w/ d16 submirror)

# metareplace –e d7 c1t0d0s0 (d7 is /local and c1t0d0s0 is device associated w/ d17 submirror)

10. Run metastat | grep sync to check if disks are in sync.

Issue I faced:

1> /swap file system was showing under Maintenance even after metareplace ran successfully and I was not able detach the submirror. Then I used #metaclear d1 to clear all the submirror and recreated the mirror and worked fine.

system diagnostic commands (Sun Solaris)

Diagnostic Command - (Sun Solaris)
by Jeff Hunter, Sr. Database Administrator
prtdiag
Use the following command to obtain detailed diagnostics information about your system configuration and hardware state :
# /usr/platform/`uname -i`/sbin/prtdiag -v
 
It will display you:
System Configuration: Sun Microsystems  sun4u 
Memory size: 1.75GB
CPU details , I/O devices
Memory Configuration 
usb Devices 
keyboard      mouse
Environmental Status Fan Speeds:
HW Revisions 
System PROM revisions:
----------------------
OBP 4.6.5 2002/06/03 16:49
POST 2.0.1 2001/08/23 17:13
prtconf
Use the following command to obtain detailed system information about your Sun Solaris installation:
# /usr/sbin/prtconf
 
System Configuration:  Sun Microsystems  sun4u
Memory size: --Megabytes
System Peripherals (Software Nodes):
# uptime
uptime reports load averages over 1-, 5- and 15-minute intervals. Typically, load averages are divided by the number of CPU cores to find the load per CPU. Load averages above 1 per CPU indicate that the CPUs are fully utilized. A general rule of thumb is that load averages that are persistently above 4 times the number of CPUs will result in sluggish performance.
# prstatmL è Solaris 10 allows us to directly monitor the amount of time threads wait for a processor via the prstat -mL command in the LAT category
# psrinfo –v èwill provide the number of CPU and there speed

Disk I/O Components

# iostat

If a disk is more than 60% busy over sustained periods of time, this can indicate overuse of that resource. The %b iostat statistic provides a reasonable measure for utilization of regular disk resources

HD info(vendor, RPM, capacity)

# iostat –E ( it will show you the disk space size and serial number.)
The DTrace Toolkit provides a way to directly measure disk utilization via the iotop -CP command.

Disk Errors


iostat -eE reports on disk error counts since the last reboot. Keep in mind that several types of events (such as ejecting a CD or some volume manager operations) are counted in this output. Once these error messages rise above 10 in any category, further investigation is warranted.

PORT enable / disable

vi /etc/inetd.conf

MOUNT ISO IMAGE UNDER SOLARIS .


To mount /root/sparc.iso file under /mnt directory.
issue the following commands.

# lofiadm -a /root/sparc.iso /dev/lofi/1
# mount -F hsfs -o ro /dev/lofi/1 /mnt
to unmount
# umount /mnt
# lofiadm -d /dev/lofi/1

Note: lofi = loopback file driver

To break lock on NIS server

#imp tsaini [/var/etc] >lockadm -f netgroup -b RCS

Ilom Alom Break
you are connected to the console
alom odr ilom ? standard at the t2210 is the newer ilom
where its like
set /HOST send_break_action=break
and then
start /SP/console
to enter the console
To change the DISPLAY setting in solaris.
To see your current settings and the possible settings...
# fbconfig -prconf
To change it:
# fbconfig -res video-mode -depth 8or24
Memory usuage by process

Display processes with the highest CPU utilization

# ps -eo pid,pcpu,args | sort +1n
# ps aux
ps command reports a snapshot on information of the current active processes. Advantage of ps command is that system admins will be able to see where the memory is used.
To see only the memory resources occupied by each category of processes, such as Apache httpd, MySQL mysqld or Java, use the following command:
# ps aux | awk '{print $4"\t"$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' | sort –nr
Sorting the output
#top
* M : sorts the output by memory usage. Pretty handy for figuring out which version of openoffice.org to kill.
* P : sorts the process by the percentage of cpu time they are using.
* T : sorts by cumulative cpu time used
* A : sorts by age of the process, newest process first
Using split and cat to help edit large files.
 
# That's 10Mb
split -b 10000000 filename.txt
# makes xaa  xab  xac  xad  xae  xaf ...
# grep for what you want, edit that file with emacs
cat xaa  xab  xac  xad  xae  xaf > new1.txt
# Using wildcards with cat seems to work fine too: 
cat x?? > new2.txt
Checking whether it's running in 32-bit mode or 64-bit mode

64-bit mode

% isalist -v 
sparcv9+vis sparcv9 sparcv8plus+vis sparcv8plus sparcv8 sparcv8-fsmuld sparcv7 sparc
% isainfo -v
64-bit sparcv9 applications
32-bit sparc applications

32-bit mode

% isalist -v 
sparcv8plus+vis sparcv8plus sparcv8 sparcv8-fsmuld sparcv7 sparc
% isainfo -v
32-bit sparc applications
 
print the version of OBP
% prtconf -V
OBP 3.3.2 1996/06/28 08:43
% /usr/platform/`uname -i`/sbin/prtdiag -v | grep OBP
OBP 3.11.1 1997/12/03 15:53   POST 3.11.4 1997/05/27 02:26
%
{2} ok .version
Release 3.23 Version 1 created 1999/07/16 12:08
OBP 3.23.1 1999/07/16 12:08
POST 2.0.2 1998/10/19 10:46
{2} ok 
 

print the version of Open Windows

% showrev -w
OpenWindows version: 
OpenWindows Version 3.6.1 25 January 1999

Examining gcc behavior

% gcc -v -x c /dev/null

Display the version of CDE

% /usr/ccs/bin/what /usr/dt/bin/dtmail
/usr/dt/bin/dtmail:
        CDE Version 1.3.4
        CDEVersion1.3.4
To find out top 10 largest file/directories is taking up the most space in a /var directory/file system:
# du -a /var | sort -n -r | head -n 10
If you want more human readable output try:
# du -ha /var | sort -n -r | head -n 10
find / -size +2000 -exec ls -s {} \; | sort -nr | more
find and delete files form specific date-
/usr/bin/find /local/ftp/pub/[Aa]lgo* -type f -mtime +14 -ls -exec /usr/bin/rm -f {} \; > /tmp/cleanftp.algo.cron.log.`/usr/bin/date +\%a` 2>&1

Installing and configuring Lock and RCS scritp

  • Install RCS package form Sun freeware. “rcs-5.7-sol10-sparc-local”
  • Install following pkg’s
    • libgcc-3.4.6-sol10-sparc-local
    • tcl-8.5.3-sol10-sparc-local
    • libgcc-3.3-sol10-sparc-local
    • expect-5.43.0-sol10-sparc-local
copy lock, lock.exc, lockadm under /usr/bin
chown bin:bin /usr/bin/lock*
# cd /var/etc/
# mkdir RCS
// Put make.conf under revision control
# ci -i make.conf
RCS/make.conf,v <-- make.conf
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>> make.conf - custom settings for portage
>> .
initial revision: 1.1
done
// The file is now in RCS, so put it back in /etc for reading
# co make.conf
Notice that make.conf is now under revision control and is read-only. To edit the file, you need to perform the following steps:
Code Listing 2: Editing a file under revision control
// Checkout the file with locking enabled
# co -l make.conf
RCS/make.conf,v --> make.conf
revision 1.1 (locked)
done
// Edit the file
# ${EDITOR} make.conf
// Check the file back in and unlock it.
# ci -u make.conf ( some time we use this command to unlock the file locked by root)
RCS/make.conf,v <-- make.conf
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single '.' or end of file:
>> changed DISTDIR to use a drive with more space
>> . done
ci(1) and co(1)
ci(1) and co(1) are the commands used to check files in and out of their RCS archives. The ci(1) command may also be used to a check a file both in and out of an archive. In their simplest forms, ci(1) and co(1) take only the name of the working file.
ci name_of_work_file
and
co name_of_work_file
The command form
ci -l name_of_work_file
checks in the file with locking enabled, and
co -l name_of_work_file
is performed automatically. That is, ci -l checks the file out again with locking enabled.
ci -u name_of_work_file
checks the file into the archive, and checks it out again with locking disabled. In all cases, the user is prompted for a log message.
ci(1) will also create a RCS archive if one does not exist already.
bash-3.00# /usr/local/bin/rlog aliases
RCS file: RCS/aliases,v
Working file: aliases
head: 1.6
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 6; selected revisions: 6
description:
Aliases file
----------------------------
revision 1.6
date: 2008/07/16 21:00:44; author: tsaini; state: Exp; lines: +0 -1
Removed the entry for tsaini
----------------------------
revision 1.5
date: 2008/07/16 15:29:31; author: tsaini; state: Exp; lines: +1 -1
*** empty log message ***
----------------------------
revision 1.4
date: 2008/07/15 21:50:58; author: hbanwait; state: Exp; lines: +1 -1
*** empty log message ***
=============================================================================
bash-3.00#

Viewing Previous Versions of a File

RCS keeps track of all revisions of a file. You can view a previous version, say version 1.6, of a file (named FILE) by checking out the old version and redirecting it to standard output.
bash-3.00# /usr/local/bin/co -p -r1.5 RCS/aliases,v
You can see the differences between revisions with the rcsdiff command. This example shows the differences between version 1.5 and 1.6.
bash-3.00# /usr/local/bin/rcsdiff -r1.6 -r1.5 RCS/aliases,v
===================================================================
RCS file: RCS/aliases,v
retrieving revision 1.6
retrieving revision 1.5
diff -r1.6 -r1.5
3833a3834
> riskmapper: tsaini
bash-3.00#

Now we can use Lock script to lock the file and edit it. Lock script is customized script to work with rcs.
Lockadm to mange the files.
bash-3.00# lockadm -f ypservers -a -u tsaini
RCS file: RCS/ypservers,v
done
bash-3.00# lockadm -f ypservers -l
The following users are on the access list for ypservers:
tsaini
bash-3.00# lockadm -f ypservers –l
or if you do # lock filename it will ask you to put that file in RCS