script to create multiple network interface in xen host – node/xenbr0-xenbr1-xend-config

Hi all, In this article we will learn how to setup multiple network interfaces for your virtual machine using xen. by default it creates 1 interface and 1 bridge interface but when you want to create more then 1 interfaces then you need to do some work manually.

please follow steps mentioned below and you will find it working.

First of all we will create a script as /etc/xen/scripts/network-xen-custom with the following content:

#!/bin/sh
# network-xen-custom
# Exit if anything goes wrong
set -e

# First arg is operation.
OP=$1
#shift
script=/etc/xen/scripts/network-bridge
case ${OP} in
start)
$script start vifnum=0 bridge=xenbr0 netdev=eth0
$script start vifnum=1 bridge=xenbr1 netdev=eth1
;;
stop)
$script stop vifnum=0 bridge=xenbr0 netdev=eth0
$script stop vifnum=1 bridge=xenbr1
br1 netdev=eth1
;;
status)
$script status vifnum=0 bridge=xenbr0 netdev=eth0
$script status vifnum=1 bridge=xenbr1 netdev=eth1
;;
*)
echo “Unknown command:${OP}”
echo ‘Valid commands are: start, stop, status’
exit 1
;;
esac

Now we need to Set correct permissions:
# chmod 755 /etc/xen/scripts/network-xen-custom

Then edit the /etc/xen/xend-config.sxp file to comment out your old configuration and add a new line to call the script we just created:
#(network-script network-bridge)
(network-script network-xen-custom)

In most cases just starting newer script works fine but if that does not work then restart the system for the new bridge interfaces to start up correctly.

Hope this will help to lot other people…

Install image based guest (sparse file). image-based-guest

How to install virtual machine on image based disk …

I will presume that you have a server running xend on it. In my case I am using CentOS 5.2 and xend 3.0.3. After your xen dom-0 server is ready we need to install dom-u on it. To install dom-u using sparse (image)file. please follow steps listed below.

Also, You need a local repository to install guest os quickly using kickstart method. please follow these two links if you want to prepare your own local yum repository and want to get sample of kickstart file.

  1. Create sparse file using command
    #dd if=/dev/zero of=/home/xenvm01.img bs=1M count=1 seek=4096.
    I am considering that you have enough disk space in /home partition and you want to install a virtual machine under that partition. please use relevent partition as per your choice. After this command completes successfully, you will see a image file xenvm01.img
  2. Now we need to install virtual maching using this image file as disk. use
    #virt-install -p –name=xenvm01 –location=http://10.10.10.1/centos53/ –bridge=xenbr0 –ram=512 –file=/home/xenvm01.img -x “ks=http://10.10.10.1/xenvm01.ks?ip=10.10.10.11”
  3. After installation is completed, you will able to login to newly installed virtual machine.
    Configuration for this xen guest (dom-U) is stored in /etc/xen/ directory. my configuration file looks like.

    name = “xenvm01”
    uuid = “056a8eb9-c5e8-dc42-1f5a-a048d9a58f74”
    maxmem = 512
    memory = 512
    vcpus = 1
    bootloader = “/usr/bin/pygrub”
    on_poweroff = “destroy”
    on_reboot = “restart”
    on_crash = “restart”
    vfb = [ ]
    disk = [ “tap:aio:/home/xenvm01.img,xvda,w” ]
    vif = [ “mac=00:16:3e:1f:c3:a4,bridge=xenbr0” ]

Use virt-install to install LVM based virtual machines (PVM).

There are few different options while you want to install virtual servers. you can also use default utility available with xen. virt-install is very famous among others. Its very simple and easy to use. In this article I will explain you how to install LVM based virtual server. I will assume that you have installation try available so that we can use kick start method to do quick install. If you don’t have installation tree available then please visit my previous article. “How to create local yum repository” available at http://www.linux4beginners.info/?q=node/local-centos-yum-repo.

Lets start :
In my case physical volume is /dev/sda2. to find out which device is setup as PV in your system, you can use

