Thursday, November 29, 2007

perl: our vs use vars

B.6.5. The vars Pragma
In the rare case that you truly need a global variable while use strict is in effect, you may declare it with the vars pragma.[407] This package-scoped pragma tells Perl that you are intentionally using one or more global variables:

If your program will never be used with a version of Perl prior to 5.6, you should use the our keyword instead of the vars pragma.
use strict;
use vars qw/ $fred $barney /;

$fred = "This is a global variable, but that's all right.\n";


31.21. use vars

use vars qw($frobbed @munge %seen);

This pragma, once used to declare a global variable, is now somewhat deprecated in favor of the our modifier. The previous declaration is better accomplished using:

our($frobbed, @munge, %seen);

or even:
our $frobbed = "F";
our @munge = "A" .. $frobbed;
our %seen = ();

No matter which of these you use, remember that they're talking about package globals, not file-scoped lexicals.



8.232. vars

Pragma that, given a list of variable names, predeclares all variables in the list, making sure they are available to routines with delayed loading (e.g., routines loaded by the AutoLoader or SelfLoader). This allows you to use the variables under use strict. The vars pragma also disables warnings about typographical errors.
use vars qw($var1 @var2 %var3);

perl: special vars

$EVAL_ERROR
$@


The currently raised exception or the Perl syntax error message from the last eval operation. (Mnemonic: where was the syntax error "at"?)
Unlike $! ($OS_ERROR), which is set on failure but not cleared on success, $@ is guaranteed to be set (to a true value) if the last eval had a compilation error or run-time exception, and guaranteed to be cleared (to a false value) if no such problem occurred. Warning messages are not collected in this variable. You can, however, set up a routine to process warnings by setting $SIG{__WARN__} as described later in this section. Note that the value of $@ may be an exception object rather than a string. If so, you can still probably treat it as a string if the exception object has stringification overloading defined for its class. If you propagate an exception by saying: die if $@; then an exception object will call $@->PROPAGATE to see what to do. (A string exception merely adds a "propagated at" line to the string.)



$!
$OS_ERROR
$ERRNO

If used in a numeric context, yields the current value of the errno variable, identifying the last system call error. If used in a string context, yields the corresponding system error string.



$@
$EVAL_ERROR

The Perl syntax error message from the last eval command.

Tuesday, May 22, 2007

excel: locate duplicates by using conditional formatting

Set up the first conditional formatting formula



I'll start by setting up a conditional format for the first data cell.

Later, I'll copy that conditional format for the whole range.



In my example, cell A1 contains

a

column heading (Invoice), so I will select cell A2, and then click Conditional Formatting

on the Format

menu. The Conditional Formatting dialog box opens.

The first box contains the text,

Cell Value Is. If you click the arrow next to this box, you can choose Formula Is.



Example





After you click

Formula Is, the dialog box changes appearance. Instead of boxes for between x and y,

there is now a single formula box. This formula box is incredibly

powerful. You can use it to enter any formula that you can dream up, as

long as that formula will evaluate to TRUE or FALSE.





In this case, we need to use a COUNTIF formula. The formula to type in the box is:





=COUNTIF(A:A,A2)>1


This formula says: Look through the entire

range of column A. Count how many cells in that range have the same

value as cell A2. Then, compare to see if that count is greater than 1.



When there are no duplicates, the count will always be 1; because

cell A2 is in the range, we should find exactly one cell in column A

that contains the same value as A2.



Note  In this formula, A2 represents the current

cell — that is, the cell for which you are setting up the conditional

format. So, if your data is in column E and you are setting up the

first conditional format in cell E5, the formula would be =COUNTIF(E:E,E5)>1.





Choose a color to highlight duplicated entries







Now it is time to select an obnoxious (that is, obvious) format to identify any duplicates that are found. In the Conditional Formatting dialog box, click the Format button.



Example



Click the Patterns tab and click a bright color swatch, like red or yellow. Then click OK to close the Format Cells dialog box.



Example





You will see the selected format in the preview box. Click OK to close the Conditional Formatting dialog box, and…



Example



Nothing happens. Wow. If this is your first time setting up

conditional formatting, it would be really nice to get some feedback

here that it worked. But, unless you are lucky enough that the data in

cell A2 is a duplicate of the data in some other cell, the condition is

FALSE and no formatting is applied.



Copy the conditional formatting to the rest of the cells



You need to copy the conditional formatting from cell A2 down to the

other cells in your range. With the cursor sill in A2, click Copy on the Edit menu. Press CTRL+Spacebar to select the entire column. Then click

Paste Special on the Edit menu. In the Paste Special dialog, click Formats, and then click OK.



Example





This will copy the conditional formatting to all cells in the column.

Now — finally — you may see some cells with the colored fill

formatting, indicating that you have a duplicate.





It is informative to go to cell A3 and look at the conditional formula

