Thursday, September 24, 2009

The Linux Boot Process

    When allocating disk space for the partitions, the first sector, or data unit, for each partition is always reserved for programmable code used in booting. The very first sector of the hard disk is reserved for the same purpose and is called the master boot record (MBR). When booting from a hard disk, the PC system BIOS loads and executes the boot loader code in the MBR. The MBR then needs to know which partitions on the disk have boot loader code specific to their operating systems in their boot sectors and then attempts to boot one of them.

Linux Boot Loader
------------------------

            The standard boot loader associated with Red Hat Enterprise Linux (RHEL) is GRUB, the GRand Unified Boot loader. The GRUB MBR boot loader merely searches for a special boot partition and loads a second stage boot loader. This then reads the data in the /boot/grub/grub.conf configuration file, which lists all the available operating systems and their booting parameters. When this is complete, the second stage boot loader then displays the familiar RHEL splash screen that lists all the configured operating system kernels for your choice.
Now let's discuss something about GRUB here. The main configuration file for the GRUB Bootloader is located under /boot/grub diretory with name grub.conf. Below is a sample grub.conf file for your reference:


default=0
timeout=5
splashimage=(hd0,4)/grub/splash.xpm.gz
hiddenmenu
password --md5 $1$2Srxmp06%KSkbeE#7deIrX8ucnCFzn/
title Red Hat Enterprise Linux Server(2.6.18-1.EL)
root (hd0,4)
kernel /vmlinuz-2.6.18-1.EL ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-1.EL.img
title Windows XP Professional
rootnoverify (hd0,0)
chainloader +1


 Here, you can see a first parameter default=0 which denotes that by default RHEL should start first. If you make it default=1 then in our case it should start Windows XP by default. The second parameter timeout=5, specifies the time, in seconds, before GRUB automatically boots the default operating system. Then third one is splashimage directive, which locates the graphical GRUB screen. Next the hiddenmenu directive which means that the GRUB options are hidden, with the message shown here:

Booting Red Hat Enterprise Linux Server (2.6.18-8.el5) in 4 seconds...


 Next parameter is password --md5 which specifies a password, hashed to the MD5 (Message-Digest algorithm 5) format, which protects GRUB from modification during the boot process. I will discuss about the same later on. Next line in the file is the title means The Title which is printed on screen while displaying GRUB screen. The next three lines specify the location of the /boot directory, the kernel, and the initial RAM disk, respectively:

root (hd0,4)
kernel /vmlinuz-2.6.18-1.EL ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.18-1.EL.img

 
Here the /boot directory is on the fifth partition of the first hard drive, as denoted by root (hd0,4). The kernel is specified by the vmlinuz-2.6.18-1.EL file, which you can find in the /boot directory. It's opened as read only (ro) to protect it from any accidental writes from the initial RAM disk; the actual top-level root directory is associated with the / label (root=LABEL=/). Finally, the rhgb quiet directive hides the boot messages by default. The last line (initrd) means initial RAM disk, it creates a temporary file system during the boot process. It includes kernel modules and user space programs needed to mount actual file systems and run the first initialization programs.

Ok and final three lines of the file are there only if users configure their computers in a dual-boot with Microsoft Windows. In most cases, you'll actually see the first line as:

title Other

In this case, here the title appears as Others, but here i have modified it so it is represented here as Microsoft Windows XP, which is installed on the first partition on the first hard drive,

rootnoverify (hd0,0)

This is different from the aforementioned root (hd0,4) directive, as rootnoverify does not attempt to mount the noted partition in a Linux fashion.

Finally, the chainloader +1 directive points to the first sector of the noted partition, where Microsoft Windows continues the boot process:

chainloader +1

  So, here it is a completed idea about the GRUB boot loader and its configuration file grub.conf. Now, in my next post i will show you something more about Grub Boot Loader.
 


 

 

Wednesday, September 16, 2009