pvscan OR pv command

This command will also show you volume group name identified by VG.
if you want to find out VolumeGroup name then you can use vgscan command also. NOW…

First of all we will need to create a logical volume which will be a disk for your virtual server. There is no need to format this lvm as we are going to use it as a raw disk. to create a disk use following command. I presume that you have enough unused disk space available in your volume group.

#lvcreate -L20G -n xenvm00 VolGroup00

well done. now you have your disk (logical volume) named xenvm00 ready to install virtual machine.
use following command to install virtual machine.

  1. #virt-install -p –name=xenvm00 –location=http://www.linux4beginners.info/ –bridge=xenbr0 –file=/dev/VolGroup00/xenvm00 –ram=2048 -x “ks=http://1.2.3.4/xenvm00.ks

    In above command :
    -p specifies it is para virtualized system,
    –name specifies hostname of virtual system you are installing.
    –location tells the location of your local centos / redhat / fedora repository. Please change it as per your convenience.
    –bridge tells which network device to specify for VM.
    –file specifies the disk for installation for your virtual system.
    –ram specifirs how much memory to be allocated.
    -x is for extra arguments. in this scenario we have spceified kick start file location. sample kick start file is also listed below.

    Follow the screen and answer the questions asked. as we are installing it through kickstart method, it will ask you minimum questions only…

  1. #Sample kickstart configuration

    install
    url –url http://1.2.3.4/centos52_64/

    network –device eth0 –bootproto static –ip 192.168.X.Y –netmask 255.255.X.Y –gateway 192.168.X.Z –nameserver ns1,ns2 –hostname xenvm00
    lang en_US.UTF-8
    skipx
    langsupport –default=en_GB.UTF-8 en_GB.UTF-8 en_US.UTF-8
    keyboard uk
    reboot

    rootpw –iscrypted $1$1kdfjalsr8099404=-459qkfjdfoiaisfoalasdkfasdf0aw348r0
    firewall –enabled
    selinux –permissive
    authconfig –enableshadow –enablemd5
    timezone [put your timezone]
    bootloader –location=mbr –append=”console=ttyS0,115200 rhgb quiet”

    clearpart –all
    part /boot –fstype ext3 –size=256
    part pv.2 –size=0 –grow
    volgroup vg0 –pesize=32768 pv.2
    logvol swap –fstype swap –name=lvswap –vgname=vg0 –size=2048
    logvol / –fstype ext3 –name=lvroot –vgname=vg0 –size=4096
    logvol /usr –fstype ext3 –name=lvusr –vgname=vg0 –size=2048
    logvol /var –fstype ext3 –name=lvvar –vgname=vg0 –size=2048
    logvol /tmp –fstype ext3 –name=lvtmp –vgname=vg0 –size=2048

    #List of required packages to install. please add / remove packages or package groups as per your requirement.it
    #very straight forward and easy.

    %packages
    @text-internet
    @legacy-software-support
    @web-server
    emacs
    kexec-tools
    device-mapper-multipath
    e2fsprogs
    lvm2
    sendmail-cf
    grub
    sysstat
    net-snmp
    -htmlview
    -pinfo
    -redhat-menus
    -GConf2
    -gtk2
    -libnotify
    -notification-daemon
    -pango
    -paps
    -redhat-lsb
    -dosfstools
    -ppp
    -rp-pppoe
    -rdist
    ntp
    ruby
    gpm
    vim-common
    vim-minimal
    vim-enhanced
    xen
    kernel-xen
    kernel-xen-devel
    gcc

    %post

    rpm –import http://www.linux4beginners.info/centos52_64/RPM-GPG-KEY-redhat-release

    chkconfig pcscd off
    chkconfig ntpd on
    chkconfig kudzu off
    chkconfig iptables off
    chkconfig ip6tables off
    chkconfig firstboot off
    chkconfig xinetd off
    chkconfig smartd off
    chkconfig isdn off
    chkconfig rhnsd off
    chkconfig gpm off
    chkconfig xfs off
    chkconfig cups-config-daemon off
    chkconfig cups off
    chkconfig yum-updatesd off
    chkconfig bluetooth off
    chkconfig portmap on
    chkconfig nfs on
    chkconfig nfslock on
    chkconfig nscd on

    # make sure default runlevel is 3
    sed -i “s/^id:5:init/id:3:init/g” /etc/inittab

    #enable listening to break on serial
    sed -i “s/^kernel.sysrq = 0/kernel.sysrq = 1/g” /etc/sysctl.conf

    echo “ttyS0” >> /etc/securetty
    echo “as:123456:respawn:/sbin/agetty ttyS0 115200 -h vt100-nav” >> /etc/inittab

    # dom0_mem
    sed -i “s/\(.*kernel.*xen.gz.*$\)/\1 dom0_mem=1024M/” /boot/grub/grub.conf
    cat > /etc/xen/xend-config.sxp <(xend-unix-server yes)
    (xend-relocation-server yes)
    (xend-unix-path /var/lib/xend/xend-socket)
    (xend-relocation-port 8002)
    (xend-relocation-address ”)
    (xend-relocation-hosts-allow ‘^localhost$ ^xen$’)
    (network-script ‘network-bridge netdev=bond0’)
    (vif-script vif-bridge)
    (dom0-min-mem 256)
    (dom0-cpus 0)

    (vncpasswd ”)
    EOF

