Linux kernel Task 02:Compile your costom kernel

2014/05/0909:04:55 5

第2个任务描述如下:

 
This is Task 02 of the Eudyptula Challenge
------------------------------------------
 
Now that you have written your first kernel module, it's time to take
off the training wheels and move on to building a custom kernel.  No
more distro kernels for you.  For this task you must run your own
kernel.  And use git!  Exciting, isn't it?  No?  Oh, ok...
 
The tasks for this round are:
  - Download Linus's latest git tree from git.kernel.org (you have to
    figure out which one is his.  It's not that hard, just remember what
    his last name is and you should be fine.)
  - Build it, install it, and boot it.  You can use whatever kernel
    configuration options you wish to use, but you must enable
    CONFIG_LOCALVERSION_AUTO=y.
  - Show proof of booting this kernel.  Bonus points if you do it on a
    "real" machine, and not a virtual machine (virtual machines are
    acceptable, but come on, real kernel developers don't mess around
    with virtual machines, they are too slow.  Oh yeah, we aren't real
    kernel developers just yet.  Well, I'm not anyway, I'm just a
    script...)  Again, proof of running this kernel is up to you, I'm
    sure you can do well.
 
Hint, you should look into the 'make localmodconfig' option, and base
your kernel configuration on a working distro kernel configuration.
Don't sit there and answer all 1625 different kernel configuration
options by hand, even I, a foolish script, know better than to do that!
 
After doing this, don't throw away that kernel, git tree, and
configuration file.  You'll be using it for later tasks.  A working
kernel configuration file is a precious thing, all kernel developers
have one they have grown and tended to over the years.  This is the
start of a long journey with yours.  Don't discard it like was a broken
umbrella, it deserves better than that.
 
I get the linux kernel source code use set of commands:
[root@bogon ~]# uname -a
Linux bogon 2.6.32-279.el6.x86_64 #1 SMP Fri Jun 22 12:19:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
[root@bogon /]# mkdir /kernel/Task2
[root@bogon /]# cd /kernel/Task2/
[root@bogon Task2]# pwd
/kernel/Task2
[root@bogon Task2]# git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[root@bogon Task2]# cd linux/
[root@bogon Task2]# make localmodconfig
Then modify the configure file '.config',set CONFIG_LOCALVERSION_AUTO=y
...
#
# General setup
#
CONFIG_INIT_ENV_ARG_LIMIT=32
CONFIG_CROSS_COMPILE=""
# CONFIG_COMPILE_TEST is not set
CONFIG_LOCALVERSION=""
#CONFIG_LOCALVERSION_AUTO is not set
CONFIG_LOCALVERSION_AUTO=y
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_BZIP2=y
CONFIG_HAVE_KERNEL_LZMA=y
...
Next run,some compile information is ignored:
[root@bogon linux]# make -j8 all
[root@bogon linux]# make modules_install
[root@bogon linux]# make install
sh /kernel/Task2/linux/arch/x86/boot/install.sh 3.15.0-rc4-00298-g9f1eb57 arch/x86/boot/bzImage \
                System.map "/boot"
Luckly,it all works well!
I found the file '/etc/grub.conf' be modified!
 
[root@bogon linux]# cat /etc/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,0)
#          kernel /vmlinuz-version ro root=/dev/sda2
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.15.0-rc4-00298-g9f1eb57)
        root (hd0,0)
        kernel /vmlinuz-3.15.0-rc4-00298-g9f1eb57 ro root=UUID=b4d19447-4c9d-4eb8-be5d-33e7ab8c5fd9 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /initramfs-3.15.0-rc4-00298-g9f1eb57.img
title CentOS (2.6.32-279.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=UUID=b4d19447-4c9d-4eb8-be5d-33e7ab8c5fd9 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-279.el6.x86_64.img
 
Next,set the default=0 and reboot my machine.About 2 mins later,the machine  launched successfully.
[root@bogon linux]# uname -a
Linux bogon 3.15.0-rc4-00298-g9f1eb57 #1 SMP Wed May 7 21:30:42 PDT 2014 x86_64 x86_64 x86_64 GNU/Linux

 

All of the above operations are completed in my virtual machine.

 

  • 微信扫码赞助
  • weinxin
  • 支付宝赞助
  • weinxin

发表评论

您必须才能发表评论!

目前评论:5   其中:访客  0   博主  0

    • guozi

      vmware workstation 10

      • guozi

        Linux是CentOS 6.5最小化安装的。

        • albert

          虚拟机用的什么?有些虚拟机好像不行

          • guozi

            Linux是CentOS 6.5最小化安装的。

            • albert

              hi,你好请问你用的Linux是什么版本,虚拟机是什么版本?我按照你的步骤做,重启总是不成功