2011年4月8日 星期五

Linux Kernel Compile


. Update to the latest package information
  #apt-get update
  #apt-get upgrade

. Install the related packages for kernel compile
  #apt-get install debhelper module-init-tools kernel-package 
   libncurses5-dev libncurses5 build-essential bin86 fakeroot
. Download the Kernel-Sources from the below site and put 
  them under the path /usr/src :
  http://security.ubuntu.com/ubuntu/pool/main/l/linux/
  (1) linux_2.6.35.orig.tar.gz
  (2) linux_2.6.35-22.33.diff.gz (Patch for kernel 2.6.35)

. Unzip the kernel file :
  # cd /usr/src; tar zxvf linux_2.6.35.orig.tar.gz
  # cd linux-2.6.35/

. Patch the latest patch file
  # zcat ../linux_2.6.35-22.33.diff.gz | patch -p1
. # cp -vi /boot/config-`uname -r` .config
. # make menuconfig












. Under kernel compile interface :
  Press<Y>includes<N>excludes<M>modularizes features
  Press<ESC><ESC>to exitLegend : [*]built-in [ ]excluded
  <M>module <> module capable
. Clean up the kernel
  # make-kpkg clean
. Start to compile the kernelthe more items selectedthe more
  time will be takenalso depends on the system speed
  # fakeroot make-kpkg --initrd --revision=xxxxx kernel_image
     kernel_headers
After compile is donethere are two files produced in /usr/src :
  linux-headers-2.6.35.4_xxxxx_i386.deb
  linux-image-2.6.35.4_xxxxx_i386.deb

. Install the just compiled kernel files :
# cd /usr/src
# dpkg -i linux-headers-2.6.35.4_xxxxx_i386.deb
# dpkg -i linux-image-2.6.35.4_xxxxx_i386.deb 

. Install the initial RAM Disk
  # mkinitramfs -v -o /boot/initrd-2.6.35.4 2.6.35.4

. Check the kernel file and initial Ram Disk file have been located
  in path /boot.
  # ls -al /boot/vmlinuz-2.6.35.4
  # ls -al /boot/initrd-2.6.35.4

. If you use this Ubuntu's grub as bootloader,the menu.lst should be
  updated automatically,change path to /boot/grub,check the
  content of menu.lst,if no problem,then can use the new kernel to
  boot
  # cd /boot/grub
  # vim ./menu.lst

. Before executing the below command :
  # apt-get purge linux-headers-2.6.32-25
  # apt-get purge linux-headers-2.6.32-25-generic
  # apt-get autoremove











. After executing the below command :
  # apt-get purge linux-headers-2.6.32-25
  # apt-get purge linux-headers-2.6.32-25-generic
  # apt-get autoremove












. Before executing the below command :
  # apt-get purge linux-image-2.6.32-25-generic
  # apt-get autoremove










. After executing the below command :
  # apt-get purge linux-image-2.6.32-25-generic
  # apt-get autoremove










. Before executing the below command :
  # apt-get purge linux-image-2.6.32-25-generic
  # apt-get autoremove











. After executing the below command :
  # apt-get purge linux-image-2.6.32-25-generic
  # apt-get autoremove











The related PowerPoint file will be downloaded from the below
address : 
Linux Kernel Compile  

2011年1月28日 星期五

Customize Ubuntu Desktop Live CD

Linux refers to the family of Unix-like computer operating systems using the Linux kernel。 Linux can be installed on a wide variety of computer hardware,ranging from mobile phones, tablet computers and video game consoles,to mainframes and supercomputers。Linux is a leading server operating system,and runs the 10 fastest supercomputers in the world。

Ubuntu is a computer operating system based on the Debian GNU/Linux distribution and distributed as free and open source software。It is named after the Southern African philosophy of Ubuntu ("humanity towards others")。

With an estimated global usage of more than 12 million users,Ubuntu is designed primarily for desktop use,although netbook and server editions exist as well。Web statistics suggest that Ubuntu's share of Linux desktop usage is about 50%,and indicate upward trending usage as a web server。

Ubuntu is sponsored by the UK-based company Canonical Ltd.,owned by South African entrepreneur Mark Shuttleworth。Canonical generates revenue by selling technical support and services tied to Ubuntu,while the OS itself is entirely free of charge。

