Friday, April 17, 2009

Unix Basics and Overview

Unix Basics and Overview

System initialization and boot management

System initialization and boot management
The numeric 1 key (F1 on graphical display), when pressed during POST (double beep), starts the SMS interface.
The numeric 5 key (F5 on graphical display), when pressed during POST, initiates a system boot in service mode using the default service mode boot list. Sequence:
1. diskette (if installed)
2. CD-ROM (if installed)
3. hard disk
4. tape drive (if installed)
5. network (a. Token ring, b. Ethernet)

The numeric 6 key (F6 on graphical display) works like the numeric 5 key, but uses the customized service mode bootlist. This is the preferred method of loading AIX diagnostics from the boot hard disk.


ipl_varyon * Used to vary on the root volume group during system boot processing.


ipl_varyon -i : Inquiry mode - skips ipl device processing. Checks which disks are already bootable.


bosboot

Creates boot image. It does not update the bootlist in the NVRAM.
bosboot -a -d /dev/hdisk0 : Re-create boot image on hdisk0.
bosboot -a -d /dev/ipldevice -D : creates a boot image with the KDB debugger enabled.


mklv
Creates a logical volume.
mklv -y hd5 -t boot rootvg 1 : re-create boot LV (BLV) hd5.


lslv
Displays information about a logical volume.
lslv -l hd5 : determines the boot disk.


mkboot
Creates the boot image, the boot record, and the service record.
mkboot -c -d /dev/hdisk0 : clears the boot record of PV hdisk0.


chpv
Changes the characteristics of a physical volume in a volume group.
chpv -c hdisk1 : clears the boot record of PV hdisk1.


bootinfo Determines and displays various boot information, including boot device type and boot device name (NOT supported in AIX 4.2 or later).
bootinfo -b : returns the last boot device.
bootinfo -B hdisk0 : returns 1 if disk is bootable, 0 if not.


bootlist
Displays or alters the list or ordering of boot devices available to the system.
Normal boot list: possible boot devices for normal mode.
Service boot list: possible boot devices for service mode.
Previous boot device: last device from which the system booted.
Support of these boot lists is model dependent.
bootlist -m normal -o : displays the normal boot list.
bootlist -m service -o : displays the service boot list (if available).
bootlist -m normal cd0 hdisk0 hdisk1 : makes changes to the normal boot list.
bootlist -m prevboot : invalidates the last device from which the system booted.


halt or fasthalt
Writes data to disk (sync) and then stops the system. The system does not restart. Do not use this command if other users are logged into the system.


reboot or fastboot
Restarts the system. Can be used if no other users are logged into the system.


shutdown
Halts the operating system. Checks the existence of the executable /etc/rc.shutdown file (added by the administrator) that specifies all the applications and other user processes to close down.
By default the shutdown command powers down the system (if supported and issued).
shutdown -Fr : fast system shutdown and restart.
shutdown -m +1 : brings the system down to maintenance (single user) mode after waiting one minute.
shutdown -l : logs the output during the shutdown to /etc/shutdown.log.


last
Displays information about previous logins using the /var/adm/wtmp file.
last reboot : displays the time between reboots.
last shutdown : lists last shutdowns of the system.


uptime
Shows how long the system has been up.
uptime : displays the current time, the length of time the system has been up, the number of users online, and the load average.


sync
Updates the i-node table and writes buffered files to the hard disk.
sync;sync;sync;reboot : writes everything from the buffer to the hard disk and reboots the system.


lsfont
Lists the fonts available for use by the display.


chfont
Changes the default font selected at boot time.


mkfont
Adds the font code associated with a display to the system.


mkfontdir
Creates a fonts.dir file from a directory of font files.


chlang
Sets LANG environment variable in the /etc/environment file for next login.


chtz
Changes the system time zone information in the /etc/environment file.


chhwkbd
Changes the low-function terminal (LFT) keyboard attributes stored in the Object Data Manager (ODM) database.


lskbd
Lists the keyboard maps currently available to the low-function terminal (LFT) subsystem.


chkbd
Changes the default keyboard map used by the low-function terminal (LFT) at system startup.


chkey
Changes your encryption key.


lslicense
Displays the number of fixed licenses and the status of floating licensing. There are two types of user licensing, fixed and floating. Fixed licensing is always enabled. Floating licensing can be enabled or disabled.
lslicense -A : displays the number of available fixed licences on the system.


chlicense
Changes the number of fixed licenses and the status of the floating licensing (updates login.cfg).
chlicense -I -u 50I -u 50 : changes the fixed license number immediately to 50 (without rebooting).
chlicense -f on : enables the floating licensing.


lsitabLists records in the /etc/inittab file.


chitab
Changes records in the /etc/inittab file.


mkitab
Adds records to the /etc/inittab file.


rmitab
Removes records from the /etc/inittab file.


telinit or init
Initializes and controls processes.
0-9 Tells the init process to put the system in one of the run levels 0-9. S,s,M,m Tells the init process to enter the maintenance mode. a,b,c Tells the init process to examine only those records in the /etc/inittab file with a, b, or c in the run-level field. Q,q Tells the init process to re-examine the entire /etc/inittab file. N Sends a signal that stops processes from being respawned.
telinit q : requests the init command to re-examine the /etc/inittab file.