How to convert / migrate image based vm (guest / dom-U) to LVM based vm (virtual machine)-(Guest / dom-U) using xen.

Hi all, In this article we will learn how to install virtual machine on sparse file (image file) and how to migrate / move it to LVM based storage / disk. It is recommended to use LVM based partition to install virtual machines for productions environment, as you may experience performance issues if you use images (sparse files) to install virtual machine.

How to install virtual machine on image based disk …

I will presume that you have a server running xend on it. In my case I am using CentOS 5.2 and xend 3.0.3. After your xen dom-0 server is ready we need to install dom-u on it. First we will install dom-u using sparse (image)file. please follow steps listed below.

  1. Create sparse file using command
    #dd if=/dev/zero of=/home/xenvm01.img bs=1M count=1 seek=4096.
    I am considering that you have enough disk space in /home partition and you want to install a virtual machine under that partition. please use relevent partition as per your choice. After this command completes successfully, you will see a image file xenvm01.img
  2. Now we need to install virtual maching using this image file as disk. use
    #virt-install -p –name=xenvm01 –location=http://10.10.10.1/centos53/ –bridge=xenbr0 –ram=512 –file=/home/xenvm01.img -x “ks=http://10.10.10.1/xenvm01.ks?ip=10.10.10.11”
  3. After installation is completed, you will able to login to newly installed virtual machine.
    Configuration for this xen guest (dom-U) is stored in /etc/xen/ directory. my configuration file looks like.

    name = “xenvm01”
    uuid = “056a8eb9-c5e8-dc42-1f5a-a048d9a58f74”
    maxmem = 512
    memory = 512
    vcpus = 1
    bootloader = “/usr/bin/pygrub”
    on_poweroff = “destroy”
    on_reboot = “restart”
    on_crash = “restart”
    vfb = [ ]
    disk = [ “tap:aio:/home/xenvm01.img,xvda,w” ]
    vif = [ “mac=00:16:3e:1f:c3:a4,bridge=xenbr0” ]

    How to convert /migrate image based xen virtual machine (guest) to LVM based Guest

  4. To achieve this reult we need a volume group with free space not allocated to any logical volume. On my test system I’ve a volume group called “xenimg01” which has free space.
    [root@localhost ~]#vgdisplay
    — Volume group —
    VG Name xenimg01
    System ID
    Format lvm2
    Metadata Areas 1
    Metadata Sequence No 2
    VG Access read/write
    VG Status resizable
    MAX LV 0
    Cur LV 1
    Open LV 1
    Max PV 0
    Cur PV 1
    Act PV 1
    VG Size 50.00 GB
    PE Size 4.00 MB
    Total PE 12799
    Alloc PE / Size 3328 / 13.00 GB
    Free PE / Size 9471 / 37.00 GB
    VG UUID 5IZDY3-Vs4o-Zs26-p7sx-CaRk-8kdi-eX9fZC

    … You can see from the above output that it has approximately 37 GB free. If you remember correctly , in our previous section we created an image disk of size 4 GB (4096 MB) to install guest OS. To convert that image based guest to LVM based disk we need logical volume with exactly same size .i.e 4 GB (4096 MB). lets create a logical volume now.

  5. [root@localhost ~]#lvcreate -L4096M -n lvmxen01 xenimg01.
    Logical volume “lvmxen01” created

    We don’t need to format this logical volume. We will use it as raw disk to migrate / convert dom-u (guest) OS to it.
  6. Shutdown the dom-u we installed earlier.
    [root@localhost ~]#xm shutdown xenvm01

    After the xenvm01 virtual machine is donw completely you need to use command specified next to convert it to LVM based dom-U

  7. [root@localhost ~]#dd if=/home/xenvm01.img of=/dev/xenimg01/lvmxen01
    This process will take good amount of time. depending on resources available on server also. usually I have noticed it takes about 30 Minutes for image of 4GB.
  8. Once the command listed in above step completes successfully, we need to make a change in configuration file for dom-U. edit /etc/xen/xenvm01 file and change the disk parameter as mentioned below.
    name = “xenvm01”
    uuid = “056a8eb9-c5e8-dc42-1f5a-a048d9a58f74”
    maxmem = 512
    memory = 512
    vcpus = 1
    bootloader = “/usr/bin/pygrub”
    on_poweroff = “destroy”
    on_reboot = “restart”
    on_crash = “restart”
    vfb = [ ]
    disk = [ “phy:/dev/xenimg01/lvmxen01,xvda,w” ]
    vif = [ “mac=00:16:3e:1f:c3:a4,bridge=xenbr0” ]

    As specified disk value need to be changed from disk = [ “tap:aio:/home/xenvm01.img,xvda,w” ] to disk = [ “phy:/dev/xenimg01/lvmxen01,xvda,w” ]

  9. Now start the guest os with following command
    xm create -c xenvm01. This will start your dom-U guest from logical volume /dev/xenmg01/lvmxen01

    Hope this article will help lots of other people as it helped a lot to me.

