Linux install

Name:
Location: United States

Thursday, May 15, 2008

linux boot sequence

1. inittab - system boot based on setting on this file. The default level is 3.
Default runlevel. The runlevels used by RHS are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

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

# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now

# When our UPS tells us power has failed, assume we have a few minutes
# of power left. Schedule a shutdown for 2 minutes from now.
# This does, of course, assume you have powerd installed and your
# UPS connected and working correctly.
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

# If power was restored before the shutdown kicked in, cancel it.
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"


# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

# Run xdm in runlevel 5
x:5:respawn:/etc/X11/prefdm -nodaemon

2. Run rc.sysinit
#!/bin/bash
#
# /etc/rc.d/rc.sysinit - run once at boot time
#
# Taken in part from Miquel van Smoorenburg's bcheckrc.
#

HOSTNAME=`/bin/hostname`
HOSTTYPE=`uname -m`
unamer=`uname -r`

set -m

if [ -f /etc/sysconfig/network ]; then
. /etc/sysconfig/network
fi
if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then
HOSTNAME=localhost
fi

if [ ! -e /proc/mounts ]; then
mount -n -t proc /proc /proc
mount -n -t sysfs /sys /sys >/dev/null 2>&1
fi
if [ ! -d /proc/bus/usb ]; then
modprobe usbcore >/dev/null 2>&1 && mount -n -t usbfs /proc/bus/usb /proc/bus/usb
else
mount -n -t usbfs /proc/bus/usb /proc/bus/usb
fi

. /etc/init.d/functions

# Check SELinux status
selinuxfs="$(fstab_decode_str `LC_ALL=C awk '/ selinuxfs / { print $2 }' /proc/mounts`)"
SELINUX_STATE=
if [ -n "$selinuxfs" ] && [ "`cat /proc/self/attr/current`" != "kernel" ]; then
if [ -r "$selinuxfs/enforce" ] ; then
SELINUX_STATE=`cat "$selinuxfs/enforce"`
else
# assume enforcing if you can't read it
SELINUX_STATE=1
fi
fi

if [ -n "$SELINUX_STATE" -a -x /sbin/restorecon ] && __fgrep " /dev " /proc/mounts >/dev/null 2>&1 ; then
/sbin/restorecon -R /dev 2>/dev/null
fi

..................
3. ......
4. /etc/modprobe.conf ---alias result scan from hardware probe
alias scsi_hostadapter1 ata_piix
alias scsi_hostadapter2 usb-storage
options snd-intel8x0 index=0
alias eth0 e100
alias snd-card-0 snd-intel8x0
options snd-card-0 index=0
alias wlan0 rt2500

linux kernel image compile

1.Copy .config file from installed kernel to new kernel source directory
2. Make oldconfig
3. make menuconfig, pick and remove things you want or unwant
4. make all
5. make modules_install
6. make install -- this will create kernel image and ramdisk for fedora core as well as configure /boot/grub/menu.lst.
7.

Tuesday, March 25, 2008

BASH script quick reference