who

Identifies the users currently logged in.

Identify Runlevel

who -r : displays the runlevel.

who /var/adm/wtmp : displays a history of logins, logouts, system startups, and system shutdowns.



restbase

Restores customized information from the boot image. Attention: The command is executed only during system boot phase 1. Do not execute it in a run-time environment.


savebase
Saves base customized device data in the ODM onto the boot device.
savebase -d /dev/hdisk0 : save the ODM to the boot logical volume.

IBM AIX - Red Books

Click the following link to access AIX Redbooks: IBM AIX - RedBooks

Wednesday, April 15, 2009

AIX - System installation and maintenance management

oslevel
Reports the latest installed maintenance level of the system.
oslevel -r : determines the highest recommended maintenance level reached for the current version of AIX.
oslevel -lr 5100-04: lists which fileset updates are missing if after installing ML 04 on 5100-03 the command oslevel -r still shows 5100-03.

alog
Creates and maintains fixed-size log files.
alog -o -t boot : view the boot log (the log that holds boot information).
alog -L : lists the logs defined in the alog database.

errpt
Generates a report of logged errors in the system error log.
errpt -a : displays a complete detailed report.
errpt -c > /dev/console : formats and displays each of the errors at logtime (concurrent error logging) on /dev/console.

errdemon
Starts the error logging daemon errdemon that reads error records from the /dev/error file and creates error log entries in the default system error log /var/adm/ras/errlog.
/usr/lib/errdemon : starts the error logging daemon.
/usr/lib/errdemon -l : displays the path to the system error log file and error log size.
/usr/lib/errdemon -s 2000000 : changes the maximum size of the error log file to 2 MB.

syslogd
The syslogd daemon logs messages from kernel, daemons and system applications using /etc/syslog.conf.
*.debug errlog (add this line to to syslog.conf to redirect all syslog messages to the system error log).
stopsrc -s syslogd : stops the syslogd daemon.
startsrc -s syslogd : starts the syslogd daemon.
refresh -s syslogd : refreshes the syslogd daemon.

errlogger
Logs an operator message.
errlogger new disk added on scsi1 adapter : logs "new disk added on scsi1 adapter" in the system error log.

errclear
Deletes entries from the system error log. Software and operator errors (older than 30 days) and hardware errors (older than 90 days) are removed using crontab.
errinstall
Installs or replaces messages in the error logging message sets of the error log message catalog.

errupdate
Updates the Error Record Template Repository (default file /var/adm/ras/errtmplt).

diag
Menu driven program to run a wide choice of tasks and service aids (diagnostics, hardware error report, format, microcode and bootlist management, ...).
Diagnostics modes:
Concurrent mode: diag is used during normal operation (only devices not in use can be tested).
Single-user mode: run diag after shutdown -m.
Stand-alone mode: boot from Diagnostics CD (press F5 when acoustic beep is heard)
or boot and press F6 when acoustic beep is heard to load diag from hard disk.
if diag returns "diag is not supported on this model" use:
SMS mode: boot and press F1 when acoustic beep is heard, select "test the computer". Some older models use a SMS diskette.

alt_disk_install
Installs an alternate disk with a mksysb install image or clones the currently running system to an alternate disk.
Note: install bos.alt_disk_install fileset to use alt_disk_install.
alt_disk_install -C hdisk2 : Clones the current rootvg to hdisk2.
alt_disk_install -C -b update_all -l /dev/cd0 hdisk4 : Creates clone of the current rootvg on hdisk4, installs a ML on the clone and changes the bootlist to hdisk4.
alt_disk_install -X old_rootvg : Removes the original rootvg from the ODM, after booting from the new alternate disk (you can still reboot from old_rootvg).

nimadm
Performs Alternate Disk Migration (to a new version or release) of AIX using NIM resources.
nimadm -c aix1 -s spot2 -l lpp2 -d "hdisk1 hdisk2" -Y : migrates totarget NIM client aix1, using NIM SPOT resource spot2, the NIM lpp_source lpp2, and hdisk1 and hdisk2 target disks, and agreeing to all required software license agreements for the software being installed (-Y).
nim -o alt_disk_install -a source=rootvg -a disk='hdisk2' -a phase=12 holland : clones a rootvg on client holland to hdisk1, but only run phase1 and phase2 (leaving the /alt_inst file systems mounted).

AIX - Problem Determination

sysdumpdev

Changes the primary or secondary dump device designation in a running system. The default primary dump device is LV /dev/hd6 and the default secondary dump device is /dev/sysdumpnull. A dedicated primary dump device LV /dev/lg_dumplv is created (if sufficient disk space is available) in systems with at least 4 Gigabytes of real memory.

sysdumpdev -l : displays current dump device settings.
sysdumpdev -P -p /dev/hd7 : changes the primary dump device permanently from the default to LV /dev/hd7.
sysdumpdev -e : estimates the dump size (in bytes) for the current running system.
sysdumpdev -L : displays statistical information about the last dump.
chdev -l sys0 -a autostart=true : automatically reboot after a crash (default is false).