What is Linux

What is Linux?

Linux is an operating system that evolved from a kernel created by Linus Torvalds when he was a student at the University of Helsinki. Generally, it is obvious to most people what Linux is. However, both for political and practical reasons, it needs to be explained further. To say that Linux is an operating system means that it’s meant to be used as an alternative to other operating systems like MS-DOS, the various versions of MS Windows, Mac OS, Solaris and others. Linux is not a program like a word processor and is not a set of programs like an office suite.

A brief history of Linux

When Linus Torvalds was studying at the University of Helsinki, he was using a version of the UNIX operating system called ‘Minix’. Linus and other users sent requests for modifications and improvements to Minix’s creator, Andrew Tanenbaum, but he felt that they weren’t necessary. That’s when Linus decided to create his own operating system that would take into account users’ comments and suggestions for improvements.

Free Software pre-Linux

This philosophy of asking for users’ comments and suggestions and using them to improve computer programs was not new. Richard Stallman, who worked at the Massachusetts Institute of Technology, had been advocating just such an approach to computer programming and use since the early 1970’s. He was a pioneer in the concept of ‘free software’, always pointing out that ‘free’ means ‘freedom’, not zero cost. Finding it difficult to continue working under conditions that he felt went against his concept of ‘free software’ he left MIT in 1984 and founded GNU. The goal of GNU was to produce software that was free to use, distribute and modify. Linus Torvalds’ goal 6 years later was basically the same: to produce an operating system that took into account user feedback.
The kernel

