在SUSE linux上编译内核

转载自:https://www.suse.com/communities/blog/compiling-de-linux-kernel-suse-way/

How to compile the kernel manually, SUSE style!.

For this example, I’ll use the new kernel 3.11 (obviously) on a SLES11 SP3 server.

1. After all we need to install: ncurses-devel

# zypper install ncurses-devel

2. Get the source:

# wget "https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.11.tar.xz"

3. Unpack the source:

# tar -Jxvf linux-3.11.tar.xz -C /usr/src/

4. Configure the kernel:

# cd /usr/src/linux-3.11/

Make sure you are in the path from the source

# make mrproper

If this is your first time, you really do not need this step, this only cleans .o files and other temporary

In the next step there are several ways to configure the kernel, I prefer to make menuconfig, but if you don’t have experience or want to play it safe, I recommend you use an existing configuration, to do this copy your old config file to the new source path:

# cp /boot/config-`uname -r` .config

If you still want to change or add something, at this point you can run: make menuconfig

HINT: After configuration you can further customize the kernel, adding a “extraversion” value. In the Makefile, edit the “EXTRAVERSION =” field, for (this) example:

注:如果你是从当前系统内核的源码编译,那么一定要修改这个,要不然在安装内核时会与原系统发生冲突。

VERSION = 3
PATCHLEVEL = 11
SUBLEVEL = 0
EXTRAVERSION = -w00t
NAME = Linux for Workgroup

5. Build the Kernel:

# make rpm

Because we copy the old configuration in this step we ask about the new kernel features, read carefully before responding.

Now, take a break, this step will take a bit depending on the performance of your hardware.

6. Install the Kernel:

If all went well, you will see output similar to this:

[...]
Wrote: /usr/src/packages/SRPMS/kernel-3.11.0_w00t_0.11_default-1.src.rpm
Wrote: /usr/src/packages/RPMS/x86_64/kernel-3.11.0_w00t_0.11_default-1.x86_64.rpm
Wrote: /usr/src/packages/RPMS/x86_64/kernel-headers-3.11.0_w00t_0.11_default-1.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.13989
+ umask 022
+ cd /usr/src/packages/BUILD
+ cd kernel-3.11.0_w00t_0.11_default
+ rm -rf /var/tmp/kernel-3.11.0_w00t_0.11_default-root
+ exit 0
rm kernel-3.11.0_w00t_0.11_default.tar.gz kernel.spec

Install the new Kernel package under /usr/src/packages/RPMS/x86_64/:

# cd /usr/src/packages/RPMS/x86_64/
sp3-lab:/usr/src/packages/RPMS/x86_64 # ls
kernel-3.11.0_w00t_0.11_default-1.x86_64.rpm
kernel-headers-3.11.0_w00t_0.11_default-1.x86_64.rpm
sp3-lab:/usr/src/packages/RPMS/x86_64 #
# rpm -ivh kernel-3.11.0_w00t_0.11_default-1.x86_64.rpm

And build the initrd

# mkinitrd

Now it only remains to edit the grub menu:

# vim /boot/grub/menu.lst

And add these lines, obviously putting the right disk to your existing system:

title SUSE Linux Enterprise Server 11 SP3 - 3.11 Linux for Workgroups
root (hdX,X)
kernel /boot/vmlinuz-3.11.0-w00t-0.11-default root=/dev/XXX resume=/dev/disk/XXX splash=silent crashkernel=256M-:128M showopts vga=0x314
initrd /boot/initrd-3.11.0-w00t-0.11-default

Basically, what we do here is copy the current grub entry in your system and just change the title and the image of the new Kernel.

Now, reboot!

We should see the new option in the grub.

转载于:https://my.oschina.net/u/2475751/blog/550909

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值