(after you've copied it from A2). Select cell A3 and click

Conditional Formatting

on the Format menu. The formula in the Formula Is box has changed to count how many times the data in cell A3 appears in column A.



Example



You can have up to 65536 cells with conditional formatting, each

cell comparing the current cell to 65535 other cells. Technically, the

formula in the first step could have been =COUNTIF($A$2:$A$1751,A2)>1.





Also, when copying the conditional format to the entire column, you could have selected just the cells

that contained data before using the Paste Special command.

Source

Monday, May 14, 2007

linux: a closer look at the boot sequence

The firmware and software programs output various messages as the computer and Linux come to life. These notes attempt to help clarify what routines and devices are doing.

Craig Van Degrift / KanjiFlash@CompuServe.com / revised December 8, 1999



1. The Motherboard BIOS Triggers the Video Display Card BIOS Initialization


The Matrox Millennium adapter BIOS sends the following to the screen:


MATROX POWER GRAPHICS ACCELERATOR
MGA Series

VGA/VBE BIOS, Version V2.2
Copyright (C) 1995, Matrox Graphic, Inc.
Copyright (C), LSI Logic Corporation, Inc. 1990-1991


The screen is cleared.



2. Motherboard BIOS Initializes Itself


The Motherboard BIOS sends the following to the screen:


*Award Modular BIOS  v4.60PGA, An Energy Star Ally
Copyright (C) 1984-98, Award Software, Inc.
Version 1.15JE33

Cyrix M II/IBM 6x86MX-233 CPU Found

Memory Test: 131072K OK

Award Plug and Play BIOS Extension v1.0A
Copyright (C) 1998, Award Software, Inc.



Press DEL to enter SETUP

11/19/1998 - VP3 - 536B - W877 - 2A5LEF09C - 00


The screen is cleared.



3. SCSI Controller BIOS Initializes



The SCSI controller BIOS sends the following to the screen:

Adaptec AHA-2940 Ultra/Ultra W BIOS v 1.23
(c) 1996 Adaptec, Inc. All Rights Reserved.

<<< Press  for SCSISelect(TM)


SCSI ID:LUNNUMBER #:# 0:0 - MICROP  3243-19 1128RQAV - Drive C: (80h)
SCSI ID:LUNNUMBER #:# 1:0 - SEAGATE ST51080N         - Drive D: (81h)
SCSI ID:LUNNUMBER #:# 2:0 - HP      C2520A
SCSI ID:LUNNUMBER #:# 5:0 - Sony    CD-R-625



Bios installed successfully!


The screen is cleared.


4. Hardware Summary


The motherboard BIOS then displays the following summary of its hardware inventory:


Award Software, Inc.
________________________________________________________________________
|
| CPU Type     : Cyrix M II/IBM 6x86MX     Base Memory    :      640K  |
| Co-Processor : Installed                 Extended Memory:   130048K  |
| CPU Clock    : 233                       Cache Memory   :     1024K  |
________________________________________________________________________
|
| Diskette Drive A: 1.44M, 3.5 in.        Display Type       : EGA/VGA |
| Diskette Drive B: 1.44M, 3.5 in.        Serial Port(s)     : 3F8 2F8 |
| Pri. Master Disk: None                  Parallel Port(s)   : 278     |
| Pri. Slave Disk : None                  Bank 0/1 DRAM Type : None    |
| Sec. Master Disk: None                  Bank 2/3 DRAM Type : EDO     |
| Sec. Slave Disk : None                  Bank 4/5 DRAM Type : EDO     |
_______________________________________________________________________

And Runs its Virus checking code that looks for changed boot sectors.


!!!! Trend ChipAwayVirus On Guard !!!! Now Detecting Boot Sector Type Virus... ChipAwayVirus BIOS Version 1.62 Verifying DMI Pool Data....... The screen is cleared.


5. OS/2 BootManager Menu


The Master Boot Record (MBR) on the first hard disk is read, by DOS tradition, into address 0x00007c00, and the processor starts executing instructions there.

This MBR boot code loads the first sector of code on the active DOS partition. In my case this is the OS/2 BootManager which displays the following menu of OS choices:


________________________________________________________________________
|                                                                      |
|                            Boot Manager                              |
________________________________________________________________________
|
|    DOS 7.1       Disk 1    C:Primary     408M        FAT             |
|    OS2Warp4      Disk 1    E:Logical    2573M        HPFS            |
|    TinyWarp      Disk 1    F:Logical     142M        HPFS            |
|    BigLinux      Disk 2      Logical    1020M        Type 83         |
|                                                                      |
________________________________________________________________________
|                                                                      |
| Timer Disabled, a timeout boot will not occur                        |
|                                                                      |
| Use ^ or V to select.  Press Enter to boot.                          |
________________________________________________________________________


6. Lilo is started


If the BigLinux selection is chosen and if Linux has been installed with Lilo, Lilo is loaded into address 0x00007c00.

Lilo prints

LILO
with its progress revealed by individually printing the letters. The first "L" is printed after Lilo moves itself to a better location at 0x0009A000. The "I" is printed just before it starts its secondary boot loader code.

Lilo's secondary boot loader prints the next "L", loads descriptors pointing to parts of the kernel, and then prints the final "O". The descriptors are placed at 0x0009d200.

The boot message and a prompt line, if specified, are printed. The pressing "Tab" at the prompt, allows the user to specify a system and to provide command-line specifications to the Linux Kernel, its drivers, and the "init" program. Also, environment variables may be defined at this point.


The following line is from /boot/message:
>>> Press  to list available boot image labels.


The following line is the prompt from /sbin/lilo:
boot:


Note: If Lilo is not used, then the boot code built into the head of the Linux kernel, linux/arch/i386/boot/bootsect.S prints "Loading" and continues.


Lilo displays the following as it loads the kernel code. It gets the text "Linux-2.2.12" from the "label=..." specification in lilo.conf.
Loading linux-2.2.12.......... 


7. The Linux Kernel Initializes


The kernel code in /linux/arch/i386/boot/setup.S arranges the transition from the processor running in real mode (DOS mode) to protected mode (full 32-bit mode). Blocks of code named Trampoline.S and Trampoline32.S help with the transition. Small kernel images (zImage) are decompressed and loaded at 0x00010000. Large kernel images (bzImage) are loaded instead at 0x00100000. This code sets up the registers, decompresses the compressed kernel (which has linux/arch/i386/head.S at its start), printing the following 2 lines from linux/arch/i386/boot/compressed/misc.c


Uncompressing Linux... Ok. Booting the kernel.

The i386-specific setup.S code has now completed its job and it jumps to 0x00010000 (or 0x00100000) to start the generic Linux kernel code.



7. Processor, Console, and Memory Initialization


This runs linux/arch/i386/head.S which in turn jumps to start_kernel(void) in linux/init/main.c where the interrupts are redefined.

linux/kernel/module.c then loads the drivers for the console and pci bus.

From this point on the kernel messages are also saved in memory and available using /bin/dmesg. They are then usually transferred to /var/log/message for a permanent record. The following line is from linux/init/version.c:

Linux version 2.2.12 (root@Baldy) (gcc version 2.8.1) #1 Thu Nov 4 19:44:40 PST 1999

Detected 187547890 Hz processor.



console_init(..) in linux/init/main.c causes the following line from linux/drivers/console.c to be printed:

Console: colour VGA+ 132x60


calibrate_delay() in linux/init/main.c prints the following line:
Calibrating delay loop... 187.19 BogoMIPS



mem_init() in linux/init/main.c causes the following line from linux/arch/i386/mm/init.c to be printed:

Memory: 127952k/131008k available (952k kernel code, 412k reserved, 1652k data, 40k init)



buffer_init() in linux/init/main.c causes the following line from linux/arch/i386/mm/fault.c to be printed:

Checking if this processor honours the WP bit even in supervisor mode... Ok.



check_bugs() in /linux/init/main.c causes the following lines from linux/include/asm-i386/bugs.h to be printed:

CPU: Cyrix M II 2.5x Core/Bus Clock stepping 08

Checking 386/387 coupling... OK, FPU using exception 16 error reporting.

Checking 'hlt' instruction... OK.

POSIX conformance testing by UNIFIX

mtrr: v1.35a (19990819) Richard Gooch (rgooch@atnf.csiro.au)


8. PCI Bus Initialization


mpci_init() in linux/init/main.c causes the following lines from linux/arch/i386/kernel/bios32.c to be printed:

PCI: PCI BIOS revision 2.10 entry at 0xfb2d0

PCI: Using configuration type 1


pci_init() in linux/init/main.c causes the following line from linux/drivers/pci/pci.c to be printed:

PCI: Probing PCI hardware


linux/drivers/quirks.c prints the following:

PCI: 00:38 [1106/0586]: Work around ISA DMA hangs (00)

Activating ISA DMA hang workarounds.



9. Network Initialization


socket_init() in linux/init/main.c causes the following network initializations:

linux/net/socket.c prints:

Linux NET4.0 for Linux 2.2

Based upon Swansea University Computer Society NET3.039


linux/net/unix/af_unix.c prints:

NET4: Unix domain sockets 1.0 for Linux NET4.0.


linux/net/ipv4/af_inet.c prints:

NET4: Linux TCP/IP 1.0 for NET4.0

IP Protocols: ICMP, UDP, TCP


linux/net/ipv4/ip_gre.c prints:

GRE over IPv4 tunneling driver


linux/net/core/dev.c prints:

early initialization of device gre0 is deferred


linux/net/core/rtnetlink.c prints:

Initializing RT netlink socket


10. The Kernel Idle Thread (Process 0) is Started


At this point a kernel thread is started running init() which is one of the routines defined in linux/init/main.c. This init() must not be confused with the program /sbin/init that will be run after the Linux kernel is up and running. mkswapd_setup() in linux/init/main.c causes the following line from linux/mm/vmscan.c to be printed:

Starting kswapd v 1.5


11. Device Driver Initialization


The kernel routine linux/arch/i386/kernel/setup.c then initializes devices and file systems (built into the kernel??). It produces the following lines and then forks to run /sbin/init:

Generic Parallel Port Initialization
The parallel port initialization routine linux/drivers/misc/parport_pc.c prints the following:

parport0: PC-style at 0x378 [SPP,PS2,EPP]


Character Device Initializations



The following 3 lines are from linux/drivers/char/serial.c:


Serial driver version 4.27 with no serial options enabled

ttyS00 at 0x03f8 (irq = 4) is a 16550A

ttyS01 at 0x02f8 (irq = 3) is a 16550A


The following line is from linux/drivers/char/lp.c:

lp0: using parport0 (polling).



linux/drivers/char/rtc.c prints:

Real Time Clock Driver v1.09

Block Device Initializations

linux/drivers/block/rd.c prints:

RAM disk driver initialized:  16 RAM disks of 8192K size


linux/drivers/block/loop.c prints:


loop: registered device at major 7


linux/drivers/block/floppy.c prints:


Floppy drive(s): fd0 is 1.44M, fd1 is 1.44M

FDC 0 is a post-1991 82077


SCSI Bus Initialization
The following lines are from aic7xxx.c, scsi.c, sg.c, sd.c or sr.c in the subdirectory linux/drivers/scsi:


(scsi0)  found at PCI 9/0
(scsi0) Wide Channel, SCSI ID=7, 16/255 SCBs
(scsi0) Warning - detected auto-termination
(scsi0) Please verify driver detected settings are correct.
(scsi0) If not, then please properly set the device termination
(scsi0) in the Adaptec SCSI BIOS by hitting CTRL-A when prompted
(scsi0) during machine bootup.
(scsi0) Cables present (Int-50 YES, Int-68 NO, Ext-68 YES)
(scsi0) Downloading sequencer code... 413 instructions downloaded
scsi0 : Adaptec AHA274x/284x/294x (EISA/VLB/PCI-Fast SCSI) 5.1.19/3.2.4

scsi : 1 host.

(scsi0:0:0:0) Synchronous at 20.0 Mbyte/sec, offset 8.

Vendor: MICROP    Model: 3243-19 1128RQAV  Rev: RQAV
Type:   Direct-Access                      ANSI SCSI revision: 02
Detected scsi disk sda at scsi0, channel 0, id 0, lun 0

(scsi0:0:1:0) Synchronous at 10.0 Mbyte/sec, offset 15.

Vendor: SEAGATE   Model: ST51080N          Rev: 0958
Type:   Direct-Access                      ANSI SCSI revision: 02
Detected scsi disk sdb at scsi0, channel 0, id 1, lun 0

Vendor: HP        Model: C2520A            Rev: 3503
Type:   Processor                          ANSI SCSI revision: 02
Detected scsi generic sgc at scsi0, channel 0, id 2, lun 0

(scsi0:0:6:0) Synchronous at 5.0 Mbyte/sec, offset 15.

Vendor: SONY      Model: CD-R   CDU926S    Rev: 1.1f
Type:   CD-ROM                             ANSI SCSI revision: 02
Detected scsi CD-ROM sr0 at scsi0, channel 0, id 6, lun 0

scsi : detected 1 SCSI cdrom 2 SCSI disks total.

sr0: scsi3-mmc drive: 0x/0x caddy

Uniform CDROM driver Revision: 2.55

SCSI device sda: hdwr sector= 512 bytes. Sectors= 8388315 [4095 MB] [4.1 GB]
SCSI device sdb: hdwr sector= 512 bytes. Sectors= 2109840 [1030 MB] [1.0 GB]


12. Initialization of Kernel Support for Point-to-Point Protocol


The following initialization is done by linux/drivers/net/ppp.c which prints:
PPP: version 2.3.7 (demand dialling)

TCP compression code copyright 1989 Regents of the University of California

PPP line discipline registered.


13. Examination of Fixed Disk Arrangement


The following lines are from linux/drivers/block/genhd.c:


Partition check:

sda: sda1 < sda5 sda6 sda7 > sda2 sda3 sda4

sdb: sdb1 < sdb5 > sdb2

VFS: Mounted root (ext2 filesystem) readonly.

Freeing unused kernel memory: 40k freed


This is the end of the messages saved in the kernel and available by using /bin/dmesg.

14. Init Program (Process 1) Startup


The program /sbin/init is started by the "idle" process (Process 0) code in linux/init/main.c and becomes process 1. /sbin/init then completes the initialization by running scripts and forking additional processes as specified in /etc/inittab. It starts by printing:


INIT: version 2.76 booting

and reads /etc/inittab, a copy of which follows:

# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.8 1998/05/10 10:37:50 miquels Exp $
# The default runlevel.
id:2:initdefault:


# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS
b::boot:echo "INIT: boot action..."
bw::bootwait:echo "INIT: boot wait action - sleeping 5 seconds..."; sleep(5); echo "done napping..."


# What to do in single-user mode.
~~:S:wait:/sbin/sulogin


# /etc/init.d/rc executes the Snn and Knn scripts in order upon change
# of runlevel.
#

# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.


l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6


# The following run when you do 'telinit A' or 'telinit B' and are disconnected from
# getting Ctrl-C, Ctrl-\, and Ctrl-Z from the keyboard.  Ctrl-D will logout from the
# current version of bash that has been temporarily replaced by the "demand" program.
# The demand program's parent is init, not bash, and bash can still be used even
# though the output from the demand program is going to the same terminal.
#
la:A:wait:/home/c/sigplayposix
lb:B:wait:/home/c/sigplayold
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin


# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now


# shutdown -t1 => 1 second pause before shutdown
# shutdown -a  => use /etc/shutdown.allow (root always allowed)
# shutdown -r  => reboot after shutdown
# shutdown -h  => halt after shutdown


# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop


# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#

# Format:
#  :::
1:12345:respawn:/sbin/agetty 9600 tty1
2:2345:respawn:/sbin/agetty 9600 tty2
3:2345:respawn:/sbin/agetty 9600 tty3
4:2345:respawn:/sbin/agetty 9600 tty4
5:2345:respawn:/sbin/agetty 9600 tty5
6:2345:respawn:/sbin/agetty 9600 tty6



x:5:respawn:/usr/X11R6/bin/xdm -nodaemon


#n1:234:wait:/etc/init.d/rc.inet1
#n2:234:wait:/etc/init.d/rc.inet2


# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100


# Example how to put a getty on a modem line.
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3


When this is processed at the very end of the booting process, the following lines are printed:


Activating swap...
Checking root filesystem...
Parallelizing fsck version 1.04 (16-May-96)
Checking all file systems.

[/sbin/fsck.ext2]fsck.ext2 -a /dev/sdb5
/dev/sdb5: clean, 26562/261120 files, 545241/1044193 blocks

Checking all filesystems...
Parallelizing fsck version 1.04 (16-May-96)

/dev/sda2: clean, 28715/376832 files, 1174190/1502077 blocks
/dev/sda7: clean, 450/26104 files, 15544/104391 blocks

Mounting local file systems...

/proc on /proc type proc (rw)
/dev/sda2 on /mnt/extra type ext2 (rw)
/dev/sdia7 on /mnt/backup type ext2 (rw)
Telling the kernel that the machine time is local, not GMT

Mon Nov 29 19:47:59 PST 1999
Cleaning up: /tmp /var/lock /var/run.
Starting System logger: syslogd.
Starting Kernel logger: klogd.



Starting BSD Printer daemon lpd: lpd.
Initializing random number generator... done.
INIT: Bootwait action - sleeping 5 seconds...
INIT: Boot (no wait) - sleeping 15 seconds...
INIT: Bootwait - Done napping.

Upon entering run level 2 it prints:

INIT: Entering runlevel: 2



Notice how /sbin/init waited for the bootwait action to finish before going to run level 2, the default runlevel specified by the id:2:default: entry in /etc/inittab. At this point all actions which are associated with runlevel 2 are started. Specifically, for this simplified /etc/inittab these are:

rc 2

/etc/init.d/rc takes the parameter 2 and walks through each link in the directory /etc/rc2.d, killing ("K") or starting ("S") scripts in the order specified by their numbering ("00" through "99"). An alternate arrangement for these script files has them placed one directory lower in (/etc/rc.d/rc2.d, etc.).



/etc/inittab also specifies that all 6 virtual consoles shall be set up in run level 2:


/sbin/agetty 9600 tty1
/sbin/agetty 9600 tty2
/sbin/agetty 9600 tty3
/sbin/agetty 9600 tty4
/sbin/agetty 9600 tty5
/sbin/agetty 9600 tty6


Each of the agetty's starts a login shell, /sbin/login, and after a log-in, starts /bin/sh which is typically a symbolic link to /bin/bash.

At this point most distributions clear the screen and set the cursor set to the top left character.

For illustrative purposes, I have made my /etc/init.d/rcS script indicate when it is started and we get the following:


Starting initscript...
Starting initscript...
Starting initscript...
Starting initscript...
Starting initscript...
Starting initscript...
Starting initscript...


/sbin/login copies the file /etc/issue to the screen before prompting for the user name and password:
Kanji-Flash Softworks
Baldy login: INIT: Boot (no wait) - Done napping.root
Password:

Last login: Mon Nov 29 17:54:57 1999 on tty2

Linux Baldy 2.2.12 #1 Thu Nov 4 19:44:40 PST 1999 i686 unknown


14. The Bash Shell is Started


The bash shell, /bin/bash is then started up. Bash initialization begins by executing script in /etc/profile which set the system-wide environment variables:


# /etc/profile
# System wide environment and startup programs
# Functions and aliases go in $HOME/.bashrc

export PATH="/bin:/usr/bin:/usr/X11R6/bin:/opt/bin:/usr/local/bin:/usr/local/java/bin:./"

umask 022

if [ `id -gn` = `id -un` ] && [ `id -u` != 0 ]; then
    umask 002
fi


if [ -z "$UID" ]; then
    UID=`id -u`
fi



if [ "$UID" = 0 ]; then
    PATH=/sbin:/usr/sbin:$PATH
else
    PATH=$PATH:
fi



export USER=`id -un`
export LOGNAME=$USER
export HOSTNAME=`/bin/hostname`
export LOCATE_PATH=/var/state/misc/locatedb

Next, Bash executes the script in /root/.profile for user-specific customizations:

# ~/.profile --
#   The  personal  initialization  file,  executed  for login shells


if [ -n "$BASH_VERSION" ]; then
    if [ -r "$HOME/.bashrc" ]; then
    # login shells are always interactive, are they?
    . $HOME/.bashrc
    fi
fi


In this case, it merely has the shell execute the script .bashrc in the user's home directory. Both .profile and .bashrc set user-specific customizations, but only .bashrc is run at each shell invocation. .profile is only run at log-in.



In my case for root, /root/.bashrc contains:


#Make backspace work as expected by PC users but otherwise leave as expected by remote terminal users.

if [ -z "$TERM" ]; then
    echo ".bashrc: TERM empty: this shouldn't happen!" 1>&2
    echo "   Please contact 'support@lst.de'" 1>&2
else

    case $TERM in
    linux*)
        stty erase '^?'
        ;;
    *)
        stty erase '^H'
        ;;
    esac
