Showing posts with label PCBSD安装. Show all posts
Showing posts with label PCBSD安装. Show all posts

Friday, April 25, 2008

How to patch your OpenBSD

Every OS needs to be patched, even for OpenBSD, either for security reasons, reliability ones, bug fixes or new functions.

To patch OpenBSD, you need first to know whether there are any patches released/applicable for your version of release. For OpenBSd, there are two ways you can check if there are any patches available. First, and recommended, is to check the errata (http://www.openbsd.org/errata.html) page. Second is to subscribe to "announce " and "security-announce" mailing lists. for more details on how, check OpenBSD web page or send a mail to majordomo@openbsd.org with subject "help".


In OpenBSD, there are 3 ways to patch your system with all the patches.
1. upgrade your system to -current branch, since all patches and fixes are incorporated into -current.

This is not suitable for most users because of the ever-changing code for -current.

2. upgrade your system to -stable branch of your your release.

By doing this, you'll need to fetch or update your source tree using the appropriate -stable branch, and recompile the kernel and userland files. While this is the easiest way and is OK for most users, it take quite a while to download source files and recompile the system, especially for these who has limited bandwidth to Internet.

3. Patch, compile and install individual impacted files.

This is what we will use for our example below. While this requires less bandwidth and typically less time than an entire cvs(1) checkout/update and source code compilation, this is sometimes the most difficult option, as there is no one universal set of instructions to follow. Sometimes you must patch, recompile and install one application, other times, you might have to recompile entire sections of the tree if the problem is in a library file.

Once you've identified the patch you need to apply to your system, here are the steps to follow:

++++++++++++++++++Following lines are from www.openbsd.org/faq/faq10.html:

Applying patches.

Patches for the OpenBSD Operating System are distributed as "Unified diffs", which are text files that hold differences to the original source code. They are NOT distributed in binary form. This means that to patch your system you must have the source code from the RELEASE version of OpenBSD readily available. In general, you should have the entire source tree available. If you are running a release from official CDROM, the source trees are available on disk 3, they are also available as files from the FTP servers. We will assume you have the entire tree checked out.

For our example here, we will look at patch 001 for OpenBSD 3.6 dealing with the st(4) driver, which handles tape drives. Without this patch, recovering data from backups is quite difficult. People using a tape drive need this patch, however those without a tape drive may have no particular need to install it. Let's look at the patch:

# more 001_st.patch
Apply by doing:
cd /usr/src
patch -p0 < 001_st.patch

Rebuild your kernel.

Index: sys/scsi/st.c
===================================================================
RCS file: /cvs/src/sys/scsi/st.c,v
retrieving revision 1.41
retrieving revision 1.41.2.1
diff -u -p -r1.41 -r1.41.2.1
--- sys/scsi/st.c 1 Aug 2004 23:01:06 -0000 1.41
+++ sys/scsi/st.c 2 Nov 2004 01:05:50 -0000 1.41.2.1
@@ -1815,7 +1815,7 @@ st_interpret_sense(xs)
u_int8_t skey = sense->flags & SSD_KEY;
int32_t info;

- if (((sense->flags & SDEV_OPEN) == 0) ||
+ if (((sc_link->flags & SDEV_OPEN) == 0) ||
(serr != 0x70 && serr != 0x71))
return (EJUSTRETURN); /* let the generic code handle it */

As you will note, the top of the patch includes brief instructions on applying it. We will assume you have put this patch into the /usr/src directory, in which case, the following steps are used:

# cd /usr/src
# patch -p0 < 001_st.patch
Hmm... Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|Apply by doing:
| cd /usr/src
| patch -p0 < 001_st.patch
|
|Rebuild your kernel.
|
|Index: sys/scsi/st.c
|===================================================================
|RCS file: /cvs/src/sys/scsi/st.c,v
|retrieving revision 1.41
|retrieving revision 1.41.2.1
|diff -u -p -r1.41 -r1.41.2.1
|--- sys/scsi/st.c 1 Aug 2004 23:01:06 -0000 1.41
|+++ sys/scsi/st.c 2 Nov 2004 01:05:50 -0000 1.41.2.1
--------------------------
Patching file sys/scsi/st.c using Plan A...
Hunk #1 succeeded at 1815. <-- Look for this message!
done

Note the "Hunk #1 succeeded" message above. This indicates the patch was applied successfully. Many patches are more complex than this one, and will involve multiple hunks and multiple files, in which case, you should verify that all hunks succeeded on all files. If they did not, it normally means your source tree is not right, you didn't follow instructions carefully, or your patch was mangled. Patches are very sensitive to "white space" -- copying and pasting from your browser will often change tab characters into spaces or otherwise alter the white space of a file, making it not apply.

At this point, you can build the kernel as normal, install it and reboot the system.

Not all patches are for the kernel. In some cases, you will have to rebuild individual utilities. At other times, will require recompiling all utilities statically linked to a patched library. Follow the guidance in the header of the patch, and if uncertain, rebuild the entire system.

Patches that are irrelevant to your particular system need not be applied -- usually.

Thursday, May 24, 2007

用Windows引导启动WinXP+PCBSD

安装XP+PCBSD双启动以后,PCBSD boot manager启动的时候那声beep实在让我讨厌,尤其是在办公室打开电脑的时候。于是我决定改用Windows的启动菜单。

这次的修改需要两个工具:
1. 可启动的、带有fdisk的工具盘
2. PCBSD的启动记录(pcbsd.pbr)

第一个工具请自备,我讲一下如何获得第二个。

方法a: 启动到windows下,从PCBSD的安装盘上copy /boot/boot1 到你的Windows启动分区下,比如C:\,并将它重命名为"pcbsd.pbr"

方法b:启动到PCBSD下,以root身份运行如下命令:
dd if=/dev/XXX of=pcbsd.pbr bs=512 count=1

这里的 XXX 是你的PCBSD的盘符, 比如ad0s2a。
然后再将PCBSD.PBR拷贝到Windows的启动盘下,比如C:\。注意,虽然PCBSD下可以直接查看NTFS分区,但不能写入,你需要通过移动硬盘或者网络来完成这一步。

将pcbsd.pbr拷贝到windows的启动分区以后,你需要编辑windows的boot.ini文件,让它看起来如下如下:

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows XP"
c:\pcbsd.pbr="My PCBSD 1.3"

这里要注意的是,boot.ini是一个默认的隐藏只读文件,你需要去掉它的的只读属性才能保存。

上面的步骤完成後,用你的启动盘重启系统,然后运行“fdisk /mbr”命令,然后从硬盘重启,你就不会再听到那讨厌的声响了,Windows的启动菜单里就会显示出“My PCBSD 1.3”的选项了。

Wednesday, May 16, 2007

WINXP+PCBSD双启动安装指南

鉴于目前的实际情况,可能很大一部分使用/学习PCBSD的人都还需要WinXP,双启动就成了一个很自然的选择。

对于新手来说,如果你的机子性能还可以的话(1G或者更多内存,2G或更快的CPU),我推荐先用VMWare虚拟机软件安装PCBSD体验一下,毕竟一个全新的操作系统还是需要一定的时间来适应的,尤其是对于PCBSD这类的非主流操作系统来说,和windows的差别还是相当大的,尤其是平时习惯的一些软件在新系统下可能都没了。

言归正传,要想双启动,你的硬盘上至少需要8GB的磁盘空间,一张PCBSD的安装盘。本文假定你已经有一个安装好的XP系统。

第一步:备份现有系统上的那些对你至关重要的文件,存放在移动硬盘或者网络硬盘上,或者任何其他存储介质。重要重要!!

第二步:为PCBSD准备磁盘空间。

这里你需要一个空白的分区,不小于8GB,而且要是一个主分区,不能是扩展分区。为了保证这一点,你可以先删除这个分区(删除操作会使该分区上的所有数据丢失),然后重新创建一个主分区。步骤如下:

1.点击“开始”》“运行”,输入“diskmgmt.msc",确定后出现磁盘管理界面。在窗口中会列出当前系统中所有的磁盘和分区情况。
2. 右键单击你想要删除的分区的图标,选择”删除分区“(或者”删除逻辑磁盘“)即可。然后那部分空间会变成自由空间。
3. 在自由空间上右键单击,选择”创建分区“,在分区类型中选择”主分区(Primary Partition)“,不必勾选格式化选项,反正安装PCBSD的时候会格式化。

至此,空间准备的操作就已经完成,可以进行PCBSD的装了。

第三步:安装PCBSD
详细的安装步骤请参考“PCBSD安装”中的另一篇文章。这里只提一下安装过程中需要注意的一个地方。

在选择安装介质的时候,请不要勾选“使用整个磁盘”的选项,否则会将整个磁盘格式化,导致数据丢失,你的XP系统也无法使用。你需要点击从而选中原来删除的那个分区(在第二步中腾出来的那部分空间),如下图。(图片被编辑过)
http://www.mediamax.com/auctionweb/Hosted/gfd.gif

第四步:安装完成。
PCBSD的安装完成后,直接重启,应该就可以看到启动选择菜单了。系统会自动分配F2给原来的XP系统,并以DOS来显示。现在你就可以通过F1或者F2来选择系统进行启动了。

Enjoy!

Tuesday, May 08, 2007

PCBSD安装新手指南

如果你准备将PCBSD安装到你的机子上,请先下载ISO文件,然后刻录成光盘进行安装。

如果你想使用VMware Workstation进行虚拟机下的安装,只需下载ISO文件即可。安装中文版需要两张ISO,英文版的话一张即可。

我的测试是在虚拟机下进行,物理安装时大同小异。

1. 装好光盘,启动机器




2. PCBSD启动、自检


3. 来到安装界面。选择图形化安装



4. 下一项,选择安装时的系统语言。
默认是英语,你可以选择简体中文
第二选项时键盘的格式,保持默认即可。
第三个是时区设置,在下拉菜单下选择Asia/Shanghai (亚洲/上海)



5. 这一步选择安装类型。我们选择“Fresh install”,全新安装。




6. 系统类型选择,选择“workstation/Laptop”,工作站/笔记本类型




7. License,勾选“I Agree”



8. 添加管理员账户(root),设置密码。第二个是添加一个普通账户,并设置密码。这里的Shell选项是设定你以后使用的命令行工具,如果你对这个 BSD/Linux下的命令行不熟悉的话,选择sh/bash好了,因为这个比较常见,资料也比较多。但对于BSD家族来讲,SH则是最常见的。这里我选 择了SH。




9. 下一步,选择安装设备,即硬盘。这里默认是单系统安装,所以选择了“Use entire disk”,使用全部硬盘。注意,选择了这一项的话,安装时会格式化硬盘,导致数据丢失,要当心!
同时也要选择下面一个:“Install PCBSD bootloader”,安装pcbsd的启动程序。



10. 接下来,系统就会自动分区并进行安装,重启后PCBSD就算安装成功了。


安装进行中.....


安装完成


重启后PCBSD的缺省界面(使用的是非root账户登陆)