1. Special character
  • ; --Command separator
  • ;; --double terminator in case ....esac
  • # -- comment
  • . -- equivalent to source command. e.g. Note: dot has other meanings as well.
    . data-file  # source data-file
  • "STRING" --partial quoting preserve most of the special characters within STRING
  • 'STRING' -- full quoting preserves all special characters within STRING
  • , -- comma separator ,links together a series of arithmetic operations. All are evaluated, but only the last one is returned.
  • \-- escape
  • ` -- command substitutions. `command` makes available the output of command for assignment to a variable
  • : -- null command=NOP , :=true
  • ! -- invert/negate/reverse the sense of a test or exit status[bang]
  • () -- command group,(a1=1,b=2), or array initialization
  • {a,b,c}--brace expansion,eg. cat {file1,file2,file3}>combined_file,eg. cp file22.{txt,backup}
  • {a..z} -- extended brace expansion. echo {a..z} #a,b,c,d....z
  • [] -- test expression between []
  • [[]]-- test.


2.

Friday, February 29, 2008

how to setup no-password ssh login

1. Use ssh-keygen to generate a pair of public and private keys
ssh-keygen -t dsa # or -t rsa
it will generate a id_dsa and id_dsa.pub in ~/.ssh/ directory
2. Copy the public key to remote machine and add it to ~/.ssh/authorized_keys
cat id_dsa.pub>>authorized_keys
3. make sure authorized_keys has correct file attribute.
chmod 640 authorized_keys
chmod 700 .ssh


4. Or use puttygen to generate a key-pair and copy public key to the remote machine, if we use putty to login to the server.

5. Make sure you're using scp or ftp to copy the public key from one machine to another. Note Cut and paste may make the key not working. Use cat id_dsa.pub >>authorized_keys to add the additional keys.
6. Change file permission to 640, chmod 640 authorized_keys

Tuesday, February 26, 2008

/sbin/chkconfig --list --checking what services are enabled on certain run level

/sbin/chkconfig --list


services runlevel0 1 2 3 4 5 6
-----------------------------------------------------------

radvd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
bootparamd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
nfs 0:off 1:off 2:off 3:on 4:off 5:on 6:off
kudzu 0:off 1:off 2:off 3:off 4:on 5:on 6:off
cups-config-daemon 0:off 1:off 2:off 3:off 4:on 5:off 6:off
innd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
arpwatch 0:off 1:off 2:off 3:off 4:off 5:off 6:off
readahead_early 0:off 1:off 2:off 3:off 4:off 5:off 6:off
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
ldap 0:off 1:off 2:off 3:off 4:off 5:off 6:off
vncserver 0:off 1:off 2:off 3:off 4:off 5:off 6:off
ypxfrd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
postgresql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
spamassassin 0:off 1:off 2:off 3:off 4:off 5:off 6:off
canna 0:off 1:off 2:on 3:off 4:on 5:off 6:off
dhcp6s 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rwhod 0:off 1:off 2:off 3:off 4:off 5:off 6:off
mdmonitor 0:off 1:off 2:on 3:off 4:on 5:on 6:off
mdmpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
bgpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
ntpd 0:off 1:off 2:off 3:off 4:off 5:on 6:off
radiusd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
microcode_ctl 0:off 1:off 2:on 3:off 4:on 5:on 6:off
netdump-server 0:off 1:off 2:off 3:off 4:off 5:off 6:off
squid 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rpcsvcgssd 0:off 1:off 2:off 3:off 4:on 5:off 6:off
autofs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
irda 0:off 1:off 2:off 3:off 4:off 5:off 6:off
psacct 0:off 1:off 2:off 3:off 4:off 5:off 6:off
nfslock 0:off 1:off 2:off 3:on 4:on 5:on 6:off
snmpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
cpuspeed 0:off 1:on 2:on 3:off 4:on 5:on 6:off
yppasswdd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rhnsd 0:off 1:off 2:off 3:off 4:on 5:off 6:off
netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
xfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sysstat 0:off 1:on 2:on 3:on 4:on 5:on 6:off
syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
rstatd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rawdevices 0:off 1:off 2:off 3:off 4:on 5:off 6:off
ospfd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
diskdump 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rusersd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
zebra 0:off 1:off 2:off 3:off 4:off 5:off 6:off
kadmin 0:off 1:off 2:off 3:off 4:off 5:off 6:off
rpcgssd 0:off 1:off 2:off 3:off 4:on 5:off 6:off
krb5kdc 0:off 1:off 2:off 3:off 4:off 5:off 6:off
lm_sensors 0:off 1:off 2:on 3:off 4:on 5:off 6:off
amd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
snmptrapd 0:off 1:off 2:off 3:off 4:off 5:off 6:off


.............

xinetd based services:
ktalk: off
klogin: off
rlogin: off
chargen-udp: off
daytime-udp: off
kshell: off
talk: off
krb5-telnet: off
echo-udp: off
ntalk: off
cups-lpd: off
swat: off
eklogin: off
rsh: off
finger: off
daytime: off
telnet: off
time-udp: off
chargen: off
amidxtape: off
rsync: off
dbskkd-cdb: off
rexec: off
amanda: off
gssftp: off
tftp: on
auth: off
time: off
amandaidx: off
echo: off

Tuesday, February 19, 2008

How to compile Madwifi package

1. Download and unzip the madwifi package. eg. madwifi-ng-r3344-20080207.tar.gz
2. Run the following command,
make CROSS_COMPILE=powerpc-405-linux-gnu- KERNELPATH=/localhome/wli/linux-2.6.24 TARGET=powerpc-be-elf DESTDIR=/localhome/wli/rootfs install

where: CROSS_COMPILE=
powerpc-405-linux-gnu- specifies the cross-compiler prefix. Make sure cross-compiler path is exported and accessible to current user.
DESTDIR =root directory to install. Usually it's a path to root file system
TARGET= target processor and image format for cross compiling, powerpc, big-endian and elf
KERNELPATH= pah of kernel where the modules to be compiled with.
install -- install after compile. This will install the following modules in ~/rootfs/lib/modules/net/

ath_hal.ko ath_pci.ko ath_rate_amrr.ko ath_rate_minstrel.ko ath_rate_onoe.ko ath_rate_sample.ko wlan_acl.ko
wlan_ccmp.ko wlan.ko wlan_scan_ap.ko wlan_scan_sta.ko wlan_tkip.ko wlan_wep.ko wlan_xauth.ko
as well as WLAN command tools in ~/rootfs/usr/local/bin
80211debug 80211stats athchans athctrl athdebug ath_info athkey athstats madwifi-unload wlanconfig






3.. Run the following command,depmod.pl script to create modules.dep on the net module directory
../depmod.pl -b ~/rootfs/lib/modules/2.6.24/net -F ~/linux-2.6.24/System.map
This will generate modules.dep on net directory. It is needed by modprobe command.

Note: depmod.pl is a perl script from busybox-1.8.2 package.

Friday, February 15, 2008

How to cross compile ZLIB, OPENSSL, OPENSSH

ZLIB:
1. download zlib-1.2.3.tar.gz. Unzip it to /localhome/wli
2. cd zlib-1.2.3, run ./configure
3. Edit Makefile, change the following lines
CC=powerpc-405-linux-gnu-gcc
CPP=powerpc-405-linux-gnu-gcc -E
AR=powerpc-405-linux-gnu-ar rc
LDSHARED=powerpc-405-linux-gnu-gcc
prefix=/localhome/wli/rootfs/usr/local #this will install zlib into rootfs/usr/local
Note: rootfs--is the target machine root file system, in this case the target machine is powerpc-405

4. run make, make install, the zlib library will be installed to $prefix/lib

OpenSSL
1. download openssl-0.9.8g, unzip it to localhome/wli
2. run ./configure --openssldir=/localhome/wli/rootfs
3. Edit Make
AR=powerpc-405-linux-gnu-ar $(ARFLAGS) r
4. run make, make install

OpenSSH
1. download openssh-4.7p1, unzip it to localhome/wli
2. run run_configure script
./configure CC=powerpc-405-linux-gnu-gcc --host=ppc --build=powerpc-405-linux-gnu --with-ssl-dir=/localhome/wli/rootfs --w ith-zlib=/localhome/wli/rootfs --prefix=/localhome/wli/rootfs --disable-etc-default-login

3. Edit Makefile
AR=powerpc-405-linux-gnu-ar
LIBS=-lresolv -lcrypto -lutil -lz -lnsl -lcrypt # add -lcrypt
4. run make, make install

Monday, February 11, 2008

how to setup uboot enviroment variable for linux booting

Uboot needs to pass command line variables to linux kernel during bootstrapping the kernel.
1. NFS boot -- assume nfs rootfiles system is ready and exported by NFS server
a. set
nfs_boot=run nfsargs addbootfile addip;tftpboot $(kernel_addr) $(bootfile);bootm $(kernel_addr)
nfsargs=setenv bootargs root=/dev/nfs rw console=ttyS0,115200 mem=128M nfsroot=172.30.80.217:/localhome/wli/rootfs
addbootfile=setenv bootfile uImage_$(kernel_ver)
addip=setenv bootargs $(bootargs) ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname):$(netdev):off panic=1
2. RAM boot
ram_boot=run ramargs addip;tftpboot $(kernel_addr) bootimg_f;bootm $(kernel_addr)
ramargs=setenv bootargs root=/dev/ram console=ttyS0,$(baudrate) ramdisk_size=20000

The bootfile is bootimg_f, which combine kernel image and root file system together.

flash unitil tools: flashcp,flash,erase,mkfs.jffs2.. compiling

1. Download mtd-utils-1.1.0.tar.bz2 package
2. This package contains utility for flash programing,erase and building flash file system
3. In order to compile this package, we need
libz.a --this package from zlib-1.2.3.tar.bz2
liblzo2.a --- this library comes from lzo package. Come download lzo-2.02.tar.gz2
4. Compile zlib to generate libz.a,compile lzo to generate liblzo2.a
5. Copy it to mtd-utils-1.1.0 directory