fi


#Exports some environmental variables:
#export GROFF_TYPESETTER=latin1
#export LC_CTYPE=iso-8859-1
#export METAMAIL_PAGER=less

export LESSCHARSET=latin1
export PS1="\[\033[0m\033[1;32m\][\d - \@: \w]\\$\[\033[1;37m\] "
export TERMINFO=/usr/lib/terminfo
export HISTSIZE=200
export LD_LIBRARY_PATH=/usr/local/lib
export PRINTER=magic
export LS_COLORS='no=01;37:fi=01:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:'


#Set some aliases:

alias which='type -path'
alias ll="ls --almost-all -l --classify --full-time --color"
alias ls="ls -A --color"
alias showhex="/usr/bin/hexdump -f /etc/hexdump.fmt"
alias cc="gcc -DEOF=-1 -Wall -lintl"
alias whatfor="whatfor --color --all"
alias last="last -n 10 -a -x"
alias less="less --raw-control-chars --LONG-PROMPT --force"
alias pssig="ps -sx --forest"
alias psx="ps -o user,ppid,pid,pgid,tty,stat,command --forest x"
alias psw="ps -aux --forest"


#Set some key bindings for bash's command line input:

# Home
bind '"\e[1~": beginning-of-line'

# Insert
bind '"\e[2~": abort'