dumpcheck
Checks the disk resources used by the system dump and logs in the system error log. Run default by cron at 3:00 pm local time each day.
/usr/lib/ras/dumpcheck -p : requests a dumpcheck. The result is printed to stdout (-p).
/usr/lib/ras/dumpcheck -r : discontinues running dumpcheck (removes the crontab entry).

kdb
Displays system images for examining a dump.
kdb /var/adm/ras/vmcore.0 /unix : starts kdb using the uncompressed dump file /var/adm/ras/vmcore.0 and kernel file /unix.

snap
Gathers system configuration information and compresses the information into a pax file.

snap -a -o /dev/rmt0 : gathers all system configuration information (needs approximately 8 MB space in directory /tmp/ibmsupt) and creates a compressed pax image (snap.pax.Z) of directory /tmp/ibmsupt.

snapcore
Gathers the core file, program, and libraries used by a program to directory /tmp/snapcore (default) and compresses the information into a pax image. The collected information allows debugging and resolving problems within an application.

snapcore -d /tmp/snapcore2 core.xx : gathers all needed information for core dump file core.xx and writes it to directory /tmp/snapcore2/snapcore_32811.pax.Z, where 32811 is the process id ($pid) of the snapcore command.
uncompress -c snapcore_32811.pax.Z | pax : displays the contents of the pax archive.
check_core

Used by snapcore to gather all information about a core dump. The bos.rte.serv_aid fileset must be installed.
/usr/lib/ras/check_core core.xx : displays a list containing the program that caused core dump core.xx and the used libraries.

shconf
Manages the system hang detection parameters for the system hang daemon shdaemon.
shconf -d : displays if priority problem detection and lost I/O detection are enabled or not.
shconf -E -l prio -H : displays the current shdaemon settings.

Wednesday, March 25, 2009

Logical Volume Manager - LVM

Add, change, and delete:
Volume groups

Logical volumes

Physical volumes

Describe mirroring

Describe striping

Logical Volume Manager

# smit lvm

Logical Volume Manager

Move cursor to desired item and press Enter.

Volume Groups
Logical Volumes
Physical Volumes
Paging Space

F1=Help F2=Refresh F3=Cancel F8=Image
F9=Shell F10=Exit Enter=Do


Volume Groups

Physical Volume (PV)
-Hard disk

Volume Group (VG)
-Collection of related disks (PVs)

SMIT Volume Groups Menu

# smit vg

Volume Groups
Move cursor to desired item and press Enter.

-List All Volume Groups
-Add a Volume Group
-Set Characteristics of a Volume Group
-List Contents of a Volume Group
-Remove a Volume Group
-Activate a Volume Group
-Deactivate a Volume Group
-Import a Volume Group
-Export a Volume Group
-Mirror a Volume Group
-Unmirror a Volume Group
-Synchronize LVM Mirrors
-Back Up a Volume Group
-Remake a Volume Group
-Preview Information about a Backup
-Verify the Readability of a Backup (Tape only)
-View the Backup Log
-List Files in a Volume Group Backup
-Restore Files in a Volume Group Backup

F1=Help F2=Refresh F3=Cancel F8=Image
F9=Shell F10=Exit Enter=Do


List All Volume Groups
# lsvg
rootvg
payrollvg
# lsvg -o
rootvg

List Volume Group Contents

# lsvg rootvg

VOLUME GROUP: rootvg VG IDENTIFIER: 000bc6fd00004c00000000e10fdd7f52
VG STATE: active PP SIZE: 16 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 1084 (17344 megabytes)
MAX LVs: 256 FREE PPs: 1032 (16512 megabytes)
LVs: 11 USED PPs: 52 (832 megabytes)
OPEN LVs: 10 QUORUM: 2
TOTAL PVs: 2 VG DESCRIPTORS: 3
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 2 AUTO ON: yes
MAX PPs per VG: 32512
MAX PPs per PV: 1016 MAX PVs: 32
LTG size (Dynamic): 256 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable

List Volume Group Information (Physical Volumes)
# lsvg -p rootvg
rootvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk0 active 159 52 24..00..00..00..28
hdisk1 active 159 78 32..02..00..12..32

List Volume Group Information (Logical Volumes)
# lsvg -l rootvg
rootvg:
LVNAME TYPE LPs PPs PVs LV STATE MOUNT POINT
hd6 paging 8 8 1 open/syncd N/A
hd5 boot 1 1 1 closed/syncd N/A
hd8 jfslog 1 1 1 open/syncd N/A
hd9var jfs 1 1 1 open/syncd /var
hd4 jfs 1 1 1 open/syncd /
hd2 jfs 77 77 1 open/syncd /usr
hd3 jfs 3 3 1 open/syncd /tmp
hd1 jfs 11 11 1 open/syncd /home
hd10opt jfs 2 2 1 open/syncd /opt
lv00 jfs2 1 2 2 open/syncd /home/john
lv01 jfs2 4 4 2 open/syncd /home/fred