Thursday, October 21, 2010

Boot Processes Fedora / CentOS /RedHat

The Boot Process

It is also easy to break.
  1. The BIOS loads the Boot Sector (Grub) from Sector 0
  2. The Grub (root line in grub.conf) points to the partition containing the kernel (Linux).
  3. The kernel loads and initializes the devices and runs /sbin/init (process 1)
  4. /sbin/init runs /etc/rc.d/rc.sysinit to initilize devices.
  5. /sbin/init reads /etc/inittab
  6. /etc/rc.d/rc.sysinit run all the scripts int the approach run level directory.

GRUB

Grub is the first step in the boot process and has the greatest Oh ---- factor. But it really doesn't have to be a big problem. You may not need to boot from a live CD to fix this. There are three main parts to boot step
  • root
  • kernel
  • initrd
Try booting and editing each of these lines in GRUB. Purposely make mistakes to learn what errors are produced.
The TAB key will do auto completions when you are editing a GRUB options.

Rescure Mode

Using the first CD to boot into Rescue mode. You can then search for the root file system and mount it to the directory /mnt/sysimage.
  chroot /mnt/sysimage
  grub
Following this command you need to show grub where to read the grub configuration. If the drive type may have changed, maybe because you changed from IDE to SCSI disks you will need to do a --recheck. Then install grub with the install command.
  grub-install --recheck /dev/hda
  grub-install /dev/hda
Redhat will ask if you want to mount the root file system. If you say no you will need to mount the root file system your self. Here are the commands to do this with the VMware system.
  mkdir /mnt/root
  mkdir /mnt/root/boot
  mount /dev/md1 /mnt/root
  mount /dev/md0 /mnt/root/boot

Fixing INITRD Modules

If the kernel is missing or corrupt you will need to reload it from the install CD.
If the initrd file is missing you you can also reload it with the kernel.
Adding missing modules to initrd:
  rm -f /boot/initrd-2.6.18-194.17.1.el5.img
  mkinitrd --preload=xor --preload=raid456 /boot/initrd-2.6.18-194.17.1.el5.img
  2.6.20-1.2320.fc5
Manually changing initrd:
  mkdir /root/initrd-tmp
  cd /root/initrd-tmp
  cp -a /boot/initrd-2.6.18-194.17.1.el5.img ..
  mv ../initrd-2.6.18-194.17.1.el5.img ../initrd-2.6.18-194.17.1.el5.img.gz
  gunzip ../initrd-2.6.18-194.17.1.el5.img.gz
  cpio -i --make-directories < ../initrd-2.6.18-194.17.1.el5.img
  vi init
  find . -depth | cpio -o > ../initrd-2.6.18-194.17.1.el5.img
  cd ..
  rm -rf initrd-tmp
  gzip -9 initrd-2.6.18-194.17.1.el5.img
  mv initrd-2.6.18-194.17.1.el5.img.gz initrd-2.6.18-194.17.1.el5.img
  mv initrd-2.6.18-194.17.1.el5.img /boot

SYSINIT


INITTAB

The file /etc/inittab controls the runlevel the system boots into.
You can override this by added the runlevel you want to the end of the kernel line in GRUB.
id:3:initrdefault:
Changing the 3 in this line will change the default runlevel to the one you want.

Runlevels

Here are the runlevels and what they mean. You should know the by heart too.
  • Run level 1 is single user
  • Run level 2 is Multiuser without NFS
  • Run level 3 is Full Multiuser
  • Run level 4 is unused
  • Run level 5 is X11 windows
  • Run level 6 will reboot the system
/etc/inittab not only starts rc.sysinit it also starts processes that shouldn't die. One of these is the system console/s. It controls which run level the system automatically boots to. The directory /etc/sysconfig hold config files for process started at this level.
RC scripts are kept in /etc/rc.d. The program that run the RC scripts is rc.sysinit. These scripts are what is done when you change run level with the init command.
The fastest to set runlevel services is to use the command 'ntsysv and tell it the runlevels you want to set. For example, this will display and change runlevels 3 and 5.
  ntsysv --level 35
Image:ntsysv.png
To turn on or off a RC script you can also use the command:
  chkconfig --level command on/off
The option --level sets the run level to be change for the command that is turned on or off. This can also be done with the GUI system-config-services.
  chkconfig --list