# Delete
bind '"\e[3~": delete-char'

# End
bind '"\e[4~": end-of-line'

# Page Up
bind '"\e[5~": abort'

# Page Down
bind '"\e[6~": abort'


#Sets tab stops to every 4th character:
setterm -clrtabs
setterm -regtabs 4


Finally, bash initialization is complete and we get the bash prompt!!!!!

[Mon Nov 29 06:33pm: ~]#

Monday, April 23, 2007

linux: loading modules causes problems in iptables


You may run into a few problems with loading modules. For example, you could get errors claiming that there is no module by such a name and so on. This may, for example look like the following.
insmod: iptable_filter: no module by that name found
This is no reason for concern yet. This or these modules may possibly have been statically compiled into your kernel. This is the first thing you should look at when trying to solve this problem. The simplest way to see if these modules have been loaded already or if they are statically compiled into the kernel, is to simply try and run a command that uses the specific functionality. In the above case, we could not load the filter table. If this functionality is not there, we should be unable to use the filter table at all. To check if the filter table is there, we do the following.
iptables -t filter -L
   
This should either output all of the chains in the filter table properly, or it should fail. If everything is o.k., then it should look something like this depending on if you have rules inserted or not.
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
    
If you do not have the filter table loaded, you would get an error that looks something like this instead.
iptables v1.2.5: can't initialize iptables table `filter': Table \
     does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
    