Steps for Installing Linux

Now you can boot your PC from bootable CD or USB Key which we have seen in the last post. After a few lines are displayed, an RHEL Installation screen will appear with boot: prompt.
If you are installing from CD/DVD you can directly install in Graphical or Text mode. But, here we are going to see the third method Network Installation. So, at boot: prompt you have to type linux askmethod to start network installation.
Here is a step by step guide for the same:

1.    Boot your computer from the first RHEL CD, from a boot CD, or from a boot USB key.

2.    When you see the boot: prompt, enter the linux askmethod command. This temporarily starts the installation process in text mode (which is actually a low-resolution graphical mode)

3.    Select a language to use during the installation process. English is the default; nearly 50 options are available.

4.    Select a keyboard type; the default depends on the language you selected.

5.    Choose your installation method. Earlier in the post, I described how to configure an NFS installation server. Therefore, select the NFS image option (the steps for installing from FTP server vary slightly).

6.    Choose how you want IP addressing configured. Your options are to enable support as a DHCP client, for IPv4 and/or IPv6 addresses.

7.    If you enable DHCP, the installation looks for a DHCP server for IPv4 and/or IPv6 addresses. Otherwise, you'll  need to enter the information manually, along with appropriate gateway and nameserver (DNS) addresses.

8.    Direct your computer to the remote NFS server. Here you have to enter the host name or IP address of the NFS server, as well as the shared directory. (If you enter a host name, you'll need a working DNS server on your network.) If you set up an NFS installation server with the instructions earlier in the post, enter /install in the Red Hat Enterprise Linux Server Directory text box.

9.    If a proper connection is made, you'll see the first Red Hat Enterprise Linux graphical installation screen. Click Next to continue. Since you've already selected a keyboard type and language, RHEL skips those graphical screens that you'd otherwise see when installing from a CD/DVD.

    If you encounter problems, examine the third and fourth consoles; to do so, press ALT-F3 or ALT-F4.

    If you've installed Red Hat Enterprise Linux on this system before, you're given the chance to upgrade the existing installation.

    Once you complete the above mentioned steps, rest are self explenatory like Partition Screen, Boot Loader, Network Configuration, Time Zone Selection, Root Password and then finally Package Selection. All this will appear graphically. Be careful while creating partition, you should create 100MB /boot partition, swap partition will be double than your RAM and other space you can assign to your /(root) partition. It totally depends on you.

Tuesday, September 15, 2009

Creating Boot CD or USB

Ok friends now in my last two posts you might have seen how to create NFS and FTP Installation servers. If not seen then please go to my previous posts and check the same. Now, once you are ready with the Server setups, let's check what else do we need to install Linux via network. Now you need to configure your computer(where you want to install Linux) with network either through DHCP or Static Ip address of your network. 
But wait before doing any further process first thing is to boot your system with CD/DVD or USB and then we will go further for network installation. So, first of all let me show you how to create installation USB Key or CD. Its very easy to do so.

You need to have a first Installation CD/DVD, in the same we have a
directory called Images in which we have two files
1.    diskboot.img    For a boot USB Key
2.    boot.iso           For a boot CD


Even if you have any running Linux system, you can also create the same from that PC also.
Now, Let's see how to create a bootable CD or USB:

Creating a Boot USB Key
------------------------------------

First insert USB into your system. Run fdisk -l command to find the logical device alias with your USB. Here, let us assume it is /dev/sdb, now run the following command:

# dd if=/media/disk/images/diskboot.img   of=/dev/sdb

here, make a note that if(InputFile) is the path where your Installation CD is mounted in your system.

Creating a Bootable CD
----------------------------

Here i am assuming that you don't have two CD drives in your system. So, first insert First Installation Disk and copy the boot.iso file from Images folder to anywhere on your system. Let's say you copied it to /tmp directory. Now, burn the CD with following command:

# cdrecord dev=/dev/hdc -v eject /tmp/boot.iso

Here the command may vary based on the CD Drive's logical name associated in your System.

So, that's all now you are ready with your Installation Disk with which you can start Installing Linux. Step by Step Installation guide i will show you in my next Post.

Sunday, September 13, 2009

Creating FTP installation server

In my previous post i have described how to setup NFS Installation server. Now, today i am going to describe how to sertup FTP Installation server and then i will show you a step how to install Linux from Network with these two servers.

Ok here basic steps are the same as NFS only. First of all let's assume that you have installed vsFTP server on your Linux Box. Main share directory for FTP is /var/ftp/pub. So, we will copy all installtion files here in the same directory. Here are the detailed steps:

1.    Create a directory for your installation files. With the following command, create the /var/ftp/pub/inst directory. (If you get an error message, vsFTP may not be properly installed.)

    # mkdir /var/ftp/pub/inst

2.    Insert the first Red Hat Enterprise Linux installation CD/DVD into its drive. In many cases, it'll get mounted automatically, using the name of the media; for example, my RHEL DVD is automounted in the /media/RHEL-5 i386 Disc     1 directory. Otherwise, you can run a command such as mount /dev/cdrom /media. (If all you have are the ISO files,     say in the /tmp directory, substitute mount -ro loop /tmp/firstcd.iso /media.)

3.    Copy the required files from the first Red Hat Enterprise Linux installation CD. Use the cp -ar /source/. /var/ftp/pub/inst command, where source is the mount directory (such as /media/RHEL 5 i386 Disc 1). Don't forget the dot (.); it makes sure to copy hidden files, including the .discinfo file from the first Red Hat Enterprise Linux installation CD.

4.    Unmount the first Red Hat Enterprise Linux installation CD. If it's an installation DVD, skip to step 6. Use the umount /source command.

5.    Repeat steps 2, 3, and 4 with the remaining Red Hat Enterprise Linux installation CDs.

6.    Make sure there's nothing blocking access to your vsFTP server. If you're using SELinux, you'll also have to use the SELinux Management Tool to allow access to appropriate directories, and reboot your system to activate the             changes. While inelegant, the following command "flushes," or turns off, the standard Linux firewall from the local computer.

    # iptables -F

7.    Now you can activate the FTP server, vsFTP. The following commands assume that it's already running (which you can check using the service vsftpd status command):

    # service vsftpd stop
    # service vsftpd start

    When you install Red Hat Enterprise Linux from an FTP server, you'll need to remember the directory with the Red Hat installation files. For an FTP server, the right directory is relative to the basic /var/ftp directory. With these steps, the installation files are in /var/ftp/pub/inst; therefore, the correct directory is /pub/inst.

Tuesday, September 8, 2009

Different Methods to Install Linux

Most of the Linux Users can easily install Linux from CD/DVD. But there is one more time saving option to install Linux is called AskMethod installation. In another words we can call it as Network installation also. Ok so, here let's discuss one of the Network installation method here.

Creating NFS installation server

A NFS, it is the most common way to share files between Linux and Unix Computers. So, here first we will discuss how to setup NFS server and then i will show how to install it from NFS.

1. First create a directory where all your installation files will be placed.
    # mkdir /install

2. Now Insert the first Red Hat Enterprise Linux installation CD/DVD into its   drive. It'll get mounted automatically, using the name of the media; for example, my first RHEL installation CD is automounted in the /media/RHEL-5 i386 Disc 1 directory (including all of those spaces). Otherwise, you can manually mount the CD with a command such as
# mount /dev/cdrom /media.

3. Copy the required files from the first Red Hat Enterprise Linux installation CD. Use the
# cp -ar /source/. /install command,
where source is the mount directory (such as /media/RHEL 5 i386 Disc 1). Don't forget the dot (.); it copies hidden files, including the .discinfo file from the first Red Hat Enterprise Linux installation CD.

4. Unmount the first Red Hat Enterprise Linux installation CD. If it's an installation DVD, skip to step 6. Use the umount /source command.

If it is a CD Pls Repeat steps 2, 3, and 4 for all other CDs and copy everything from it.

5. Now Set up an NFS share. Add the following line to your /etc/exports file. You can use any text editor such as vi or the system-config-nfs utility (also known as the Graphical NFS Server Configuration tool).

Entry inside the file should look like below one...
/install       *(ro,sync)

Now, Export the shared directory by the command,

# exportfs -a

Make sure there's nothing blocking access to NFS. The default Red Hat Enterprise Linux firewall blocks access to an NFS server. While inelegant, the following command "flushes," or turns off, the standard Linux firewall from the local computer. If you've enabled SELinux, you'll also have to use the SELinux Management Tool to change the associated NFS boolean variable to "Allow the reading on any NFS file system". Don't forget to restart NFS to activate all of your changes.

Now just activate the NFS service. The following commands assume that it's already running (which you can check using the service nfs status command):

# service nfs stop
# service nfs start

Finally, you can check the status of your share. If it's working, you should see the contents of the /etc/exports directory when you run the following command:

# showmount -e

When you install Red Hat Enterprise Linux from an NFS server, you'll need the name of the installation directory-in this case, /install.

Sunday, September 6, 2009

Linux File System and Directory Structure


As we all know that Linux gets installed under / (root) file system and under / there are different sub directories, each has got separate task and meaning. Here is a list of all those directories and some explanation about them.

/
The root directory, it is a top level directory where our Linux gets installed.
/bin
Binary Directory; it stores all essential commands working under OS.
/boot
As the name suggests this directory holds all the files which are required to boot our Linux OS.
/dev
Hardware and Software device drivers for all the devices.
/etc
It holds all of the basic system configuration files for different services and utilities of Linux.
/home
Home directory for almost every user.
/lib
Program libraries for the Kernel and different command and other utilities.
/media
Mount point for removable devices likes floppy, DVDs, Pen Drives or Zip Drives etc.
/misc
The standard mount point for local directories mounted via the automounter.
/mnt
A legacy mount point; formerly used for removable media.
/net
The standard mount point for network directories mounted via the automounter.
/opt
Common location for third-party applications and their files.
/proc
Currently running kernel-related processes, including device assignments such as IRQ ports, I/O addresses, and DMA channels, as well as kernel configuration settings such as IP forwarding.
/root
The home directory of the root user.
/sbin
System administration commands.
/selinux
Currently configured settings associated with Security Enhanced Linux.
/srv
Commonly used by various network servers on non-Red Hat distributions.
/tftpboot
Included if the TFTP server is installed.
/tmp
Temporary files. By default, Red Hat Enterprise Linux deletes all files in this directory periodically.
/usr
Small programs accessible to all users. Includes many system administration commands and utilities.
/var
Variable data, including log files and printer spools.

So, this is a complete Directory Hierarchy of Linux OS. A person who wants to work with Linux OS he/she should have knowledge of this Directory Structure so He/She can work with it very smoothly.


About My Blog for Linux


As all of you IT savvy people are aware that Linux is Open Source Operating System widely used by our current IT Industry. Now a day Linux is used by so many people in the Industry. Major benefit of using Linux is it can be used in Desktop Computer to Server Computer in enterprise environment. In short it can be used for different services like Word Processing, Internet Surfing, Sharing of Files or Printer Sharing or even different server level utilities can be performed. Best part of this Operating System is that it works on almost all the platforms. Another thing about Linux is that it is freely licensed so it can be installed and used in as many as Systems.

OK anyways here through this blog I will try to cover up all possible technical aspects, some Tips and Tricks and some short of How To about different Linux Server based utilities. I will be updating this blog regularly so; you can go through with it on regular basis. First of all I will start with some basic part of Linux.