This command will list all the services and if they are on or off for each run level.
  chkconfig --add/--del command
This command will add or delete a new command from the RC start-up scripts.
After configuring a system like Apache it is easy to forget make it start at boot time. Don't forget to reboot you system before the test is over.
You can debug the RC process by booting into single user mode and running the RC scripts in the run level by hand. You can also bypass init by adding init=/bin/bash the kernel line in GRUB.

CLONING or RESTORING a System

THIS IS NOT NEEDED FOR THE TEST
Here are some of the issues if you are cloning or restoring a system by copy all the files into empty directories and then restoring the boot process. This process involves creating all the required root directories (/ /etc /usr /bin /var /opt /home) and coping all the files back into place with their ownership and permissions maintained. Directories that are not copied include /tmp /dev /proc /mnt. The directories that are not copied do need to be created.
  • The partitions and/or e2 labels may not be the same. This will require changing /etc/fstab
  • Some directories will/may not be copied. This may include /dev. In witch case mounting the root file system with the chroot command will leave you without any devices.
  • Grub.conf (/etc/grub/grub.conf and menu.lst) may also need editing. Both the root and kernel lines may contain references to the wrong partitions.
  • /etc/mtab needs to be edited to match the new disk. Partition numbers can change and sometimes the type, like from IDE to SCSI (hda to sda).
After booting into recover mode with the install CD. You will need to mount all of the file systems into their place under /mnt/sysimage. You can them mount the live proc and dev inplace with the command:
  mount -o bind /dev /mnt/sysimage/dev
  mount -o bind /proc /mnt/sysimage/proc
With the file systems in place you can use the chroot command to create the write environment for fixing the master boot record and Grub.
  chroot /mnt/sysimage

RedHat / Centos minimal services

I always disable most of the services witch are activated by a default Centos 5.3 instalation.

To disable them, run the following commands:
chkconfig anacron off
chkconfig apmd off
chkconfig atd off
chkconfig autofs off
chkconfig cpuspeed off
chkconfig cups off
chkconfig cups-config-daemon off
chkconfig gpm off
chkconfig isdn off
chkconfig netfs off
chkconfig nfslock off
chkconfig openibd off
chkconfig pcmcia off
chkconfig portmap off
chkconfig rawdevices off
chkconfig readahead_early off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig smartd off
chkconfig xfs off
chkconfig ip6tables off
chkconfig avahi-daemon off
chkconfig firstboot off
chkconfig yum-updatesd off
chkconfig mcstrans off
chkconfig pcscd off
chkconfig bluetooth off
chkconfig hidd off
And you might consider disable this:
chkconfig sendmail off
chkconfig xinetd off
chkconfig acpid off
chkconfig microcode_ctl off
chkconfig irqbalance off
chkconfig haldaemon off
chkconfig messagebus off
chkconfig mdmonitor off

osCommerce Installation on CentOS/ Fedora /RedHat

Welcome to osCommerce!

osCommerce has attracted a large growing e-commerce community that consists of over 239,200 store owners and developers who support each other and extend osCommerce Online Merchant with add-ons being contributed on a daily basis. To date there are over 6,100 add-ons that are available for free to customize osCommerce Online Merchant online stores and to help increase sales.
osCommerce Online Merchant is an Open Source online shop e-commerce solution that is available for free under the GNU General Public License. It features a rich set of out-of-the-box online shopping cart functionality that allows store owners to setup, run, and maintain online stores with minimum effort and with no costs, fees, or limitations involved.

#yum install  mysql mysql-server httpd php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc phpmyadmin

#service httpd start
#service mysqld start
#mysql_secure_installation (set up root password) 
#wget http://www.oscommerce.com/redirect.php/go,45
#unzip oscommerce-3.0a5.zip -d /var/www/html/oscommerce/
http://youdomain.com









Wednesday, October 20, 2010

Joomla Install on Fedora /CentOS /RedHat

Joomla is an award-winning content management system (CMS), which enables you to build Web sites and powerful online applications. Many aspects, including its ease-of-use and extensibility, have made Joomla the most popular Web site software available. Best of all, Joomla is an open source solution that is freely available to everyone.

#yum install  mysql mysql-server httpd php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc phpmyadmin

#service httpd start
#service mysqld start
#mysql_secure_installation (set up root password)