This is a bit more serious since it points out that first of all, we do not have the functionality compiled into the kernel, and second, that the module is not possible to find in our normal module paths. This may either mean that:

  • you have forgotten to install your modules,
  • you have forgotten to run depmod -a to update your module databases or
  • you have not compiled the functionality as either module or statically into kernel.
There may of course be other reasons for the module not to be loaded, but these are the main reasons. Most of these problems are easily solved.

  • The first problem would simply be solved by running make modules_install in the kernel source directory (if the source has already been compiled and the modules have already been built).
  • The second problem is solved by simply running depmod -a once and see if it works afterward.
  • The third problem is a bit out of the league for this explanation, and you are more or less left to your own wits here. You will most probably find more information about this on the Linux Documentation Project homepage.

Source

netperf design

Netperf Always Uses Two Separate Connections

One connection for control, one connection for data.

When you execute netperf, the first thing that will happen is the establishment of a control connection to the remote system. This connection will be used to pass test configuration information and results to and from the remote system. Regardless of the type of test being run, the control connection will be a TCP connection using BSD sockets.

Once the control connection is up and the configuration information has been passed, a separate connection will be opened for the measurement itself using the APIs and protocols appropriate for the test. The test will be performed, and the results will be displayed.

Netperf places no traffic on the control connection while a test is in progress. Certain TCP options, such as SO_KEEPALIVE, if set as your system's default, may put packets out on the control connection.



Source

Thursday, March 29, 2007

linux: how to stop the firewall


To stop your linux firewall, first login as root, else use sudo for the following commands.

Option A - If you are on a RedHat or Fedora based system:
/etc/init.d/iptables stop
OR
service iptables stop

Option B - If you are on a Debian-based system,:
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT[/code]


Source

Tuesday, March 27, 2007

esx: obtaining a vm's ip address from the command line

You can get a VM's IP adrress just using:

vmware-cmd [vmx_path] getguestinfo "ip"

When the guest operating system is running inside a virtual machine, you can pass information
from a script (running in another machine) to the guest operating system, and from the guest
operating system back to the script, through the VMware Tools service. You do this by using a class of shared variables, commonly referred to as GuestInfo.
VMware Tools must be installed and running in the guest operating system before a GuestInfo variable can be read or written inside the guest operating system. (source: VMware Scripting API - 2.3 User's Manual)

source

Monday, March 26, 2007

esx: killing a stuck vm from the command line


On the ESX 3 console find the PID by:

ps -ef|grep [VM name]
and then kill it by:
kill -9 PID




source

esx: stopping a vm from the command line using powerop_mode

Login to the Service Console and try the following:


vmware-cmd [vm-cfg-path] stop [powerop_mode]

where [vm-cfg-path] is the location of the vmx file for the VM and [powerop_mode] is either hard, soft or trysoft .

It is tempting to just use hard for the [powerop_mode] when it appears that the VM is really stuck :)




source


Wednesday, March 21, 2007

esx: ide vs sata

Installation on IDE or SATA Drives:

(source: vi3_esx_quickstart.pdf)




The installer displays a warning if you attempt to install ESX Server software on an IDE drive or a SATA drive in ATA emulation mode. It is possible to install and boot ESX Server software on an IDE drive. However, VMFS, the filesystem on which virtual machines are stored, is not supported on IDE or SATA. An ESX Server host must have SCSI storage, NAS, or a SAN on which to store virtual machines.

Tuesday, March 6, 2007

networking: tso (tcp segmentation offload) overview

TSO, a feature found in the OS, improves performance by offloading packet formation from the host processor to the Ethernet network controller.



TSO does not require special end-to-end enablement because it uses IEEE® standards-based 1500-byte frames. TSO allows the host to send 64 KB blocks of data to the network adapter, instead of 1518-byte packets. The network adapter's controller parses the 64 KB block into standard Ethernet packets, thus reducing the host processor utilization. By increasing network throughput and reducing CPU utilization, TSO increases network efficiencies.







IT managers considering Linux can benefit from choosing a server with a network connection that includes support for the new TCP Segmentation Offload (TSO) technology (also known as Large Send Offload [LSO] in Microsoft operating systems). TSO, originally designed for the Microsoft Windows® 2000 OS, is now also available for Windows XP and Windows .NET Server 2003. The performance gains offered by TSO were so substantial in the Microsoft operating systems that Intel took advantage of TSO in the Linux environment. Today, the Intel 82545EM, 82546EB, and 82540EM Gigabit Ethernet controllers support TSO. Intel continues to work closely with Linux kernel developers to make TSO a robust Linux offering.



Jumbo frames (frames larger than the standard 1518 bytes) is another technology that improves performance by reducing the amount of processing that the operating system must complete (see Figure 3). When a large block of data is requested-64 KB or more-the OS must break the block into packet-sized pieces, and then further process these pieces into packets that can ultimately be driven out onto the network.





Figure 3. Relieving the OS burden: Standard frames compared to TCP segmentation





When Jumbo frames is enabled on the network, packets going out on the network are simply oversized and the OS has fewer packets to create and transmit. However, when block sizes are smaller, Jumbo frames performance begins to diminish as latencies are introduced. Both TSO and Jumbo frames achieve performance gains. However, there is a disadvantage with Jumbo frames. With Jumbo frames, every node on the network and all of the switching infrastructure in between must be specifically enabled.





Source: http://www.dell.com/content/topics/global.aspx/power/en/

Monday, March 5, 2007

esx: DMZ within a single esx box

dmz in a box using esx







DMZ in a box



In this example, we have four virtual machines running two Firewalls, a Web server and an Application Server to create a DMZ. The Web server and Application server sit in the DMZ between the two firewalls. External traffic from the Internet (labeled External) is verified by the firewall inside the VM, and if authorized routed to the virtual switch in the DMZ – the switch in the middle. The Web Server and Application Server are connected to this switch and hence can serve external requests.





This switch is also connected to a firewall that sits between the DMZ and the internal corporate network (labeled Internal). This second firewall filters packets and if verified, routes them to the VMNIC0, connected to the internal corporate network. Hence a complete DMZ can be built inside a single ESX Server. Because of the isolation between the various virtual machines, even if one of them were to be compromised by, say, a virus the

other virtual machines would be unaffected.















Source1

Source2: tommy walker ppt - Virtualization Reducing Costs, Time and Effort with VMware (2002)

Friday, March 2, 2007

linux basics: umask

Question: Your umask value is set to 022 and you create a file. Which set of permissions are associated with this file?

A. rw-r--r--

B. rwxr--r--

C. ----w--w-

D. rw-rw-rw-

E. rwxrwxrwx



Answer: A.

