Make Your Own Linux

Discussion in 'Linux' started by Tango Issac Debian, Jul 6, 2006.

  1. Tango Issac Debian

    Tango Issac Debian New Member

    Joined:
    May 3, 2006
    Messages:
    31
    Likes Received:
    1
    Trophy Points:
    0
    Linux now become the platform of the developers.They now feeling very excited in their colorful life with Linux.Some of them are thinking Linux as their wife!They always spending with Linux.They can now explain themselves more significantly to the total developer's world with their Personal Linux.They generate the sense of the Linux as more powerful,reliable,flexiable and scalable in the total developer's world.......They make it too flexible to support for multitude of multiprocessor's architechture,hardware devices,graphical support and communication protocols.

    Some days ago,I have done an experiment with my friend's old unused PC for our target project.Our targets were---------------------

    • Develop a boot loader to run on the PowerON
    • A configured linux kernel
    • A sweet file-system all with the necessary software.

    HARDWARE USED:


    • A P2 machine
    • A 16MB RAM
    • 2GB HDD
    • A AMD Athlon 64 2800+(1.8GHz)machine as a host for our development

    Maintaining the development Environment:



    In this case,the development process has done on the host system,taking the targeting system as the consideration,because of the high memory,advantage of the lower compile time of the host machine.Here,the concept of the "Cross-compilation "is needed.Because the CROSS_COMPILER is a system that runs on one type of processor,but compiles instructions for the another.

    Setting up the HOST



    Though the presence of the different several processes I have used here "REMOVABLE STORAGE SETUP", where there are no direct physical link between the host and the target.Actually, a storage device is written by the host and is transferred into the target,which is used to boot the target system.

    Preparation for the Host Environment


    1. Install a latest Linux edition of REDHAT,or other similar.
    2. Format the target HDD with a suitable file system.(I prefer ext2).
    3. The host system should have "Cross-Compiler toolchain" to build up the software for the target system.I have used GNU's cross Platform developent toolchain.I also used
      • Binary Utilities (Assembler,linker and Various Object file Utilities).
      • The GCC compiler for GNU C,C++
      • The C Library(like glibc,newlib etc.)

    Binding up our personal Toolchaon



    Here , an alternative C library like "uClibc" is choosen for my personal system development.The "uClibc" is a C library optimized for embedded systems.

    To build up our custom toolchain I have performed some steps as --------

    With the open source Automation tools like "buildroot" I have configured the toolchain and installed it in "uClibc" version, "binutils" version, GCC version and so on.

    After the succesful toolchain compilation,it has installed in a specific PATH environment variable to the "bin" directory of the installed path.

    Having the cross development platform ready,we need three components to build up a complete Linux environment for an embedded system.
    • The Kernel
    • The Root file System
    • The Boot Loader

    Setting up the KERNEL:



    First download the Linux kernel from "www.kernel.org" (say as inux2.4.20.tar.bz2) and extract it and cd to the directory.Now ,feel the thrillings that U'r ready now to compile the chossen kernel with your new toolchain.So, edit the "makefile" to set up the "CROSSCOMPILE" prefix using

    CROSSCOMPILE =i386-linux-uclibc

    Then configure the kernel according to the embedded target device requirements using

    make menuconfig or make xconfig.

    Then issue the "make dep" and "make bzImage" commands.

    The kernel image is now built in the "arch/i386/boot" directory. If the modules r enabled,implement "make modules",and " make modules-install" . The compiled modules will be installed in " /lib/modules/linux-<version>".

    Creating the Root File System



    I have created the root file system on the previous "ext2" formatted HDD.FIrst, we mount the partition as SUPER USER,by

    #mount -t ext2 /dev/hdc1 /mnt/target

    Now enter to the /mnt/target dir and create a standard Linux root directory structure.

    #mkdir bin boot dev etc etc/init.d proc sbin usr

    Create "modules" directory in "lib" if modules were enabled.

    #mkdir /lib/modules

    Now set appropriate permissions for these directories.To set up various core linux utilities like sh,ls,cp,clear,mkdir.......Fortunately u can get a tool that combines all the utilities called " BUSYBOX".Busybox is highly configureable,and u can select only those utilities u want to for your platform.U can select also static or dynamic compilation.

    Compile it with your new toolchain.

    $ make
    $ make PREFIX= /mnt/target install

    This will populate bin,sbin,usr,usr directories with all symlinks to "busybox" binary in /mnt/target/bin directory.

    Then,the boot directory needs to be generated with your previous compiled kernel image. U need to create the necessary device nodes appropriately in the "dev" directory using "mknod" utility; for example, the terminal devices like "tty", console , virtual terminal devices for VGA display,serial terminal devices,the ps mouse,null device etc.

    Next set up the various startup scripts .Create a "rcS" script in " etc/init.d/"

    #! /bin/sh
    mount -a #Mount the default file system mentioned in /etc
    /fstab
    /bin/sh #Invoke Busybox shell

    Create "fstab " file in /etc directory
    Create "inittab" file in /etc directory

    #This is run as first script
    :: sysinit : /etc/init.d/rcS
    ::askfirst :-/bin/sh
    ::restart : /sbin/init
    ::ctrlaltdel:/sbin/reboot
    ::shutdown:/bin/unmount -a -r >/dev/null 2>&1
    Thse script may be customizesd according to the target requirements.

    INSTALLING THE BOOT LOADER



    To make first bootable Personal linux system u need to install the Boot Loader.Copy the Stage1 ,Stage2 dir.s of GRUB from the host machine into target's boot/GRUB directory.Install the GRUB on the target hard disk.

    #/sbin/GRUB
    #GRUB> root(hd1,0)
    #GRUB> setup(hd1)

    Now ,u need to edit 'etc/GRUB.conf as shown below:

    #Assuming the Storage device will be installed as first
    #harddisk.
    title MYPERSONAL LINUX
    root(hd0,0)
    kernel /boot/bzImage ro root=/dev/hda1

    Atlast,the GRUB should be compiled with our cross toolchain.

    READY TO ENJOY



    Shut down the host system.Remove the target HDD and install it on the target system.Power on this machine.See the GRUB menu.Select your choice.If choice the MYPERSONAL LINUX,your linux system get booted,and a Busybox shell promt should appear..

    Now Start to enjoy........with Your Personal Linux System.

    (At the last,Give greatful thanks to LINUS TORVALD ).

    Resources:
    1. www.kernel.org
     
    boki likes this.
  2. ManzZup

    ManzZup New Member

    Joined:
    May 9, 2009
    Messages:
    278
    Likes Received:
    43
    Trophy Points:
    0
    Occupation:
    Production Manager:Software @ ZONTEK
    Location:
    Sri Lanka
    Home Page:
    http://zontek.zzl.org
    great one
    gotta try this instead of LFS :)
     
  3. dibinwebtech3

    dibinwebtech3 Banned

    Joined:
    Mar 27, 2012
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    seo
    Home Page:
    http://www.munnarhotels.org.in/place-to-visit-in-munnar.html
    Grub installation very good and great pleasure
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice