OpenBSD 3.6 的安装过程虽然在命令行下完成,但每一步都有清晰的提示和默认选项,只要按部就班操作,并不会太复杂。下面以实际操作为例,完整走一遍从光盘启动到系统重启的流程,遇到关键点会做些解释,方便你理解背后的逻辑。
1.1 系统从光盘启动,自检过程略
光盘引导后,系统会完成硬件自检,这部分不需要人工干预,直接进入安装环境。
1.2 选择安装类型
|erase ^?, werase ^W, kill ^U, intr ^C, status ^T |(I)nstall, (U)pgrade or (S)hell? i; #####################################################
这里提供三个选项:I 安装全新系统,U 升级已有的 OpenBSD 旧版本,S 退出到命令行。我们要装一个全新的系统,所以输入 i 并回车。万一在安装过程中误操作,按下 Ctrl+C 可以退回命令行,再输入 install 重新进入安装程序,这是个很实用的“后悔药”。
1.3 选择终端类型
|Welcome to the OpenBSD/i386 3.6 install program. |This program will help you install OpenBSD in a simple and rational way. |... |Terminal Type? [vt220];
OpenBSD 默认终端类型是 vt220,对于绝大多数情况都适用,直接回车跳过即可。
1.4 选择键盘类型
|Do you wish to select a keyboard encoding table? [no] yes; |Select your keyboard type: (P)C-AT/XT, (U)SB, or 'done' [P] ; |The a vailable keyboard encoding tables are: | be br de dk es fr it jp lt no pt ru sf sg sv ua uk us |Table name? (or 'done') [us] ; |keyboard mapping set to us ##########################################
大部分中国用户使用的是标准美式键盘,这也是 OpenBSD 默认的布局,直接回车继续就行。
1.5 磁盘划分
|IS YOUR DATA BACKED UP? ... |Proceed with install? [no] yes; |Cool! Let's get to it... |You will now initialize the disk(s)... |A vailable disks are: wd0. |Which one is the root disk? (or 'done') [wd0] ;
在 OpenBSD 中,IDE 接口硬盘被命名为 wd0、wd1……,SCSI 硬盘则是 sd0、sd1……。这里只有一个硬盘 wd0,直接选它。
|Do you want to use *all* of wd0 for OpenBSD? [no] yes;
系统询问是否把整块硬盘都给 OpenBSD,默认是 no。如果打算拿它做服务器,一般会独占整盘,所以输入 yes。
|Putting all of wd0 into an active OpenBSD MBR partition (type 'A6') ... |... |You will now create an OpenBSD disklabel inside the OpenBSD MBR partition. |The offsets used in the disklabel are ABSOLUTE... |# using MBR partition 3: type A6 off 63 (0x3f) size 8385687 (0x7ff54b) |Treating sectors 63-8385930 as the OpenBSD portion of the disk. |Initial label editor (enter '?' for help at any prompt)
接下来进入磁盘标签编辑器。在 > 提示符下输入 ? 可以查看帮助。常用命令:p 显示当前分区情况,d 删除分区(注意 c 分区被系统保留,不能删),z 清空分区表,a 创建新分区。
记住 OpenBSD 的命名规则:xx0a 一定是根文件系统 /,xx0b 一定是 swap,xx0c 表示整个硬盘。在这三个分区的基础上,可以继续划分 xx0d、xx0e 等。另外,d x 删除分区时,c 分区无法删除;a x 增加分区时,c 分区无法覆盖。
|>; p; |device: /dev/rwd0c |... |16 partitions: |# size offset fstype [fsize bsize cpg] | a: 8385867 63 unused 0 0 | c: 8388608 0 unused 0 0 |>; d a ; |>; a a ; |offset: [63] ; |size: [8385867] 128M ; |Rounding to nearest cylinder: 262017 |FS type: [4.2BSD] ; |mount point: [none] / ; |>; a b ; |...(依次创建 /、swap、/tmp、/var、/usr、/home)
实际操作时,我们按顺序创建了 128MB 的根分区、256MB 的 swap、128MB 的 /tmp、512MB 的 /var、2GB 的 /usr,剩下的给 /home。每个分区的大小可根据实际需求调整,这里只是演示一组典型分配。最后用 p 确认分区表,w 写入并 q 退出。
|Mount point for wd0d (size=131040k)>; (or 'none' or 'done')[/tmp]; |Mount point for wd0e ... [/var] ; |... |Mount point for wd0d ... done ; |No more disks to initialize. |OpenBSD filesystems: |wd0a / |wd0d /tmp |wd0e /var |wd0f /usr |wd0g /home |The next step *DESTROYS* all existing data on these partitions! |Are you really sure that you're ready to proceed? [no] yes ; | ...... 创建磁盘过程省略 ......
确认无误后输入 yes,系统开始创建文件系统。
1.6 网络配置
|System hostname? (short form, e.g. 'foo') bsd010ids;
输入主机名,这里用的是 bsd010ids。
|Configure the network? [yes]; |A vailable interfaces are: le1 le2 |Which one do you wish to initialize? (or 'done') [le1] ; |Symbolic (host) name for le1? [bsd010ids] ; |IPv4 address for le1? (or 'none' or 'dhcp') 10.x.x.x ; |Netmask? [255.255.255.0] ;
接下来配置两个网卡。第一个网卡 le1 配内网 IP(示例中用了 10.x.x.x),第二个网卡 le2 配外网 IP(192.168.1.1)。根据实际环境填写,如果使用 DHCP 可以直接输入 dhcp。
|DNS domain name? (e.g. 'bar.com') [my.domain] mycom.com; |DNS nameserver? (IP address or 'none') [none] 202.97.224.68 ; |Use the nameserver now? [yes] ; |Default IPv4 route? (IPv4 address, 'dhcp' or 'none') 10.x.x.x ;
设置 DNS 域名、DNS 服务器和默认网关,这里用了 202.97.224.68 作为示例,实际要根据网络环境填写。
1.7 设置 root 口令
|Password for root account? (will not echo) |Password for root account? (again)
两次输入 root 密码,注意屏幕不会显示输入字符,输完回车即可。
1.8 选择需要安装的系统文件
|Sets can be located on a (m)ounted filesystem; (c)drom, (d)isk or (t)ape device; or a (f)tp, (n)fs or (h)ttp server. |Where are the install sets? (or 'done') c; |A vailable CD-ROMs are cd0. |Which one contains the install media? (or 'done') [cd0] ;
这里选择安装源,输入 c 从光盘安装,然后选择 cd0。
|Pathname to the sets? (or 'done') [3.6/i386]; |The following sets are a vailable... | [X]bsd | [X]bsd.rd | [ ]bsd.mp | [X]base36.tgz | [X]etc36.tgz | [X]misc36.tgz | [X]comp36.tgz | [X]man36.tgz | [X]game36.tgz | [ ]xbase36.tgz | ... |File name? (or 'done') [bsd.mp] -game36.tgz ;
系统列出所有可选的安装包。解释一下:以 x 开头的是 X Window 相关的包,如果不用图形界面可以不装。除了 bsd.mp 和 game36.tgz,其余带 [X] 的都是系统必需包。bsd.mp 估计是 SMP 支持用的,默认没选。这里去掉了游戏包 game36.tgz,输入 -game36.tgz 取消选择,然后再次输入 done 确认。
|Ready to install sets? [yes]; | ...... 安装过程省略 ...... |Where are the install sets? (or 'done') done ;
确认后开始安装,完成后提示继续选择,输入 done 结束。
1.9 系统服务配置
|Start sshd(8) by default? [yes]; |Do you expect to run the X Window System? [yes] no ; |Change the default console to com0? [no] ; |Sa ving configuration files...done.
默认开启 SSH 服务(方便远程管理),不使用 X Window,不改串口控制台,直接按默认设置走。
|What timezone are you in? ('?' for list) [Canada/Mountain] ? ;
|...
|What timezone are you in? ... [Canada/Mountain] PRC ;
|Setting local timezone to 'PRC'...done.
输入 ? 查看时区列表,选择 PRC(中国时区)。注意,此处如果用 UTC,时间会和手表一致,所以建议选 UTC,但示例中选的是 PRC。
|Making all device nodes...done. |Installing boot block... |... |CONGRATULATIONS! Your OpenBSD install has been successfully completed! |To boot the new system, enter halt at the command prompt. |# halt; |syncing disks... done |The operating system has halted. |Please press any key to reboot. ; |Rebooting...
安装完成后,输入 halt 关机,然后按任意键重启,系统就从硬盘启动了。
至此,系统安装部分完毕。