Explanation: Remember that the permissions for created files will always be the numeric value 666 minus the umask value. (666 – 022 = 644) Important Points: to make permanent change, change the umask value in user’s .profile or .cshrc. If you just change it on the current shell session, the effect is only temporary! (Next time, you log in, it will be lost!)



Source

linux basics: bash shortcuts


alt+f : move forward one word
alt+b : move backwards one word

ctrl+a : takes you to the begining of the line you are currently typing
ctrl+e : takes you to the end of the line you are currently typing
ctrl+b : move backward one character
ctrl+f : move forward one character

ctrl+c : kills the current command or process.
ctrl+d : kills the shell.
ctrl+z : puts the currently running process in background

ctrl+h : deletes one letter at a time from the line you are typing in
ctrl+w : delete word before cursor
ctrl+k : clears the line after the cursor
ctrl+u : clears the line before the cursor
ctrl+l : clear screen



ctrl+r : does a search in the previously given commands so that you don't have to repeat a long command

esc+b : takes you back by one word while typing a command
esc+p : like ctrl+r + lets you search through the previously given commands
esc+. : gives the last command you typed.

esx: you can't run it on a vm!

Running ESX on a VM - vmware.esx-server | Google Groups:

">On Feb 26, 7:03 pm, "yy" ...@yahoo.com.ph> wrote:
>Has anyone successfully setup/ran an ESX on a Virtual Machine? I need
> to do this as a proof of concept before dealing with real hardware.

ESX server won't run on in a VM virtualized by ESX server.

I've tried. There is something ESX looks for in the CPU that is not
virtualized by ESX server."

Tuesday, February 27, 2007

networking: vlans, vlan ids, vlan trunks


Networking FAQ: VLAN
Wikipedia

VLANs:
are independent logical LANs within the same physical network. They help in reducing the broadcast domain and aids in network administration by separating logical segments of a LAN (like company departments) that should not exchange data using a LAN (they still can exchange data by routing).

VLANs use medium to high range switches that enable software partitioning of the available ports, based on certain criteria. This set of ports is called a Virtual LAN or is abbreviated to VLAN. As you can imagine, the switch fabric could forward the Ethernet frames to the ports belonging to the same VLAN, while it would prevent any communication among distinct Virtual LANs.

VLAN Trunks:
When a single switch is not sufficient for a company, but the LAN extends over a set of them, the need arises to create Virtual LANs on each and enable communication between them. The first solution could be to use a port dedicated to the uplink for each VLAN. This would however lead to waste in terms of ports and cables; if the Virtual LANs common to two switches are n you must use n uplink cables.

A better solution is to create a trunk or trunking: in other words, both switches are attributed a common port (trunk port) to all the VLANs that need to be transported. Such trunks must run between these "tagged ports" of VLAN-aware devices, so they are often switch-to-switch or switch-to-router links rather than links to hosts.The switches tag each packet outbound of the trunk with a VLAN ID and each packet entering via trunking is forwarded on the right VLAN based on the VLAN ID. It is obvious that the two switches must use the same trunking protocol to communicate correctly via the trunk. There are different types of these protocols, which are often proprietary, and this could lead to inter-operational problems among different brands of switch that use the Virtual LANs. Yet, the most used trunking protocol is IEEE 802.1Q. The latter, for each Ethernet frame exiting the trunk configured port, adds 4 bytes and only 12 bits of which are used to identify the VLAN. The VLAN ID is therefore between 1 and 4094, considering 0 and 4095 are reserved values.

Thursday, February 22, 2007

vmware: virtual center 2.0 - feature highlights

VMware Consolidated Backup
Consolidated Backup enables offloaded and impact-free backup for virtual machines running on an ESX Server system by allowing traditional file-based backup software to leverage VMware virtual machine snapshot technology and efficient SAN-based data transfer.

Remote CD/Floppy Access
Using either the Virtual Infrastructure Client or Virtual Infrastructure Web Access, a virtual machine can access a CD or floppy device from the client's machine.

VMware HA
VMware HA (High Availability) increases the availability of virtual machines by detecting host failures and automatically restarting virtual machines on other available hosts. HA operates on a set of ESX Server 3.0 hosts that have been grouped into a cluster with HA enabled.

VMware DRS
Distributed Resource Scheduling allows resources from all hosts in a cluster to be treated as a single, aggregated pool. When changes occur in the environment, DRS can tune the resource scheduling on individual hosts as well as use VMotion to rebalance workload across hosts in the cluster. When a virtual machine is powered on, DRS calculates the optimal host on which to start it, given current resource levels and the resource configuration of the new virtual machine.

Resource Pools
A resource pool provides a way of subdividing the resources of a stand-alone host or a cluster into smaller pools. A resource pool is configured with a set of CPU and memory resources that are shared by the virtual machines that run in the resource pool. Resource pools can be nested.

VMotion
- Virtual machine migrations while powered on (VMotion) are also all fully operational and enable migrations between two ESX Server 3.0 hosts or between two ESX Server 2.x hosts.
- Virtual machine migrations while powered off (cold migrations) are all fully operational and enable migrations between two ESX Server 3.x hosts or between ESX Server 3.x and ESX Server 2.x hosts.

esx: esx 3.0 feature highlights

  • NAS and iSCSI Support
    ESX Server 2.x could store virtual machines only on SCSI disks and on Fibre Channel SANs. ESX Server 3.0 can store virtual machines on NAS and iSCSI. iSCSI LUNs, like Fibre Channel LUNs, can be formatted with the VMware file system (VMFS). Each virtual machine resides in a single directory. Network attached storage (NAS) appliances must present file systems over the NFS protocol for ESX Server to be able to use them. NFS mounts are used like VMFS with ESX Server creating one directory for each virtual machine.

    Four-way Virtual SMP and 16 GB Memory Available to Guest Operating Systems
    Virtual machines can now have up to 4 processors (up from 2) and 16 GB of RAM (up from 3.6 GB) allocated to them.

  • ESX Server Clusters
    VirtualCenter 2.x introduces the notion of a cluster of ESX Server hosts. A cluster is a collection of hosts that can be managed as a single entity. The resources from all the hosts in a cluster are aggregated into a single pool. A cluster looks like a stand-alone host, but it typically has more resources available.

  • 64-Bit OS Virtual Machines
    64-bit guest operating systems are experimentally supported and visible in the Virtual Infrastructure Client interface, with full support available in future VI3 releases.

  • Hot-Add Virtual Disk
    ESX Server 3.0 supports adding new virtual disks to a virtual machine while it is running. This is useful with guest operating systems capable of recognizing hot-add hardware.

  • VMFS 3
    There is a new generation of VMFS in ESX Server 3.0. Scalability, performance, and reliability have all improved. Furthermore, subdirectories are now supported. ESX Server system will create a directory for each virtual machine and all its component files.

  • Potential Scalability Bottlenecks Have Been Removed
    In ESX Server 2.x, one vmx process per running virtual machine ran in the service console to implement certain virtual machine functionality. In ESX Server 3.x, these processes are no longer bound to the service console but instead are distributed across a server's physical CPUs.


  • New Guest SDK Available
  • The VMware Guest SDK allows software running in the guest operating system in a VMware ESX Server 3.0 virtual machine to collect certain data about the state and performance of the virtual machine. Download the Guest SDK package from www.vmware.com/support/developer/
  • VMware Tools Auto-Upgrade
  • VMware Infrastructure 3 (ESX Server 3.0/VirtualCenter 2.0) supports the ability to install or upgrade VMware Tools on multiple virtual machines at the same time without needing to interact with each virtual machine. Detailed instructions are provided in the Installation and Upgrade Guide.