We should point out here that the focal point of any operating system is its ‘kernel’. Without going into great detail, the kernel is what tells the big chip that controls your computer to do what you want the program that you’re using to do. To use a metaphor, if you go to your favorite Italian restaurant and order ‘Spaghetti alla Bolognese’, this dish is like your operating system. There are a lot of things that go into making that dish like pasta, tomato sauce, meatballs and cheese. Well, the kernel is like the pasta. Without pasta, that dish doesn’t exist. You might as well find some bread and make a sandwich. A plate of just pasta is fairly unappetizing. Without a kernel, an operating system doesn’t exist. Without programs, a kernel is useless.

1991, a fateful year

In 1991, ideal conditions existed that would create Linux. In essence, Linus Torvalds had a kernel but no programs of his own, Richard Stallman and GNU had programs but no working kernel. Read the two men’s own words about this:

Linus: “Sadly, a kernel by itself gets you nowhere. To get a working system you need a shell, compilers, a library etc.”
RMS: The GNU Hurd is not ready for production use. Fortunately, another kernel is available. [It is called] Linux.

So combining the necessary programs provided by GNU in Cambridge, Massachusetts and a kernel, developed by Linus Torvalds in Helsinki, Finland, Linux was born. Due to the physical distances involved, the means used to get Linus’ kernel together with the GNU programs was the Internet, then in its infancy. We can say then that Linux is an operating system that came to life on the Internet. The Internet would also be crucial in Linux’s subsequent development as the means of coordinating the work of all the developers that have made Linux into what it is today.

Linux is introduced

Late in 1991, Linus Torvalds had his kernel and a few GNU programs wrapped around it so it would work well enough to show other people what he had done. And that’s what he did. The first people to see Linux knew that Linus was on to something. At this point, though, he needed more people to help him. Here’s what Linus had to say back in 1991.
“Are you without a nice project and dying to cut your teeth on an OS you can try to modify for your needs?… This post might just be for you.”
People all over the world decided to take him up on it. At first, only people with extensive computer programming knowledge would be able to do anything with that early public version of Linux. These people started to offer their help. The version numbers of Linux were getting higher and higher. People began writing programs specifically to be run under Linux. Developers began writing drivers so different video cards, sound cards and other gadgets inside and outside your computer could use Linux. Nevertheless, throughout most of first part of the 1990’s Linux did not get out of the ‘GURU’ stage. GURU is a term that has evolved to mean anyone who has special expertise in a particular subject. That is, you had to have special expertise in how computers worked to be able to install Linux in those days.

Linux, at first, not for everybody

Other popular software companies sold you a CD or a set of floppies and a brief instruction booklet and in probably less than a half an hour, you could install a fully working operating system on your PC. The only ability you needed was knowing how to read. Those companies had that intention when they actually sat down and developed their operating systems. Linus Torvalds didn’t have that in mind when he developed Linux. It was just a hobby for him. Later on, companies like Red Hat made it their goal to bring Linux to the point where it could be installed just like any other operating system; by anyone who can follow a set of simple instructions, and they have succeeded. For some reason, though, Linux hasn’t completely lost its ‘Gurus only’ image. This is largely because of the popular tech press’ inability to explain in a meaningful way what Linux is. The truth is that few tech reporters have real life experience with Linux and it is reflected in their writing.

Linux Today

Today, Linux is enjoying a favorable press for the most part. This comes from the fact that Linux has proven to be a tremendously stable and versatile operating system, particularly as a network server. When Linux is deployed as a web server or in corporate networks, its down-time is almost negligible. There have been cases when Linux servers have been running for more than a year without re-booting and then only taken down for a brief period for routine maintenance. Its cost effectiveness has sold it more than anything else. Linux can be installed on a home PC as well as a network server for a fraction of the cost of other companies’ software packages. More reliability and less cost – it’s ideal.

