对于新安装的OpenBSD系统,马上安装开发团队公布的补丁是保障系统安全稳定运行的最佳选择,也是最快的系统完善方式,是用户在初次安装完系统并投入正式运营前首先需要执行的操作。OpenBSD的patches发布页面在http://www.openbsd.org/errata.html,里面罗列了自OpenBSD正式版发布以来所有发行版的补丁,为了更好地提供最新的发行版,而且由于OpenBSD的开发人员人力有限,所以开发团队对每个发行版的维护时间为一年,而通常情况下,每年的5月和11月推出新的发行版本,版本号以0.1的数量级递增。这些细节对OpenBSD的老用户来说可能已经耳熟能详了,但是对初次或刚接触OpenBSD的用户来说,必须要知道一点,虽然这个页面里列出了所有的以往的发行版本,但开发团队已经不对旧版本做进一步的维护和修正了,所以继续维护的版本只是页面上列出的最后两个版本。例如,
这些版本里面,目前来说只有4.6和4.7还在维护,因此初次安装的用户不要去下载以往更老的版本。而且查看和下载补丁时也应该对应自己安装的发行版本。还有一点需要注意的是对应每个发行版的不同硬件平台的补丁并不单独发布,而是集中在一个页面上统一发布,例如,目前最新的发行版OpenBSD 4.7的补丁发布页面在http://www.openbsd.org/errata47.html 。2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7.
2. 补丁的获取方式
我们这里假设你已经配置好了网络,如果你的OpenBSD尚未配置好网络,请自行使用其它方法获取补丁,不在本文讨论范围之内。我们先创建一个/usr/patches目录, 将补丁下载到这个目录内:
代码: 全选
# mkdir /usr/patches
# cd /usr/patches
- 2.1 选择下载新补丁
OpenBSD基本系统内自带了文字浏览器lynx, 你可以用它访问相关的补丁页面,因为OpenBSD已经对内置的lynx做了patch, 所以你在命令行上运行:系统会自动进入OpenBSD的主页OpenBSD.org,在里面选择Pacthes,系统会自动连接到最新版本的OpenBSD(目前为4.7)的补丁页面,(如果你还在使用4.6的话,请自行点击4.6的链接转入4.6的补丁页面。)然后点击所需的补丁就可以将补丁文件下载到本地了。代码: 全选
lynx
- 2.2 一次性下载全部补丁
因为补丁文件一般很小,你可以选择一次性将全部补丁下载到本地,然后解压缩,例如直接在命令行输入命令,然后选择"D)ownload"将所有的补丁压缩包一次性下载下来,或者用ftp命令:代码: 全选
# lynx http://ftp.openbsd.org/pub/OpenBSD/patches/4.7.tar.gz
代码: 全选
# ftp http://ftp.openbsd.org/pub/OpenBSD/patches/4.7.tar.gz
OpenBSD的补丁并非以二进制的形式发放的,实际上发布的每个补丁全是纯文本文件。而且就目前来说,OpenBSD系统也无法自动检测出是否有新的补丁出现,所以你需要经常查阅相关的补丁页面,在出现新补丁后马上下载、编译和安装它们。 —— 我们期待有一天OpenBSD系统可以像Windows系统那样自动侦测、下载、并安装新的补丁文件;或者至少像FreeBSD那样可以通过简单的两个命令来实现系统的修补。毕竟普通用户也希望系统更加简单和易用。
这里我们假设你下载了全部的补丁,我们先将补丁解压缩:
代码: 全选
# tar zxf 4.7.tar.gz
# cd 4.7
# ls
alpha common i386 m68k mvme68k powerpc sparc zaurus
amd64 hp300 landisk mac68k mvme88k sgi sparc64
armish hppa luna88k macppc ports socppc vax
代码: 全选
# cd common
# ls
001_kerberos.patch 003_openssl.patch 005_pfsync.patch 007_scsi.patch
002_mpi.patch 004_pfsync.patch 006_scsi.patch
再将所有的patch文件拷贝到 /usr/src 目录:
代码: 全选
# cp *.patch /usr/src
OpenBSD的系统补丁大致上分成两类 —— 一类是针对系统内核的补丁,一类是针对应用程序的补丁。用户要区分这两类补丁也很简单,很简单,用head命令来完成,例如要知道006_scsi.patch这个补丁的类型:
代码: 全选
# head 006_scsi.patch
Apply by doing:
cd /usr/src
patch -p0 < 006_scsi.patch
[color=royalblue]Then build and install a new kernel.[/color]
Index: sys/scsi/cd.c
===================================================================
RCS file: /cvs/src/sys/scsi/cd.c,v
retrieving revision 1.164
接下来我们看一下003_openssl.patch这个补丁:
代码: 全选
# head 003_openssl.patch
Apply by doing:
[color=royalblue]cd /usr/src[/color]
patch -p0 < 003_[color=royalblue]openssl.patch[/color]
And then rebuild and install the library and statically-linked binaries
that depend upon it:
cd lib/libssl
make obj
make depend
#
因为这些补丁都是纯文本文件,如果你喜欢查看研究补丁的代码,只需用自己喜欢的编辑器打开这些补丁。
4. 应用补丁
应用每个补丁分成下面4.2和4.3两个步骤,但是应用补丁前,你可能需要执行步骤4.1:
- 4.1 下载所需的发行版源代码
- 4.2 将补丁释放到源代码里
- 4.3 重新编译和安装修补过的源代码
4.1 下载所需的发行版源代码
系统源代码树在ftp上被分成两个部分,这在FAQ里有详细的描述,请参阅http://openbsd.gobsd.org/faq5.html#SrcandSys。
如果是针对内核的补丁,我们需要从OpenBSD的ftp服务器上下载sys.tar.gz和src.tar.gz这两个文件,前者是内核源代码,后者是除了ports和X11以外的用户岛应用程序源代码。
如果某个补丁是针对ports和X window系统的,我们就还需要分别下载ports.tar.gz或xenocara.tar.gz这两个文件。
如果你不清楚或者不关心补丁的类型,就直接将这四个文件全部下载到 /usr 目录下,就目前的OpenBSD 4.7来说,这面所提的这4个源代码压缩包都在ftp://ftp.openbsd.org/pub/OpenBSD/4.7/ 目录下,你可以用ftp命令一次将它们全部下载到本地:
代码: 全选
# cd /usr
# ftp -i ftp://ftp.openbsd.org/pub/OpenBSD/4.7/
# mget *.tar.gz
题外话:这里注意,并非一定要将源代码下载到/usr, 你可以自己根据硬盘的情况保存到到其它的目录,例如你的 /home 目录空间有足够的空间也可以放在那里修补以及编译源代码,我们这里仅采用一般用户熟悉和习惯的目录。
将发行版的源代码释放到系统内:
代码: 全选
# cd /usr/src
# tar xzf ../sys.tar.gz
# tar xzf ../src.tar.gz
# cd /usr
# tar xzf xenocara.tar.gz
# tar xzf ports.tar.gz
4.2 + 4.3
这个步骤可能是新手有些为难的地方,可能会觉得有的补丁写的不是很"详细"—— 换句话说就是没有看懂应该如何修补源代码。我们这里就以OpenBSD 4.7的目前的7个补丁为例,说一下怎样修补源代码。
实际上每个补丁里面都有比较详细的说明,如果你觉得修正方法写的比较含糊,你可以参照以往编译内核的经验进行。如果还有问题就在论坛上提问好了。
实际上每个补丁的修补顺序都包含了4.2和4.3这两个步骤。 我们下面参照补丁的说明并根据顺序逐一安装patch文件。
我们先进入 /usr/src 目录看看所有的补丁是否已经拷贝过来了:
代码: 全选
# [color=royalblue]cd /usr/src[/color]
# [color=royalblue]ls *.patch[/color]
001_kerberos.patch 003_openssl.patch 005_pfsync.patch 007_scsi.patch
002_mpi.patch 004_pfsync.patch 006_scsi.patch
代码: 全选
# [color=royalblue]head 001_kerberos.patch[/color]
Apply by doing:
cd /usr/src
patch -p0 < 001_kerberos.patch
Rebuild and install the Kerberos 5 library:
[color=red] cd lib/libkrb5[/color]
[color=red] make obj[/color]
[color=red] make depend[/color]
[color=red] make[/color]
[color=red] make install[/color]
#
代码: 全选
# [color=royalblue]patch -p0 < 001_kerberos.patch[/color]
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Apply by doing:
| cd /usr/src
| patch -p0 < 001_kerberos.patch
|
|Rebuild and install the Kerberos 5 library:
[color=red]| cd lib/libkrb5[/color]
[color=red]| make obj[/color]
[color=red]| make depend[/color]
[color=red]| make[/color]
[color=red]| make install[/color]
|
|And then rebuild and install the Kerberos 5 KDC:
[color=red]| cd ../../kerberosV/libexec/kdc[/color]
[color=red]| make obj[/color]
[color=red]| make depend[/color]
[color=red]| make[/color]
[color=red]| make install[/color]
|
|
|Index: kerberosV/src/lib/krb5/crypto.c
|===================================================================
|RCS file: /cvs/src/kerberosV/src/lib/krb5/crypto.c,v
|retrieving revision 1.10
|diff -p -u -p -u -r1.10 crypto.c
|--- kerberosV/src/lib/krb5/crypto.c 6 Oct 2006 07:09:10 -0000 1.10
|+++ kerberosV/src/lib/krb5/crypto.c 30 Mar 2010 17:17:43 -0000
--------------------------
Patching file kerberosV/src/lib/krb5/crypto.c using Plan A...
Hunk #1 succeeded at 3451.
Hunk #2 succeeded at 3531.
Hunk #3 succeeded at 3600.
done
#
上面的红色部分是系统提示的操作说明,我们照着做:
代码: 全选
# [color=royalblue]cd lib/libkrb5[/color]
# [color=royalblue]make obj[/color]
# [color=royalblue]make depend[/color]
# [color=royalblue]make[/color]
# [color=royalblue]make install[/color]
# [color=royalblue]cd ../../kerberosV/libexec/kdc[/color]
# [color=royalblue]make obj[/color]
# [color=royalblue]make depend[/color]
# [color=royalblue]make[/color]
# [color=royalblue]make install[/color]
下面接着第二个补丁,别忘了先退回 /usr/src目录:
代码: 全选
# [color=royalblue]cd /usr/src[/color]
# [color=royalblue]head 002_mpi.patch[/color]
Apply by doing:
cd /usr/src
patch -p0 < 002_mpi.patch
[color=royalblue]Then build and install a new kernel[/color].
Index: sys/dev/ic/mpi.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/mpi.c,v
retrieving revision 1.134
#
代码: 全选
# [color=royalblue]patch -p0 < 002_mpi.patch[/color]
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Apply by doing:
| cd /usr/src
| patch -p0 < 002_mpi.patch
|
|[color=red]Then build and install a new kernel.[/color]
|
|Index: sys/dev/ic/mpi.c
|===================================================================
|RCS file: /cvs/src/sys/dev/ic/mpi.c,v
|retrieving revision 1.134
|retrieving revision 1.134.2.1
|diff -u -p -r1.134 -r1.134.2.1
|--- sys/dev/ic/mpi.c 11 Jan 2010 03:51:57 -0000 1.134
|+++ sys/dev/ic/mpi.c 4 Apr 2010 11:38:29 -0000 1.134.2.1
--------------------------
Patching file sys/dev/ic/mpi.c using Plan A...
Hunk #1 succeeded at 1.
Hunk #2 succeeded at 2725.
done
#
这里的“Then build and install a new kernel.”是什么意思,具体怎么做? 如果你有这样的疑问,建议认真地从头阅读一下OpenBSD FAQ中文版的第五章——从源代码构建系统,这里我们开始编译和安装新内核,我们假设我们的平台是i386:
代码: 全选
# [color=royalblue]cd /usr/src/sys/arch/i386/conf[/color]
# [color=royalblue]config GENERIC[/color]
# [color=royalblue]cd ../compile/GENERIC[/color]
# [color=royalblue]make clean && make depend && make[/color]
[...lots of output...]
# [color=royalblue]make install[/color]
代码: 全选
# [color=royalblue]reboot[/color]
代码: 全选
OpenBSD 4.7 ([color=red]GENERIC[/color]) #0: Fri Sep 24 18:34:47 CDT 2010
Welcome to OpenBSD: The proactively secure Unix-like operating system.
Please use the sendbug(1) utility to report bugs in the system.
Before reporting a bug, please try to reproduce it with the latest
version of the code. With bug reports, please try to ensure that
enough information to reproduce the problem is enclosed, and if a
known fix for it exists, include that as well.
#
下面继续安装第三个补丁:
代码: 全选
# [color=royalblue]cd /usr/src[/color]
# [color=royalblue]ls *.patch[/color]
001_kerberos.patch 003_openssl.patch 005_pfsync.patch 007_scsi.patch
002_mpi.patch 004_pfsync.patch 006_scsi.patch
# [color=royalblue]head 003_openssl.patch[/color]
Apply by doing:
cd /usr/src
patch -p0 < 003_openssl.patch
And then rebuild and install the library and statically-linked binaries
that depend upon it:
[color=red] cd lib/libssl[/color]
[color=red] make obj[/color]
[color=red] make depend[/color]
#
我们根据提示进行操作:
代码: 全选
# [color=royalblue]patch -p0 < 003_openssl.patch[/color]
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Apply by doing:
| cd /usr/src
| patch -p0 < 003_openssl.patch
|
|And then rebuild and install the library and statically-linked binaries
|that depend upon it:
|
[color=red]| cd lib/libssl[/color]
[color=red]| make obj[/color]
[color=red]| make depend[/color]
[color=red]| make includes[/color]
[color=red]| make[/color]
[color=red]| make install[/color]
[color=red]| cd ../../sbin[/color]
[color=red]| make obj[/color]
[color=red]| make depend[/color]
[color=red]| make[/color]
[color=red]| make install[/color]|
|Index: lib/libssl/src/ssl/s3_pkt.c
|===================================================================
|RCS file: /cvs/src/lib/libssl/src/ssl/s3_pkt.c,v
|retrieving revision 1.14
|diff -p -u -p -u -r1.14 s3_pkt.c
|--- lib/libssl/src/ssl/s3_pkt.c 10 Nov 2009 09:09:40 -0000 1.14
|+++ lib/libssl/src/ssl/s3_pkt.c 30 Mar 2010 17:41:20 -0000
代码: 全选
# [color=royalblue]cd lib/libssl[/color]
# [color=royalblue]make obj[/color]
# [color=royalblue]make depend[/color]
# [color=royalblue]make includes[/color]
# [color=royalblue]make[/color]
# [color=royalblue]make install[/color]
# [color=royalblue]cd ../../sbin[/color]
# [color=royalblue]make obj[/color]
# [color=royalblue]make depend[/color]
# [color=royalblue]make[/color]
# [color=royalblue]make install[/color]
下面安装第四个补丁004_pfsync.patch:
代码: 全选
# [color=royalblue]cd /usr/src[/color]
# [color=royalblue]head 004_pfsync.patch[/color]
This is the 2nd revision of this patch.
Apply by doing:
cd /usr/src
patch -p0 < 004_pfsync.patch
[color=red]Then build and install a new kernel.[/color]
Index: sys/net/if_pfsync.c
===================================================================
#
代码: 全选
# [color=royalblue]patch -p0 < 004_pfsync.patch[/color]
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|This is the 2nd revision of this patch.
|
|Apply by doing:
| cd /usr/src
| patch -p0 < 004_pfsync.patch
|
|[color=red]Then build and install a new kernel[/color].
|
|Index: sys/net/if_pfsync.c
|===================================================================
|RCS file: /cvs/openbsd/src/sys/net/if_pfsync.c,v
|retrieving revision 1.143
|retrieving revision 1.143.2.1
|diff -u -p -r1.143 -r1.143.2.1
|--- sys/net/if_pfsync.c 1 Mar 2010 12:29:35 -0000 1.143
|+++ sys/net/if_pfsync.c 24 Mar 2010 20:52:09 -0000 1.143.2.1
--------------------------
Patching file sys/net/if_pfsync.c using Plan A...
Reversed (or previously applied) patch detected! Assume -R? [y] [color=royalblue][color=royalblue]y[/color][/color]
Hunk #1 succeeded at 1.
Hunk #2 succeeded at 1219.
代码: 全选
# [color=royalblue]cd /usr/src/sys/arch/i386/conf[/color]
# [color=royalblue]config GENERIC[/color]
# [color=royalblue]cd ../compile/GENERIC[/color]
# [color=royalblue]make clean && make depend && make[/color]
[...lots of output...]
# [color=royalblue]make install[/color]
# [color=royalblue]reboot[/color]
下面安装第五个补丁005_pfsync.patch:
代码: 全选
# [color=royalblue]cd /usr/src[/color]
# [color=royalblue]head 005_pfsync.patch[/color]
Apply by doing:
cd /usr/src
patch -p0 < 005_pfsync.patch
[color=red]Then build and install a new kernel[/color].
Index: sys/net/if_pfsync.c
===================================================================
RCS file: /cvs/src/sys/net/if_pfsync.c,v
retrieving revision 1.143.2.1
代码: 全选
# [color=royalblue]patch -p0 < 005_pfsync.patch[/color]
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Apply by doing:
| cd /usr/src
| patch -p0 < 005_pfsync.patch
|
|[color=red]Then build and install a new kernel[/color].
|
|Index: sys/net/if_pfsync.c
|===================================================================
|RCS file: /cvs/src/sys/net/if_pfsync.c,v
|retrieving revision 1.143.2.1
|retrieving revision 1.143.2.2
|diff -u -r1.143.2.1 -r1.143.2.2
|--- sys/net/if_pfsync.c 24 Mar 2010 20:52:09 -0000 1.143.2.1
|+++ sys/net/if_pfsync.c 14 May 2010 09:02:41 -0000 1.143.2.2
--------------------------
Patching file sys/net/if_pfsync.c using Plan A...
Hunk #1 succeeded at 1 with fuzz 1.
Hunk #2 succeeded at 1473.
Hunk #3 succeeded at 1485.
done
代码: 全选
# [color=royalblue]cd /usr/src/sys/arch/i386/conf[/color]
# [color=royalblue]config GENERIC[/color]
# [color=royalblue]cd ../compile/GENERIC[/color]
# [color=royalblue]make clean && make depend && make[/color]
[...lots of output...]
# [color=royalblue]make install[/color]
# [color=royalblue]reboot[/color]
接下来安装第六个补丁006_scsi.patch, 老规矩先查看补丁信息:
代码: 全选
# [color=royalblue]cd /usr/src[/color]
# [color=royalblue]head 006_scsi.patch[/color]
Apply by doing:
cd /usr/src
patch -p0 < 006_scsi.patch
Then build and install a new kernel.
Index: sys/scsi/cd.c
===================================================================
RCS file: /cvs/src/sys/scsi/cd.c,v
retrieving revision 1.164
代码: 全选
# [color=royalblue]patch -p0 < 006_scsi.patch[/color]
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Apply by doing:
| cd /usr/src
| patch -p0 < 006_scsi.patch
|
|[color=red]Then build and install a new kernel.[/color]
|
|Index: sys/scsi/cd.c
|===================================================================
|RCS file: /cvs/src/sys/scsi/cd.c,v
|retrieving revision 1.164
|retrieving revision 1.164.2.1
|diff -u -r1.164 -r1.164.2.1
|--- sys/scsi/cd.c 28 Feb 2010 21:17:00 -0000 1.164
|+++ sys/scsi/cd.c 6 Jul 2010 08:48:50 -0000 1.164.2.1
--------------------------
Patching file sys/scsi/cd.c using Plan A...
Hunk #1 succeeded at 1.
Hunk #2 succeeded at 683.
Hunk #3 succeeded at 705.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: sys/scsi/sd.c
|===================================================================
|RCS file: /cvs/src/sys/scsi/sd.c,v
|retrieving revision 1.182
|retrieving revision 1.182.2.1
|diff -u -r1.182 -r1.182.2.1
|--- sys/scsi/sd.c 15 Jan 2010 05:50:31 -0000 1.182
|+++ sys/scsi/sd.c 6 Jul 2010 08:48:50 -0000 1.182.2.1
--------------------------
Patching file sys/scsi/sd.c using Plan A...
Hunk #1 succeeded at 1.
Hunk #2 succeeded at 755.
Hunk #3 succeeded at 777.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: sys/scsi/st.c
|===================================================================
|RCS file: /cvs/src/sys/scsi/st.c,v
|retrieving revision 1.93
|retrieving revision 1.93.2.1
|diff -u -r1.93 -r1.93.2.1
|--- sys/scsi/st.c 15 Jan 2010 05:50:31 -0000 1.93
|+++ sys/scsi/st.c 6 Jul 2010 08:48:50 -0000 1.93.2.1
--------------------------
Patching file sys/scsi/st.c using Plan A...
Hunk #1 succeeded at 1.
Hunk #2 succeeded at 1088.
Hunk #3 succeeded at 1108.
done
#
再重新构建新内核:
代码: 全选
# [color=royalblue]cd /usr/src/sys/arch/i386/conf[/color]
# [color=royalblue]config GENERIC[/color]
# [color=royalblue]cd ../compile/GENERIC[/color]
# [color=royalblue]make clean && make depend && make[/color]
[...lots of output...]
# [color=royalblue]make install[/color]
# [color=royalblue]reboot[/color]
现在我们安装最后一个补丁(第七个)007_scsi.patch,这个补丁的类型请大家自行判断吧,如果还判断不出来,我就:mad::
代码: 全选
# [color=royalblue]cd /usr/src[/color]
# [color=royalblue]head 007_scsi.patch[/color]
Apply by doing:
/usr/src
patch -p0 < 007_scsi.patch
[color=red]Then build and install a new kernel[/color].
Index: sys/scsi/scsi_base.c
===================================================================
RCS file: /cvs/src/sys/scsi/scsi_base.c,v
retrieving revision 1.166
# [color=royalblue]patch -p0 < 007_scsi.patch[/color]
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Apply by doing:
| /usr/src
| patch -p0 < 007_scsi.patch
|
[color=red]|Then build and install a new kernel.[/color]
|
|Index: sys/scsi/scsi_base.c
|===================================================================
|RCS file: /cvs/src/sys/scsi/scsi_base.c,v
|retrieving revision 1.166
|retrieving revision 1.166.2.1
|diff -u -r1.166 -r1.166.2.1
|--- sys/scsi/scsi_base.c 15 Jan 2010 06:27:12 -0000 1.166
|+++ sys/scsi/scsi_base.c 24 Aug 2010 09:10:14 -0000 1.166.2.1
--------------------------
Patching file sys/scsi/scsi_base.c using Plan A...
Hunk #1 succeeded at 1.
Hunk #2 succeeded at 723.
Hmm... The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Index: sys/dev/ic/gdt_common.c
|===================================================================
|RCS file: /cvs/src/sys/dev/ic/gdt_common.c,v
|retrieving revision 1.47
|retrieving revision 1.47.2.1
|diff -u -r1.47 -r1.47.2.1
|--- sys/dev/ic/gdt_common.c 9 Jan 2010 23:15:06 -0000 1.47
|+++ sys/dev/ic/gdt_common.c 19 Aug 2010 10:48:53 -0000 1.47.2.1
--------------------------
Patching file sys/dev/ic/gdt_common.c using Plan A...
Hunk #1 succeeded at 1.
Hunk #2 succeeded at 593.
Hunk #3 succeeded at 622.
Hunk #4 succeeded at 761.
Hunk #5 succeeded at 768.
Hunk #6 succeeded at 1094.
Hunk #7 succeeded at 1166.
done
# [color=royalblue]cd /usr/src/sys/arch/i386/conf[/color]
# [color=royalblue]config GENERIC[/color]
# [color=royalblue]cd ../compile/GENERIC[/color]
# [color=royalblue]make clean && make depend && make[/color]
[...lots of output...]
# [color=royalblue]make install[/color]
# reboot
到现在我们把所有的补丁都打上了,我们很幸运,打了这么多补丁的情况下编译过程居然没有出错,重新启动系统后,我们看一下系统信息:
代码: 全选
OpenBSD 4.7 ([B][color=red]GENERIC[/color][/B]) #4: Fri Sep 24 19:45:26 CDT 2010
Welcome to OpenBSD: The proactively secure Unix-like operating system.
Please use the sendbug(1) utility to report bugs in the system.
Before reporting a bug, please try to reproduce it with the latest
version of the code. With bug reports, please try to ensure that
enough information to reproduce the problem is enclosed, and if a
known fix for it exists, include that as well.
编后语:
并非这样做一定不会出错,如果新内核出错了、系统无法启动怎么办?安装新内核的命令make install实际上是将老内核改名为/nbsd, 再将新编译的内核拷贝为 /bsd,。所以,如果这个bsd内核文件无法启动,你可以在系统出现 boot >提示符时输入命令就可以恢复前一个内核了:
代码: 全选
boot > boot nbsd
此外如果你刚安装好OpenBSD就有很多补丁,不建议采用这种方式修补,可以参考这个帖子OpenBSD如何更新为稳定版,也就是用另一种方式来修补,这样仅编译一次内核就可以了。
有的朋友可能会说,能不能直接先将所有的补丁应用后,再一次性的编译内核?我的经验是有时可以、但有时不行,没深究,可能因为旧内核无法兼容新的应用吧。如果您愿意这样,也欢迎尝试一下,并请给出您的意见。
完