esx: vmfs 2 overview

(source: vmware)



While conventional file systems allow only one server to have read-write access to the same file at a given time, VMFS is a cluster file system that leverages shared storage to allow multiple instances of ESX Server

to read and write to the same storage, concurrently.
VMFS allows :



  • Easier VM management: Greatly simplify virtual machine provisioning and administration by efficiently

    storing the entire virtual machine state in a central location.
  • Live Migration of VMS: Support unique virtualization-based capabilities such as live migration of running virtual machines from one physical server to another, automatic restart of a failed virtual machine on a separate physical server, and clustering virtual machines across different physical servers.
  • Performance: Get virtual disk performance close to native SCSI for even the most data-intensive applications with dynamic control of virtual storage volumes.
















  • Concurrent access to storage: Enable multiple installations of ESX Server to read and write from the same storage location concurrently.
  • Dynamic ESX Server Modification: Add or delete an ESX Server from a VMware VMFS volume without disrupting other ESX Server hosts.
  • VMFS volume resizing on the fly: Create

    new virtual machines without relying on a storage administrator.

    Adaptive block sizing and addressing for growing files allows you to

    increase a VMFS volume on the fly.
  • Automatic LUN mapping: Simplify storage management with automatic discovery and mapping of LUNs to a VMware VMFS volume.
  • I/O parameter tweaking: Optimize your virtual machine I/O with adjustable volume, disk, file and block sizes.
  • Failure recovery: Recover virtual machines faster and more reliably in the event of server failure with Distributed journaling.

VMware VMFS cluster file system is included in VMware Infrastructure

Enterprise and Standard Editions and is available for local storage

only with the Starter edition.


vmware: virtual infrastructure 3 overview

VMware Infrastructure 3 is a feature-rich suite that delivers the production-proven efficiency, availability, and

dynamic management needed to create a responsive data center. The suite includes:









esx: the vmfs file system

VMFS - Wikipedia: "VMFS is VMware's SAN file system. (Other examples of SAN file systems are Global File System, Oracle Cluster File System). VMFS is used solely in the VMware flagship server product, the ESX. It was developed and is used to store virtual machine disk images, including snapshots.


- Multiple servers can read/write the same filesystem simultaneously
, while
- Individual virtual machine files are locked
- VMFS volumes can be logically 'grown' (nondestructively increased in size) by spanning multiple VMFS volumes together.

There are three versions of VMFS: VMFS1, VMFS2 and VMFS3.

* VMFS1 was used by the ESX 1.x which is not sold anymore. It didn't feature the cluster filesystem properties and was used only by a single server at a time. VMFS1 is a flatfilesystem with no directory structure.

* VMFS2 is used by ESX 2.x, 2.5.x and ESX 3.x. While ESX 3.x can read from VMFS2, it will not mount it for writing. VMFS2 is a flatfilesystem with no directory structure.

* VMFS3 is used by ESX 3.x. As a most noticeable feature, it introduced directory structure in the filesystem. Older versions of ESX can't read or write on VMFS3 volumes. Beginning from ESX 3 and VMFS3, also virtual machine configuration files are stored in the VMFS partition by default."

vmware: known issues

Source: VMware - Wikipedia

Hardware support

issues:

  • VMware virtual machines do not support FireWire.
  • VMware virtual machines provide no direct USB 2.0 support, but make USB 2.0 devices in the host operating-system visible to the guest operating-system as USB 1.1 devices. (VMware Workstation 6.0 will offer USB 2.0 support.)
  • VMware virtual machines provide only experimental support for 3D hardware acceleration.
  • From ESX 2.x to ESX 3.x it is no longer possible to connect/disconnect the CD-ROM through the console session.


vmware: known issues with newer linux kernels

Source: VMware - Wikipedia:

"Older versions of VMware seem unable to run newer versions of Linux (kernel 2.4 series seem to panic when run on VMware 2.x; and 2.6 series kernels, when run on VMware 3.x, give a protection error). VMware Workstation has now (as of Nov 2006) reached version 5.5.3, which supports these newer operating systems and kernels. However, the latest versions of the 2.6.x kernel require a patch to use all the VMware features — even when using VMware Workstation 5.0 or 5.5. This patch, freely available as vmware-any-any-updatexxx (as of 29 January 2007: update107), comes via the Czech Technical University."

LUN: Logical Unit Number

In computer storage, a logical unit number or LUN is an address for an individual disk drive and by extension, the disk device itself. The term originated in the SCSI protocol as a way to differentiate individual disk drives within a common SCSI target device like a disk array. The term has become common in storage area networks (SAN) and other enterprise storage fields. Today, LUNs are normally not entire disk drives but rather virtual partitions (or volumes)of a RAID set.

Nomenclature: In SCSI, LUNs are addressed in conjunction with the controller ID of the host bus adapter, the target ID of the storage array, and an optional (and no longer common) slice ID. In the UNIX family of operating systems, these IDs are often combined into a single "word". For example, "c1t2d3s4" would refer to controller 1, target 2, disk 3, slice 4.


(Logical Unit Number) is an identification scheme for storage disks that typically supports a small number of units addressed as LUN 0 through 7, 15 or 31 depending on the technology. For example, Fibre Channel supports 32 addresses (0-31). A LUN may refer to a single disk, a subset of a single disk or an array of disks. Derived from the SCSI bus technology, each SCSI ID address can be further subdivided into LUNs 0 through 15 for disk arrays and libraries. See SCSI.


Logical Unit Number Masking or LUN masking is an authorization process that makes a LUN available to some hosts and unavailable to other hosts.The security benefits are limited in that with many HBAs (i.e. say, SCSI cards) it is possible to forge source addresses (WWNs/MACs/IPs). However, it is mainly implemented not as a security measure per se, but rather as protection against misbehaving servers from corrupting disks belonging to other servers. For example, Windows servers attached to a SAN will under some conditions corrupt non-Windows (Unix, Linux, NetWare) volumes on the SAN by attempting to write Windows volume labels to them. By hiding the other LUNs from the Windows server, this can be prevented, since the Windows server does not even realise the other LUNs exist.

os: threads, fibers and processes



Thread (computer science) - Wikipedia, the free encyclopedia

Threads compared with processes

Threads are distinguished from traditional multi-tasking operating system processes in that processes are typically independent, carry considerable state information, have separate address spaces, and interact only through system-provided inter-process communication mechanisms. Multiple threads, on the other hand, typically share the state information of a single process, and share memory and other resources directly. Context switching between threads in the same process is typically faster than context switching between processes. Systems like Windows NT and OS/2 are said to have "cheap" threads and "expensive" processes; in other operating systems there is not so great a difference.