Linux is one OS which has the easy way to customize it by yourself,and no any extra fee is needed,Ubuntu is a rising star in the mainstream Linux market in these years,the below methodology describes the steps how to customize the Ubuntu Desktop Live CD easily。
    .Install the tool for creating squashfs filesystem.
        $ sudo apt-get install squashfs-tools

    .Mount the ISO file under /tmp/livecd
        $ mkdir /tmp/livecd
        $ sudo mount -o loop ~/Desktop/ubuntu-10.04.1-desktop-i386.iso
          /tmp/livecd

    .Create a directory containing the future CD image named ”cd” 
        in working directory named ”~/livecd”and copy all the CD 
        content but exclude casper/filesystem.squashfs in ~/livecd/cd 
        directory.
        $ mkdir ~/livecd
        $ mkdir ~/livecd/cd
        $ rsync --exclude=/casper/filesystem.squashfs -a /tmp/livecd
          ~/livecd/cd

    Mount casper/filesystem.squashfs onto a directory named 
       ~/livecd/squashfs in order to copy its content in a directory 
       where we are going to edit live CD filesystem : ~/livecd/custom
        $ mkdir ~/livecd/squashfs
        $ mkdir ~/livecd/custom
        $ sudo modprobe squashfs
        $ sudo mount -t squashfs -o loop /tmp/livecd/casper/
           filesystem.squashfs ~/livecd/squashfs/
        $ sudo cp -a ~/livecd/squashfs/* ~/livecd/custom

    Copy /etc/resolve.conf /etc/hosts /etc/wgetrc to ~/livecd 
        /custom/etc and copy /etc/apt/apt.conf to ~/livecd/custom
        /etc/apt/ so we can access network from within the image 
        we are going to customize through.
        chroot :
        $ sudo cp /etc/resolve.conf /etc/hosts ~/livecd/custom/etc
        $ sudo cp /etc/apt/apt.conf ~/livecd/custom/etc/apt/
        $ sudo cp /etc/wgetrc ~/livecd/custom/etc/

    For customize the imagechroot into ~/livecd/custom 
        directorymount some necessary pseudo-filesystem (/proc 
        and /sys)From therewe will be able to customize our Live 
        CD.
        $ sudo chroot ~/livecd/custom
        # mount -t proc none /proc/
        # mount -t sysfs none /sys/
        # export HOME=/root

    Install text editor ”vim”
        # apt-get install vim

    Custom Background for GNOME
        Put a picture (DSC03920.JPG) which used for customized
        background in below path :

        /usr/share/backgrounds

        Add the below section in the file ”/usr/share/gnome-
        background-properties/ubuntu-wallpapers.xml”
        
        <wallpaper>
        <name>DSC03920</name>
        <filename>/usr/share/backgrounds/DSC03920.JPG</filename>
        <options>zoom</options>
        <pcolor>#091d5c</pcolor>
        <scolor>#091d5c</scolor>
        <shade_type>solid</shade_type>
        </wallpaper>

        Modify the file ”/usr/share/gconf/defaults/16_ubuntu-wallpapers”
        to point to the path of customized filesomething like this :
        /desktop/gnome/background/picture_filename "/usr/share
        /backgrounds/DSC03920.JPG”
        /desktop/gnome/background/picture_options "zoom”
        /desktop/gnome/background/color_shading_type "solid"
        /desktop/gnome/background/primary_color "#091d5c”
        /desktop/gnome/background/secondary_color "#091d5c”
       
        Search the section ”background” in the file ”/var/lib/gconf/
        debian.defaults/%gconf-tree.xml” and modify it for the
        corresponding value,something like this :
          
        <dir name="background">
        <entry name="picture_options" mtime="1281952284" type="string">
        <stringvalue>zoom</stringvalue>
        </entry>
        <entry name="picture_filename" mtime="1281952284"
        type="string">
        <stringvalue>/usr/share/backgrounds/DSC03920.JPG
        </stringvalue>
        </entry>
        <entry name="color_shading_type" mtime="1281952284"
        type="string"> 
        <stringvalue>solid</stringvalue>
        </entry>
        <entry name="secondary_color" mtime="1281952284" 
        type="string">
        <stringvalue>#091d5c</stringvalue>
        </entry>
        <entry name="primary_color" mtime="1281952284"
        type="string">
        <stringvalue>#091d5c</stringvalue>
        </entry>
        </dir>

     .We will remove gnome-gamesnon-english language 
         packagesand openoffice.org-math
         # apt-get remove --purge gnome-games*
         # apt-get remove –purge gbrainy
         Modify the file ”/var/lib/locales/supported.d/local” as
         en_US.UTF-8 UTF-8
         Modify the file ”/etc/default/locale” as LANG="en_US.UTF-8"
         LANGUAGE="en_US:en"
         # apt-get remove --purge `dpkg-query -W --showformat=
         '${Package}\n' | grep language-pack | egrep -v '\-en'`
       
         To check all the installed packages, executing the below
         commands :
         # dpkg-query -W --showformat='${Package}\n' | less or
         # dpkg-query -W --showformat='${Package}
         ${Version}\t${Maintainer}\n'
         Remove openoffice.org-math package :
         # apt-get remove –purge openoffice.org-math

    Open and edit the file /etc/apt/sources.list, and make it look 
        like :
        # vim /etc/apt/sources.list
        deb http://archive.ubuntu.com/ubuntu lucid main restricted
        universe multiverse
        deb-src http://archive.ubuntu.com/ubuntu lucid main restricted
        universe multiverse
        deb http://archive.ubuntu.com/ubuntu lucid-updates main
        restricted universe multiverse
        deb-src http://archive.ubuntu.com/ubuntu lucid-updates main
        restricted universe multiverse
        deb http://security.ubuntu.com/ubuntu lucid-security main
        restricted universe multiverse
        deb-src http://security.ubuntu.com/ubuntu lucid-security main
        restricted universe multiverse

    Update the image :
        # apt-get update
        # apt-get dist-upgrade

    Install all the multimedia packages we may need :
        # apt-get install gstreamer0.10-ffmpeg gstreamer0.10-plugins-ugly
        gstreamer0.10-plugins-ugly-multiverse gstreamer0.10-plugins-bad
        gstreamer0.10-plugins-bad-multiverse vlc mplayer mplayer-fonts
        # cd /usr/share/doc/libdvdread4/
        # ./install-css.sh

    Download ”libdvdcss2_1.2.10-0.2medibuntu1_i386.deb” from
        http://packages.medibuntu.org/pool/free/libd/libdvdcss/ and 
        put it under the path /usr/share/doc/libdvdread4, install it as 
        command :
        # dpkg -i libdvdcss2_1.2.10-0.2medibuntu1_i386.deb

    Install RealPlayer
        Download ”RealPlayer11GOLD.deb” from http://www.real.com/
        realplayer/linux and put it under the path /tmpinstall it as
        command :
        # dpkg -i RealPlayer11GOLD.deb

    Install some useful utilities
        # apt-get install rar unrar unace-nonfree

    Install some wireless network utilities
        # apt-get install ndiswrapper-common ndiswrapper-utils-1.9
        cabextract unshield kismet aircrack-ng

    Install some network utilities
        # apt-get install wireshark nmap ettercap traceroute

    Install some flash plugin and firefox plugin
        # apt-get install flashplugin-nonfree flashplugin-installer mozilla
        -plugin-vlc swfdec-mozilla mozilla-plugin-gnash

    Clean the download cache files and remove unnecessary files
        # apt-get clean
        # rm -rf /tmp/*
        # rm -f /etc/hosts /etc/resolv.conf
        # umount /proc/
        # umount /sys/
        # exit

    Make the new manifest file
        $ chmod +w ~/livecd/cd/casper/filesystem.manifest
        $ sudo chroot ~/livecd/custom dpkg-query -W
        -showformat='${Package}${Version}\n' > ~/livecd/cd/casper/
        filesystem.manifest
        $ sudo cp ~/livecd/cd/casper/filesystem.manifest ~/livecd
        /cd/casper/filesystem.manifest-desktop

    Make the new squash file system
        $ sudo mksquashfs ~/livecd/custom ~/livecd/cd/casper/
        filesystem.squashfs

    Customize the file ”~/livecd/cd/README.diskdefines”
        $ vim ~/livecd/cd/README.diskdefines

    Update the file ”~/livecd/cd/md5sum.txt”
        $ sudo rm ~/livecd/cd/md5sum.txt
        $ sudo -s
        # cd ~/livecd/cd && find . -type f -print0 | xargs -0 md5sum
        > md5sum.txt

    Make the CD ISO file
        $ cd ~/livecd/cd
        $ sudo mkisofs -r -V "Ubuntu-Live-Custom" -b isolinux/isolinux.bin
        -c isolinux/boot.cat -cache-inodes -J -l -no-emul-boot -boot
        -load-size 4 -boot-info-table -o ~/Desktop/Ubuntu-Live-10.04
        -custom_R.iso .

    Use Virtualbox to open the ISO fileif no problem, just can 
        burn it as a CD

    The related PowerPoint file will be downloaded from the below
    address :
    Customize Ubuntu Desktop Live CD