If you’re reading this, you’re obviously here to learn how to use Linux. Any learning experience means opening up to new ideas and new ways of doing things. As mentioned before, Linux is in the UNIX family of operating systems. UNIX is primarily designed to be used by professionals. You will have to learn some UNIX concepts in this lesson, but that doesn’t mean that Linux is a professionals-only operating system. In fact, most major versions of Linux are designed to be as user-friendly and as easy to install as any other operating system on the market today.

Now that you know what Linux is and how good it is, there’s one more thing we have to do – install Linux!

Main Features on GNU/Linux.

1. Low Cost
2. Stability.
3. Speed.
4. Graphical Interface.
5. Performance.
6. Networking.
7. Security.
8. Open Source.
9. Reliability.
10. Scalibility.

Facts about GNU/Linux.

This is a list of things that all can easily do in GNU/Linux but find it hard or impossible to do in other desktop operating system.

* Connect more than four people across the internet to a graphical interface at the same time.
* Tinker around with the source code.
* Compile your own GNU/Linux from scratch.
* Have as many or as little programs installed as you want.
* Change every aspect of the user interface to suit your needs.
* Never pay for any program.
* Use more of your computer memory for programs and not for the operating system.
* Use less than one gigabyte of hard disk space for operating system.
* Use it on older hardware.
* Easily automate any task.
* Create your own commands.
* Configure, update and restart every aspect of your computer remotely.
* Run graphical programs on local screen from a remote connection.
* Start a program, put it in background, close your connection and when you reconnect you can still interact
with the same program.
* Never ever worry about virus’s or malware.
* Not have to worry about DRM.
* Update all installed programs at the same time and completely automatically.
* Easily and cleanly uninstall all parts, including configuration files of programs.
* Not have to reinstall operating system because it is slowing down.
* Easily transfer your personal settings to any gnu/linux computer.
* Easily run your own Linux on any computer from a flash drive.
* Setup an Terminal Server and use any computer to connect and use GUI interface without installing OS.
* Not have to activate your operating system and give information about your computer to any company.
* No more typing of product keys or worrying about losing them.
* Never see a nagscreen or have a program crippled because I used it beyond the demonstation time limit.
* Never have to restart the machine because a program other than the kernel requires more resources.
* Compile your own GNU/Linux kernel to suit your own machine to match your needs.

vim Basics

In this tutorial I will share some vim basics. Vim is a powerful text editor used in CLI (command line interface). Because gnu/linux uses a lot of configuration files which are all in clear text format, you’ll often need to edit them and vim (in short vi) is a great tool to use.

vim (vi) has a particular working method. Indeed there are to main mods : command and other mods, so if you get familier with some basics then it will be a very good starting point.

The command mod lets you select the mod you want to enter to, save, quit, copy, paste and that kind of things but you can’t edit the file in this mod.

There are several other mods. In this article I’ll only speak about those I often use.

After opening a new OR existing file in vim editor with vim you can try mods listed here.

Insert mod : lets you insert text in a document. Shotcurt : “i” (insert where the cursor is) or “o” (insert at the beginning of the following line).

Visual mod : permits to select the text like you would do with a mouse but using the keyboard instead of the mouse. Useful to copy several lines for example. Shotcurt : V

Let’s now speak about the command mod.

A command begins with the symbol “:”.

When you are in another mod you can use the escape key (sometimes you’ll need to hit it twice) to come back to command mod at any time.

save : :w
save and exit : :wq
exit : :q
force : ! (example :w! :q!)
vertical split : open a document and then type :vsplit /path-to-document/document and this will open the specified document and split the screen so you can see both documents.
copy : y
copy a line : yy
paste : p
cut : d
cut a line : dd

I repeat these are very basic commands for vim, but they are very useful, and I hope this will help you configuring your Linux.

View text files (config files) without comments using grep / egrep