Multithreading is a popular programming and execution model that allows multiple threads to exist within the context of a single process, sharing the process' resources but able to execute independently. The threaded programming model provides developers with a useful abstraction of concurrent execution. However, perhaps the most interesting application of the technology is when it is applied to a single process to enable parallel execution on a multiprocessor system.

This advantage of a multi-threaded program allows it to operate faster on computer systems that have multiple CPUs, CPUs with multiple cores, or across a cluster of machines. This is because the threads of the program naturally lend themselves to truly concurrent execution.



A process is the "heaviest" unit of kernel scheduling.
Processes own resources allocated by the operating system. Resources
include memory, file handles, sockets, device handles, and windows.
Processes do not share address spaces or file resources except through
explicit methods such as inheriting file handles or shared memory
segments, or mapping the same file in a shared way. Processes are
typically pre-emptively multitasked. However, Windows 3.1 and older
versions of Mac OS used co-operative or non-preemptive multitasking.


A thread is the "lightest" unit of kernel scheduling. At
least one thread exists within each process. If multiple threads can
exist within a process, then they share the same memory and file
resources. Threads are pre-emptively multitasked if the operating
system's process scheduler is pre-emptive. Threads do not own resources
except for a stack and a copy of the registers including the program counter.

A fiber is a "user thread." In some situations, there is a distinction between "kernel threads" and
"user threads" -- the former are managed and scheduled by the kernel,
whereas the latter are managed and scheduled in userspace. In this
article, the term "thread" is used to refer to kernel threads, whereas
"fiber" is used to refer to user threads. Fibers are co-operatively scheduled:
a running fiber must explicitly "yield" to allow another fiber to run.
A fiber can be scheduled to run in any thread in the same process.




powered by performancing firefox

Wednesday, February 21, 2007

linux basics: /etc/sysconfig/network

The etc/sysconfig/network file is used to specify information about the desired network configuration. The following values may be used:
  • NETWORKING=, where is one of the following boolean values:
    • yes — Networking should be configured.
    • no — Networking should not be configured.
  • HOSTNAME=, where should be the Fully Qualified Domain Name (FQDN), such as hostname.domain.com, but can be whatever hostname you want.
    Note Note
    For compatibility with older software that people might install (such as trn), the /etc/HOSTNAME file should contain the same value as here.
  • GATEWAY=, where is the IP address of the network's gateway.
  • GATEWAYDEV=, where is the gateway device, such as eth0.
  • NISDOMAIN=, where is the NIS domain name.
  • FORWARD_IPV4=answer, where the answer is yes or no. This decides whether to perform IP forwarding or not to perform IP forwarding.

virtualization: types of hypervisors

From the Wikipedia Definition:

"In computing, a hypervisor (also: virtual machine monitor) is a virtualization platform that allows multiple operating systems to run on a host computer at the same time. The term usually refers to an implementation using full virtualization. Hypervisors are currently classified in two types:

* Type 1 hypervisor
(e.g. ESX Server)
is software that runs directly on a given hardware platform (as an operating system control program). A 'guest' operating system thus runs at the second level above the hardware. The classic type 1 hypervisor was CP/CMS, developed at IBM in the 1960s, ancestor of IBM's current z/VM. More recent examples are Xen, VMware's ESX Server, and Sun's Hypervisor (released in 2005).

* Type 2 hypervisor
(e.g. VM Workstation)
is software that runs within an operating system environment. A 'guest' operating system thus runs at the third level above the hardware. Examples include VMware server and Microsoft Virtual Server."

virtualization: server consolidation

definition from Whatis.com:

DEFINITION - Server consolidation is an approach to the efficient usage of computer server resources in order to reduce the total number of servers or server locations that an organization requires. The practice developed in response to the problem of server sprawl, a situation in which multiple, under-utilized servers take up more space and consume more resources than can be justified by their workload.

According to Tony Iams, Senior Analyst at D.H. Brown Associates Inc. in Port Chester, NY, servers in many companies typically run at 15-20% of their capacity, which may not be a sustainable ratio in the current economic environment. Businesses are increasingly turning to server consolidation as one means of cutting unnecessary costs and maximizing return on investment (ROI) in the data center. Of 518 respondents in a Gartner Group research study, six percent had conducted a server consolidation project, 61% were currently conducting one, and 28% were planning to do so in the immediate future.

Although consolidation can substantially increase the efficient use of server resources, it may also result in complex configurations of data, applications, and servers that can be confusing for the average user to contend with. To alleviate this problem, server virtualization may be used to mask the details of server resources from users while optimizing resource sharing. Another approach to server consolidation is the use of blade servers to maximize the efficient use of space.

os: processor affinity

Processor Affinity - Wikipedia:

"Processor affinity is a modification of the native central queue scheduling algorithm. Each task (be it process or thread) in the queue has a tag indicating its preferred / kin processor. At allocation time, each task is allocated to its kin processor in preference to others.

Processor affinity takes advantage of the fact that some remnants of a process may remain in one processor's state (in particular, in its cache) from the last time the process ran, and so scheduling it to run on the same processor the next time could result in the process running more efficiently than if it were to run on another processor."

virtualization: server consolidation and containment

Server Consolidation and Containment:

Today's IT organizations face the costly management of server sprawl. This includes the hardware, maintenance and people resources needed to manage, operate and administer those servers on a daily basis. VMware server consolidation and containment solutions allow enterprises to enable workload isolation and granular resource control for all of the system's computing and I/O resources.

Using virtual infrastructure to consolidate physical systems in the data center, enterprises experience:

* Lower total cost of ownership of servers
* Higher server utilization
* Increased operational efficiency

linux: grub vs lilo

GNU GRUB 2:

Here are some of GRUB 2's features that make it more attractive than LILO (imo):

* Scripting support, such as conditionals, loops, variables and functions.
* Graphical interface.
* Dynamic loading of modules in order to extend itself at the run time rather than at the build time.
* Portability for various architectures.
* Internationalization. This includes support for non-ASCII character code, message catalogs like gettext, fonts, graphics console, and so on.
* Real memory management, to make GNU GRUB more extensible.
* Modular, hierarchical, object-oriented framework for file systems, files, devices, drives, terminals, commands, partition tables and OS loaders.
* Cross-platform installation which allows for installing GRUB from a different architecture.
* Rescue mode saves unbootable cases. Stage 1.5 was eliminated.
* Fix design mistakes in GRUB Legacy, which could not be solved for backward-compatibility, such as the way of numbering partitions."



GRUB (Legacy) vs. LILO

As stated at the start of this article, all boot loaders work in a similar way to fulfill a common purpose. But LILO and GRUB do have a number of differences:

  • LILO has no interactive command interface, whereas GRUB does.
  • LILO does not support booting from a network, whereas GRUB does.
  • LILO stores information regarding the location of the operating systems it can to load physically on the MBR. If you change your LILO config file, you have to rewrite the LILO stage one boot loader to the MBR. Compared with GRUB, this is a much more risky option since a misconfigured MBR could leave the system unbootable. With GRUB, if the configuration file is configured incorrectly, it will simply default to the GRUB command-line interface.