Hi all, here you will learn something very interesting about grep with regexp. I’ve been using grep since many years to trim comments out of config files. We need coments in config files to provide details but sometimes when you want to look through files quickly then comments can get in your way. I’ve found files hundreds of lines long which had fewer than ten active configuration lines, it’s really hard to get an overview of what’s going on when you have to search / walk through hundreds of lines of comments.

  • using following syntax on command line you can ommit comments and just view imp configuration.
    $ grep ^[^#] /etc/ntp.conf

    The regex ^[^#] matches the first character of any line, as long as that character that is not a #. Because blank lines don’t have a first character they’re not matched either, resulting in a nice compact output of just the active configuration lines.

  • i also use this a lot just in case if there are any spaces in front.
    I also use a lot:
    $ egrep -v “^[[:space:]]*#|^$” /etc/ntp.conf

Tips-n-Tricks – All valuable tips and tricks for gnu/linux fans

  1. SSH Tunneling (Port Forwarding)
  2. Cube Effects in Ubuntu 7.10 (Gusty Gibbon)
  3. Installing LAMP (Linux, Apache, Mysql, PHP) in Ubuntu
  4. Quick steps to setup TRIPWIRE – Host Based Intrusion Detection System
  5. Create CSR (Certificate Request) using openssl in Linux
  6. Recover MySQL root password
  7. Nagios Quickstart installation guide (Fedora/CentOS)

  8. Add swap space on the fly

  9. Create big size files in unix and linux with dd command

  10. Create big trees of directory in unix and linux with single command

  11. Monitor your Linux or unix live servers with top command

  12. We can do spell check in vi editor while editing it on Linux or unix live servers.

  13. We can have Colorful Tabs in Firefox Web Browser on our Linux Desktop machines.

  14. We can easily access Remote machine from our Linux Desktop.

  15. Save time by using ps command with writing small shell script on Linux/unix desktop and Servers.

  16. Automate execution of shell script owned by non-root user at booting

  17. Create LVM based virtual servers using virt-install

The Boot Process

The basic stages of the boot process of LINUX Operating System for an x86 system:

1. The system BIOS checks the system and launches the boot loader on the MBR [ MBR stands for Master Boot Record, which occupy 512 Bytes only.]
2. The boot loader loads itself into memory and launches the boot loader from the /boot/ partition.
3. Then boot loader loads the kernel into memory, which in turn loads any necessary modules and mounts the root partition read-only.
4. Then the kernel transfers control of the boot process to the /sbin/init program.
5. Then the /sbin/init program loads all services and user-space tools, and mounts all partitions listed in /etc/fstab file.
6. Then the user is presented with a login screen to get login into system.

Note:- MBR contains machine code instructions for booting the machine, called a boot loader along with the partition table.

Note that boot loader do not load more than one Operating System at a same time, even if the machine is “multi-boot” system.

Little Detail Look in Boot Process.
The GRUB has the advantage of being able to read ext2 and ext3 partitions and then load its configuration file from /boot/grub/grub.conf — at boot time.

The Kernal is a core of Linux. It loads into RAM, at the time of machine boots, and it runs until the computer is shutdown.

The initramfs is used by the Linux kernel to load different drivers and modules necessary to boot the system.

After it once the kernel and the initramfs image(s) are loaded into memory, the boot loader hands control of the boot process to the kernel.

Now when the kernel is loaded, it will immediately initializes and configures the system’s memory and configures the various hardware which are attached to the system, which includes processors, storage devices and some others.

And kernel then creates a root device, mounts the root partition read-only, and frees any unused memory.

Now after it to set up the user environment, the kernel executes the /sbin/init program.

The /sbin/init program which is also called as “init” coordinates the rest of the boot process and configures the environment for the system user.

The init daemon is one of the most important Linux daemon. Because it creates the processes for the rest of the system.

Note :- Daemon—Daemon is the program which runs in the background.

When daemon command start, it will runs the /etc/rc.d/rc.sysinit script, which sets the environment path, starts swap, checks the file systems, and executes all other steps required for system initialization

The init program is usually kept in /bin directory, and some distributions of linux keeps it in /sbin. The configuration files are always kept in /etc.

The init daemon is executed when linux starts and stay active until linux system is get shut down.

When the init daemon is executed, it will reads instructions from the file /etc/inittab, which is primarily used to start getty processes for terminals and other processes required by the linux system.

While examining the /etc/inittab file, init searches for an entry labeled initdefault, which sets the default initial run level of the system.

If no initdefault level is defined in the /etc/inittab file, the system prompts for the level.

Runlevels are a state, or mode, defined by the services, which is listed in the SysV /etc/rc.d/rc.d/ directory, where is the number of the specific runlevel

The init daemon knows which processes are associated with each run level from information in the /etc/inittab file.

The Boot Loader GRUB

The Boot Loader is mainly used for following purpose,

[1] For selecting an Operating System from different option.
[2] For locating the kernel.
[3] When we need to identify the partition.

The GRand Unified Boot loader (GRUB) is the default bootloader for RedHat linux.
passwd,ubuntu,suse,centos,debain,slackware,mandrake,fedora,knopix
1. It is password protected boot loader.
2. We can easily edit GRUB during boot process.
3. We can change different parameter in GRUB configuration file, without making any permanent changes in it.linux how tos, linux-how-tos, linux-howto, useradd, adduser, ls, dir, pwd,

4. Another good advantage of GRUB is that, it supports Logical Block Addressing.

( LBA ) mode, so it can help system to findout the /boot files.

1. The main GRUB configuration file is /boot/grub/grub.conf, for it is also linked to /etc/grub.conf for convenience in use.

The main configuration file of GRUB. /boot/grub/grub.conf

# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,5)
# kernel /vmlinuz-version ro root=/dev/hdc7
# initrd /initrd-version.img
#boot=/dev/hdc
default=0
timeout=5000
splashimage=(hd0,5)/grub/splash.xpm.gz
hiddenmenu
title Fedora Core (2.6.11-1.1369_FC4)
root (hd0,5)
kernel /vmlinuz-2.6.11-1.1369_FC4 ro root=LABEL=/1 rhgb quiet
initrd /initrd-2.6.11-1.1369_FC4.img
title Other
rootnoverify (hd0,0)
chainloader +1

The main GRUB VARIABLES

[1] password — It is used to protect GRUB with use of –md5 encryption.
[2] default — It will specifies the default operating system. E.g., if the default=0, then what ever the title in first line will boots automatically.
[3] timeout — It shows the time before which GRUB starts.
[4] splashimage — It shows the GURB’s image.
[5] title — It will show the options of GRUB menu which you find on screen at
start time.
[6] root — This root will indicates the partition with /boot files.
[7] kernel — Linux kernel’s location.
[8] initrd — Initial RAM disks’s location.
[9] rootnoverify — It configures the root partition for GRUB, just like the root command, but it will does not mount the partition.
[10] chainloader — It will loads the specified file as a chain loader.

linux how tos, linux-how-tos, linux-howto, useradd, adduser, ls, dir, pwd, groupadd, passwd, redhat, ubuntu, festi, suse, centos, debain, slackware, mandrake, fedora, knopix

Add swap space on-the-fly

In Linux, as in most other Unix-like operating systems, it is common to use a whole partition of a hard disk for swapping. However, with the 2.6 Linux kernel, swap files are just as fast as swap partitions, although Red Hat recommends using a swap partition. The administrative flexibility of swap files outweighs that of partitions; since modern high capacity hard drives can remap physical sectors, no partition is guaranteed to be contiguous. You can add swap file as a dedicated partition or use following instructions to create a swap file.
Procedure to add a swap file

You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.

a) Login as the root user
b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):
# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
c) Set up a Linux swap area:
# mkswap /swapfile1
d) Activate /swapfile1 swap space immediately:
# swapon /swapfile1
e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
# vi /etc/fstab
Append following line:
/swapfile1 swap swap defaults 0 0
So next time Linux comes up after reboot, it enables the new swap file for you automatically.
g) How do I verify swap is activated or not?
Simply use free command:
$ free -m