OpenBSD 4.2安装指南(2)

电脑版微信多开,最详细教程没有之一 首先桌面任意的位置右键新建文本文档输入如下代码: TASKKILL /F/IM WECHAT.EXE start " " "D:\Program Files (x86)\Tencent\WeChat\WeChat.exe" start " " "D:\Program Files (x86)\Tencent\WeChat\WeChat.exe" ... 阅读详情
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

4.5.2 - 设置磁盘

重要提示:使用超大磁盘的用户请先看这一节。所谓超大磁盘,是指那些比使用它的计算机出厂时生产的一般磁盘容量要大的那些磁盘。

OpenBSD 在各种平台下设置磁盘是有一点差异的. 对于 i386,amd64,macppc,zaurus和armish,设置磁盘只有两个步骤. 首先, OpenBSD 占用的slice是由 fdisk(8) 来划分的, 然后这块 slice 再由 disklabel(8) 二次划分成 OpenBSD 分区 .

一些用户可能会对这里的一些专用术语感到有点困惑. 在这里会看到我们用的 "partition" 一词有两种意思. 这个发现是正确的. 在 OpenBSD 平台下的分区有两层, 第一层, 我们可以认为是操作系统分区, 就是各种操作系统标识在硬盘上哪块空间是属于他们的, 第二层就是 OpenBSD 下二次划分为独立文件系统的分区. 第一种是能作为一块硬盘分区被 DOS, Windows, 或其它使用这种分布格式的操作系统所识别的. 而第二层分区只能被 OpenBSD 和那些能直接读取 OpenBSD 文件系统的的操作系统所识别.

Cool !  Let ' s get to it...
You will now initialize the disk(s) that OpenBSD will use. To enable all
available security features you should configure the disk(s) to allow the
creation of separate filesystems 
for   / ,  / tmp,  / var,  / usr, and  / home.
Available disks are: wd0.
Which one 
is  the root disk ?  (or done) [wd0] Enter

root disk 就是系统将会启动的那个盘, 通常也是交换分区所在的那块硬盘. IDE 硬盘一般会被标识为 wd0, wd1, 等., SCSI 硬盘 RAID 设备会被标识为 sd0, sd1, 依此类推. 所有 OpenBSD 能识别出来的硬盘都会被罗列在这里 -- 如果你的驱动器没有被识别出来, 那你的设备应该是没有获得支持或者你对硬件进行了错误的配置.

Do you want to use  * all *  of wd0  for  OpenBSD ?  [no] Enter

如果你对这个问题回答 "yes" , 那么整块硬盘都会被 OpenBSD 占据. 这样子就会建立一个标准的 Master Boot Record ,分区表也会被写入硬盘 -- 这块分区的大小就是整块硬盘的大小, 并会被设定为 OpenBSD 的分区类型和标示为启动分区. 对于大多数使用 OpenBSD 的机器这是最常用的选择; 然而, 对于有些系统我们就不能这样做了. 许多 Compaq 的系统, 许多 laptops, 一些 Dell机型以及其它机器,他们使用 "maintenance" 或者 "Suspend to Disk" 类型的分区,这些分区应该被完整保留. 如果你的机器上还有其它类型的分区而你不想擦除它, 在以上的问题不要回答 "yes" .

下面的例子我们就来假设一下,这块硬盘将会被 OpenBSD 和 已有的 windows 2000 所共享, 所以我们选择 "no", 这样我们就会进入 fdisk(8) .

你在这里也能获得更多的关于 fdisk(8) 信息.

注意:如果你对上面的问题回答了"Y",或者你的硬件平台不使用fdisk(如sparc64),你将不会经历这一步骤,而是直接转入"创建disklebel"一节。

You will now create a single MBR partition to contain your OpenBSD data. This partition must have an id of  ' A6 ' ; must  * NOT *  overlap other partitions; and must be marked  as  the only active partition.
The 
' manual '  command describes all the fdisk commands  in  detail.
Disk: wd0 geometry: 
2586 / 240 / 63  [ 39100320  Sectors]
Offset: 
0  Signature:  0xAA55
Starting Ending LBA Info:
#: id C H S 
-  C H S [ start: size ]
------------------------------------------------------------------------
* 0 : 0B  0   1   1   -   202   239   63  [  63 :  3069297  ] Win95 FAT - 32
1 :  00   0   0   0   -   0   0   0  [  0 :  0  ] unused
2 :  00   0   0   0   -   0   0   0  [  0 :  0  ] unused
3 :  00   0   0   0   -   0   0   0  [  0 :  0  ] unused
Enter 
' help '   for  information
fdisk: 
1 >  help
help Command help list
manual Show entire OpenBSD man page 
for  fdisk
reinit Re
- initialize loaded MBR (to defaults)
setpid Set the identifier of a given table entry
disk Edit current drive stats
edit Edit given table entry
flag Flag given table entry 
as  bootable
update Update machine code 
in  loaded MBR
select Select extended partition table entry MBR
swap Swap two partition entries
print Print loaded MBR partition table
write Write loaded MBR to disk
exit Exit edit of current MBR, without saving changes
quit Quit edit of current MBR, saving current changes
abort Abort program without saving current changes
fdisk: 
1 >

这里的一些命令是有必要解释一下的:

* r or reinit: 清除现存的分区表, 使用整个硬盘建立一个 OpenBSD 分区, 将其标示为可启动, 并且写入 OpenBSD MBR 代码. 就相当于前面

那个"use *all* of ..." 的问题回答 "yes".
* p or print: 显示当前分区表. "p m" 将会以兆(M)为单位显示, "p g" 将会以千兆(G)为单位显示.
* e or edit: 编辑分区表.
* f or flag: 将一块分区标示为可启动分区, 之后机器将会从这块分区启动.
* u or update: 将 MBR 升级为OpenBSD 启动代码, 这样做的效果类似于使用 "reinit", 只是不会改变现有的分区表.
* exit and quit: 留心使用这两个命令, 有些用户使用 "exit" 和 "quit" 的时候搞反了他们的意思.

非常有必要在这里再次指出, 这一步的错误会造成非常严重的资料损失. 如果你要在一个存有重要数据的驱动器上进行这些操作, 那么在一个"可以随便操作"的驱动器上做些练习是蛮有价值的, 当然也要记得作好备份.

我们的驱动器上有一块 1.5G 的给 Windows 2000 的分区(使用 FAT 文件系统). 看一下上面显示的信息, 我们可以看到 Windows 的分区占据了从驱动器的 202 柱面结束的地方 . 所以, 我们要把硬盘上剩下的空间分配给 OpenBSD, 从柱面 203 开始. 你也可以通过将现存分区的起始扇区 (63) 和它的大小 (3069297)相加计算出 OpenBSD'的起始扇区为 3069360 .你能对驱动器分布以柱面/柱头/扇区或者是原始扇区的格式进行修改. 只要选对你来说觉得容易的那种就可以了; 在这钟情况下,对于一块已经有现存分区的驱动器, 使用 CHS 格式会比较方便. 如果你是在建立这块硬盘上的第一块分区, 使用原始的扇区会更方便点.

fdisk:  1 >  e  1
Starting Ending LBA Info:
#: id C H S 
-  C H S [ start: size ]
------------------------------------------------------------------------
1 :  00   0   0   0   -   0   0   0  [  0 :  0  ] unused
Partition id (
' 0 '  to disable) [ 0   -  FF]: [ 0 ] ( ?   for  help) a6
Do you wish to edit 
in  CHS mode ?  [n] y
BIOS Starting cylinder [
0   -   2585 ]: [ 0 ]  203
BIOS Starting head [
0   -   239 ]: [ 0 ] Enter
BIOS Starting sector [
1   -   63 ]: [ 0 ]  1
BIOS Ending cylinder [
0   -   2585 ]: [ 0 ]  2585
BIOS Ending head [
0   -   239 ]: [ 0 ]  239
BIOS Ending sector [
1   -   63 ]: [ 0 ]  63
fdisk:
* 1 >  p
Disk: wd0 geometry: 
2586 / 240 / 63  [ 39100320  Sectors]
Offset: 
0  Signature:  0xAA55
Starting Ending LBA Info:
#: id C H S 
-  C H S [ start: size ]
------------------------------------------------------------------------
* 0 : 0B  0   1   1   -   202   239   63  [  63 :  3069297  ] Win95 FAT - 32
1 : A6  203   0   1   -   2585   239   63  [  3069360 :  36030960  ] OpenBSD
2 :  00   0   0   0   -   0   0   0  [  0 :  0  ] unused
3 :  00   0   0   0   -   0   0   0  [  0 :  0  ] unused
fdisk:
* 1 >  p m
Disk: wd0 geometry: 
2586 / 240 / 63  [ 19092  Megabytes]
Offset: 
0  Signature:  0xAA55
Starting Ending LBA Info:
#: id C H S 
-  C H S [ start: size ]
------------------------------------------------------------------------
* 0 : 0B  0   1   1   -   202   239   63  [  63 : 1499M] Win95 FAT - 32
1 : A6  203   0   1   -   2585   239   63  [  3069360 : 17593M] OpenBSD
2 :  00   0   0   0   -   0   0   0  [  0 : 0M] unused
3 :  00   0   0   0   -   0   0   0  [  0 : 0M] unused
fdisk:
* 1 >

在使用fdisk的平台上,非常重要的一点是第一块分区要避开硬盘上的第一个轨道。 在本例中, 就是从 63 扇区开始的. 如果一块 OpenBSD 分区被建立为从最前面的 0 扇区开始的话, 分区表就会被 OpenBSD 的分区启动记录(PBR)所覆盖. 这个系统可能仍然能启动, 但是这很难维护, 这种配置是不推荐的,并且不被支持.

注意这个时候提示符多了个星号 ('*')以提醒你尚未保存修改. 我们输入一下 p m 就能看到我们没有改动 Windows 分区, 我们成功得将剩余的空间分配给了 OpenBSD, 分区也没有重叠. 胜利在望.

还有一件事我们没做的就是把分区标志为可启动的, 这样我们下次重启后就能启动OpenBSD :

fdisk: * 1 >  f  1
Partition 
1  marked active.
fdisk:
* 1 >  p
Disk: wd0 geometry: 
2586 / 240 / 63  [ 39100320  Sectors]
Offset: 
0  Signature:  0xAA55
Starting Ending LBA Info:
#: id C H S 
-  C H S [ start: size ]
------------------------------------------------------------------------
0 : 0B  0   1   1   -   202   239   63  [  63 :  3069297  ] Win95 FAT - 32
* 1 : A6  203   0   1   -   2585   239   63  [  3069360 :  36030960  ] OpenBSD
2 :  00   0   0   0   -   0   0   0  [  0 :  0  ] unused
3 :  00   0   0   0   -   0   0   0  [  0 :  0  ] unused
fdisk:
* 1 >

现在,我们就可以保存一下修改了:

fdisk: * 1 >  w
Writing MBR at offset 
0 .
wd0: no disk label
fdisk: 
1 >  q


创建disklabel

下一步就是使用 disklabel(8) 分配 OpenBSD 分区(第二层). 更多使用 disklabel(8) 的细节可以在 FAQ 14 查看, disklabel.

Here  is  the partition information you chose:
Disk: wd0 geometry: 
2586 / 240 / 63  [ 39100320  Sectors]
Offset: 
0  Signature:  0xAA55
Starting Ending LBA Info:
#: id C H S 
-  C H S [ start: size ]
------------------------------------------------------------------------
0 : 0B  0   1   1   -   202   239   63  [  63 :  3069297  ] Win95 FAT - 32
* 1 : A6  203   0   1   -   2585   239   63  [  3069360 :  36030960  ] OpenBSD
2 :  00   0   0   0   -   0   0   0  [  0 :  0  ] unused
3 :  00   0   0   0   -   0   0   0  [  0 :  0  ] unused

You will now create an OpenBSD disklabel inside the OpenBSD MBR partition. The disklabel defines how OpenBSD splits up the MBR partition into OpenBSD partitions 
in  which filesystems and swap space are created.

The offsets used 
in  the disklabel are ABSOLUTE, i.e. relative to the start of the disk, NOT the start of the OpenBSD MBR partition.

disklabel: no disk label
WARNING: Disk wd0 has no label. You will be creating a 
new  one.

# 
using  MBR partition  1 : type A6 off  3069360  ( 0x2ed5b0 ) size  36030960  ( 0x225c9f0 )

Treating sectors 
3069360 - 39100320   as  the OpenBSD portion of the disk.
You can use the 
' b '  command to change  this .

Initial label editor (enter 
' ? '   for  help at any prompt)
>   ?
Available commands:
?  [cmnd]  -   this  message or command specific help.
a [part] 
-  add  new  partition.
b 
-   set  OpenBSD disk boundaries.
c [part] 
-  change partition size.
D 
-   set  label to  default .
d [part] 
-  delete partition.
e 
-  edit drive parameters.
g [b
| d | u]  -  use [b]ios, [d]isk or [u]ser geometry.
M 
-  show entire OpenBSD man page  for  disklabel.
m [part] 
-  modify existing partition.
n [part] 
-   set  the mount point  for  a partition.
p [unit] 
-  print label.
q 
-  quit and save changes.
r 
-  recalculate free space.
s [path] 
-  save label to file.
u 
-  undo last change.
w 
-  write label to disk.
X 
-  toggle expert mode.
x 
-  exit without saving changes.
z 
-  zero  out  partition table.
Numeric parameters may use suffixes to indicate units:
' b '   for  bytes,  ' c '   for  cylinders,  ' k '   for  kilobytes,  ' m '   for  megabytes,
' g '   for  gigabytes or no suffix  for  sectors (usually  512  bytes).
' % '   for  percent of total disk size,  ' & '   for  percent of free space.
Non
- sector units will be rounded to the nearest cylinder.
Entering 
' ? '  at most prompts will give you (simple) context sensitive help.
>

同样的,这里的一些命令也要解释一下:

* p - displays (prints) 显示当前的 disklabel , 你也能用 k, m 或者 g 来表示 kilobytes, megabytes 或者 gigabytes为单位进行显示.
* D - 清除现有的 disklabel, 以覆盖当前的 OpenBSD 分区来建立一个新的默认的 disklabel. 当硬盘上本来有一个 disklabel,或者当

OpenBSD 分区被重新划分了大小 -- 老的 disk label 没有被删除的时候(会造成冲突)是很有用的.
* m - 修改 disklabel 中已有的记录. 不要高估了这个命令能给予你的功能. 即使它可能可以更改 disklabel 分区的大小, 但是它不能改变驱动器上的文件类型. 如果你想丢失大量资料的话那么使用这个命令来调整现有分区的大小是个不错的办法.

在你的硬盘上进行 Slice 划分是很重要的 . "我该如何为系统分区?" 的答案就是 "你需要用它做什么". 各种应用之间都是不同的. 在这里没有什么统一的答案. 如果你还没拿定主意如何划分你的系统, 看这里的讨论.

在这台机器上, 我们给了 OpenBSD 17G以上的空间. 这是块很大的空间, 我们多数用不了那么多. 所以我们没必要使用最小的容量单位. 我们很可能会宁愿有几百MB的未使用空间, 而不是几个KB。太小了.

在根分区上, 'a'(/)分区必须要建立以用做根文件系统 (/). 如果这个分区不被建立的话安装程序是无法继续进行的. 一般你也需要一个交换分区(swap),'b'.但是如果你确信系统有永远不会用尽的物理内存,也可以不创建它。如果根磁盘(root disk)上存在'b'分区的话,系统会自动用它作交换分区。如果交换分区位于其他的磁盘上,那就必须手工把它加到/etc/fstab文件中。

稍作思考后,我们决定建立足够的分区来用作推荐使用各个独立文件系统 (/, /tmp, /var, /usr, /home) ,还有一个交换分区:

* wd0a: / (root) - 150M. 应该够了.
* wd0b: (swap) - 300M.
* wd0d: /tmp - 120M. /tmp 会被用来编译一些软件, 120M 对于大多数软件还是足够的.
* wd0e: /var - 80M. 如果这个系统是用做 web 或者 mail 服务器的话 我们希望这块分区能够更大一些, 但是在这里我们并不打算这么做.
* wd0g: /usr - 2G. 我们希望这块分区能有足够的空间来存放用户的应用软件, 如果需要的话还能在这里通过源代码升级或者重新编译系统. Ports 树也会被放在这里, 在 ports 树建立前大概会在这里占用 100M 的空间. 如果你想在这里通过源代码编译许多应用程序而不是使用预编的packages 包, 那你要在这里在多留点空间了.
* wd0h: /home - 4G. 这里用来存放用户资料的.

现在,如果你添加了以上的分区, 你就会看到 6G 以上的空间没有使用! 空白空间不会造成什么问题, 而且它还给我们将来扩大分区提供了方便. 需要更多的 /tmp? 没问题, 在剩余空间中建立一个新的分区,用newfs将它格式化,然后修改一下 /etc/fstab将新分区加载到/tmp上。搞定 .

>  p m
device: 
/ dev / rwd0c
type: ESDI
disk: ESDI
/ IDE disk
label: ST320011A
bytes
/ sector:  512
sectors
/ track:  63
tracks
/ cylinder:  16
sectors
/ cylinder:  1008
cylinders: 
16383
total sectors: 
39102336
free sectors: 
36030960

16  partitions:
# size offset fstype [fsize bsize cpg]
a: 
17593.2M   1498.7M  unused  0   0
c: 
19092.9M   0.0M  unused  0   0
i: 
1498.7M   0.0M  MSDOS
>  d a
>  a a
offset: [
3069360 ] Enter
size: [
36030960 ] 150m
Rounding to cylinder: 
317520
FS type: [
4 .2BSD] Enter
mount point: [none] 
/
>  a b
offset: [
3386880 ] Enter
size: [
35713440 ] 300m
Rounding to cylinder: 
619920
FS type: [swap] Enter
>  a d
offset: [
4006800 ] Enter
size: [
35093520 ] 120m
Rounding to cylinder: 
257040
FS type: [
4 .2BSD] Enter
mount point: [none] 
/ tmp
>  a e
offset: [
4263840 ] Enter
size: [
34836480 ] 80m
Rounding to cylinder: 
166320
FS type: [
4 .2BSD] Enter
mount point: [none] 
/ var
>  a g
offset: [
4430160 ] Enter
size: [
34670160 ] 6g
Rounding to cylinder: 
12594960
FS type: [
4 .2BSD] Enter
mount point: [none] 
/ usr
>  a h
offset: [
17025120 ] Enter
size: [
22075200 ] 4g
Rounding to nearest cylinder: 
8391600
FS type: [
4 .2BSD] Enter
mount point: [none] 
/ home
>  p m
device: 
/ dev / rwd0c
type: ESDI
disk: ESDI
/ IDE disk
label: ST320011A
bytes
/ sector:  512
sectors
/ track:  63
tracks
/ cylinder:  240
sectors
/ cylinder:  15120
cylinders: 
2586
total bytes: 
19092.9M
free bytes: 
6681.4M
rpm: 
3600

16  partitions:
# size offset fstype [fsize bsize cpg]
a: 
155.0M   1498.7M   4 .2BSD  2048   16384   16  #  /
b: 
302.7M   1653.8M  swap
c: 
19092.9M   0.0M  unused  0   0
d: 
125.5M   1956.4M   4 .2BSD  2048   16384   16  #  / tmp
e: 
81.2M   2082.0M   4 .2BSD  2048   16384   16  #  / var
g: 
6149.9M   2163.2M   4 .2BSD  2048   16384   16  #  / usr
h: 
4097.5M   8313.0M   4 .2BSD  2048   16384   16  #  / home
i: 
1498.7M   0.0M  MSDOS
>  q
Write 
new  label ? : [y] Enter

你会注意到C分区被忽略了. 这个分区就是你的整个硬盘; 不要企图去修改它. 你也会发现一块不是我们定义的 i 分区; 这就是已经存在的 Windows 2000 分区. 分区没有被分配到特定的字母 -- 除了 a (root), b (swap) 和 c (整块硬盘), 剩余的分区 (一直到字母 p) 可以由我们来命名.

如果你仔细看 disklabel 的输出, 你会发现你的驱动器的转速可能是错的. 这是个由来已久的问题; 不过系统不会以任何方式使用驱动器的转速这个参数. 不必担心.

配置文件系统装载点并且格式化它

现在是对挂载点的最后配置了. 如果你用 disklabel(8) 来配置挂载点, 这里的步骤就是验证你的选择; 不然的话就在这里指定它.

Mount point  for  wd0d (size = 128520k) ?  (or  ' none '  or  ' done ' ) [ / tmp] Enter
Mount point 
for  wd0e (size = 83160k) ?  (or  ' none '  or  ' done ' ) [ / var] Enter
Mount point 
for  wd0g (size = 6297480k) ?  (or  ' none '  or  ' done ' ) [ / usr] Enter
Mount point 
for  wd0h (size = 4195800k) ?  (or  ' none '  or  ' done ' ) [ / home] Enter
Mount point 
for  wd0d (size = 128520k) ?  (or  ' none '  or  ' done ' ) [ / tmp] done
No more disks to initialize.

OpenBSD filesystems:
wd0a 
/
wd0d 
/ tmp
wd0e 
/ var
wd0g 
/ usr
wd0h 
/ home

The next step 
* DESTROYS *  all existing data on these partitions !
Are you really sure that you
' re ready to proceed? [no] y
newfs: reduced number of fragments per cylinder group from  19840  to  19760  to enlarge last cylinder group
/ dev / rwd0a:  155 .0MB  in   317520  sectors of  512  bytes
5  cylinder groups of  38 .59MB,  2470  blocks,  4992  inodes each
newfs: reduced number of fragments per cylinder group from 
16064  to  15992  to enlarge last cylinder group
/ dev / rwd0d:  125 .5MB  in   257040  sectors of  512  bytes
5  cylinder groups of  31 .23MB,  1999  blocks,  4096  inodes each
newfs: reduced number of fragments per cylinder group from 
10392  to  10344  to enlarge last cylinder group
/ dev / rwd0e:  81 .2MB  in   166320  sectors of  512  bytes
5  cylinder groups of  20 .20MB,  1293  blocks,  2688  inodes each
/ dev / rwd0g:  6149 .9MB  in   12594960  sectors of  512  bytes
31  cylinder groups of  202 .47MB,  12958  blocks,  25984  inodes each
/ dev / rwd0h:  4097 .5MB  in   8391600  sectors of  512  bytes
21  cylinder groups of  202 .47MB,  12958  blocks,  25984  inodes each
/ dev / wd0a on  / mnt type ffs (rw, asynchronous, local, ctime = Tue Oct  23   00 : 55 : 20   2007 )
/ dev / wd0h on  / mnt / home type ffs (rw, asynchronous, local, nodev, nosuid, ctime = Tue Oct  23   00 : 55 : 20   2007 )
/ dev / wd0d on  / mnt / tmp type ffs (rw, asynchronous, local, nodev, nosuid, ctime = Tue Oct  23   00 : 55 : 20   2007 )
/ dev / wd0g on  / mnt / usr type ffs (rw, asynchronous, local, nodev, ctime = Tue Oct  2300 : 55 : 20   2007 )
/ dev / wd0e on  / mnt / var type ffs (rw, asynchronous, local, nodev, nosuid, ctime = Tue Oct  23   00 : 55 : 20   2007 )

你可能会奇怪为什么安装程序会重复询问你挂载点. 这是为了让你有机会修改在建立 disklabel 时造成的挂载点遗失或错误. 比如, 安装程序会自动删除你在配置 disklabel 输入的相同的挂载点. disklabel 程序允许你输入重复的挂载点, 但是它们必须在 disklabel 程序退出后检查一下. 重复的挂载点被删除后会造成分区失去挂载点, 如果你想用它的话还要再分配新的挂载点.

注意 "Are you really sure that you are ready to proceed?" 默认的回答是 no, 所以你要回答 yes 来让它继续安装过程并格式化分区. 如果你回答no,你就会进入一个字符终端, 输入 install 就能再次进入安装, 或者重启你的机器也行.

现在所有的文件系统都将会被格式化。根据磁盘的空间大小和速度,这个过程可能需要一段时间。

4.5.3 - 设置系统的主机名

现在你必须设置一下主机名. 这个值, 连同 DNS 域名(specified below), 会被存放在 /etc/myname, 这个文件会在启动时用来设置主机名. 如果你不设置系统的域名, 系统就会使用默认的 'my.domain' .

设置这个名字很重要, 因为当系统安装后第一次启动生成系统密钥时会被用到. 不论网络有没有被配置好,密钥都会被生成.

Enter system hostname ( short  form, e.g.  ' foo ' ): puffy

4.5.4 - 配置网络

现在到配置你的网络了. 如果你打算做一个 FTP 或者 NFS 的基本安装那必须要配置网络, NFS的安装需要以你输入的信息为基础. 这里就是一个安装过程中的网络配置的例子.在我们的例子中,我们会将fxp0接口连接到一个cable modem上并使用DHCP来配置;另外一个则连接到我们的内网中,我们将手动配置网络。

Configure the network ?  [yes] Enter
Available interfaces are: fxp0 xl0.
Which one 
do  you wish to initialize ?  (or  ' done ' ) [fxp0] xl0
Symbolic (host) name 
for  xl0 ?  [puffy] Enter
The media options 
for  xl0 are currently
media: Ethernet autoselect (100baseTX full
- duplex)
Do you want to change the media options
?  [no] Enter
IPv4 address 
for  xl0 ?  (or  ' dhcp ' )  192.168 . 1.254
Netmask
?  [ 255.255 . 255.0 ] Enter
IPv6 address 
for  xl0 ?  (or  ' rtsol '  or  ' none ' ) [none] Enter
Available interfaces are: fxp0.
Which one 
do  you wish to initialize ?  (or  ' done ' ) [fxp0] Enter
Symbolic (host) name 
for  fxp0 ?  [puffy] Enter
The media options 
for  fxp0 are currently
media: Ethernet autoselect (10baseT half
- duplex)
Do you want to change the media options
?  [no] Enter
IPv4 address 
for  fxp0 ?  (or  ' none '  or  ' dhcp ' ) dhcp
Issuing hostname
- associated DHCP request  for  fxp0.
DHCPDISCOVER on fxp0 to 
255.255 . 255.255  port  67  interval  1
DHCPOFFER from 
73.34 . 136.1
DHCPREQUEST on fxp0 to 
255.255 . 255.255  port  67
DHCPACK from 
73.34 . 136.1
bound to 
69.241 . 244.76   --  renewal  in   1800  seconds.
IPv6 address 
for  fxp0 ?  (or  ' rtsol '  or  ' none ' ) [none] Enter
No more interfaces to initialize.
DNS domain name
?  (e.g.  ' bar.com ' ) [my.domain] example.com
DNS nameserver
?  (IP address or  ' none ' ) [ 68.87 . 77.130   68.87 . 72.130 ] Enter
Use the nameserver now
?  [yes] Enter
Default route
?  (IP address,  ' dhcp '  or  ' none ' ) [dhcp] Enter
Edit hosts with ed
?  [no] Enter
Do you want to 
do  any manual network configuration ?  [no] Enter

注意: 安装过程中只有一个网络接口可以轻松地使用DHCP进行配置,如果你尝试用DHCP配置另外的一个,将会发生错误。你将需要在安装完成后手工配置另外的一个网络接口。

现在,我们输入一下root用户的口令:

Password  for  root account ?  (will not echo) pAssWOrd
Password 
for  root account ?  (again) pAssWOrd

记得使用一个安全点的口令. 你也可以在启动后用 passwd(1) 建立新的口令:

The new password should be at least six characters long and not purely alphabetic. Its total length must be less than _PASSWORD_LEN (currently 128 characters). A mixture of both lower and uppercase letters, numbers,and meta-characters is encouraged.

4.5.5 - 选择安装介质

网络建立好之后, 安装脚本会给你一个手工调整配置的机会. 你建立的文件系统会被挂载根用户的口令也会被要求输入. 这样你的硬盘就能准备好安装 OpenBSD 的软件包套件了.

下面,你要选择一个安装介质. 选项都被列出来了.

Let ' s install the sets!
Location of sets ?  (cd disk ftp http or  ' done ' ) [cd] Enter
Available CD
- ROMs are: cd0.

在这里我们用 CD-ROM 安装. 会有一个被系统识别为 CD-ROM 的设备列表被显示出来. 大多数人只有一个. 如果你有很多个那就选你哟给你来安装 OpenBSD 的那个.

注意: 不是所有的硬件平台都支持全部的安装选项。本例中,OpenBSD/i386平台不支持NFS安装,因而列表中就没有显示。

Available CD - ROMs are: cd0.
Which one contains the install media
?  (or  ' done ' ) [cd0] Enter

Pathname to the sets
?  (or  ' done ' ) [ 4.2 / i386] Enter

这里,你要设定一下安装文件所在的文件夹的位置, 官方 CD-ROM 上的位置是 4.2/i386/ .

4.5.6 - 选择安装套件.

现 在就是选择你要安装的软件套件的时候了. 在后面一段中你能看到对这些包的描述. 被安装程序所找到的文件会被显示在屏幕上. 你的工作就是确定哪些文件是你需要的. 非 X 的包默认被选中; 然而有人需要限制包的数量来运行基本的 OpenBSD 系统, 那只要选 base42.tgz, etc42.tgz 和 bsd. 其他人或许想要安装所有的软件包套件.下面这个例子就是完全安装.

Select sets by entering a  set  name, a file name pattern or  ' all ' . De - selectsets by prepending a  ' - '  to the  set  name, file name pattern or  ' all ' . Selected sets are labeled  ' [x] ' .

[X] bsd
[X] bsd.rd
[ ] bsd.mp
[X] base42.tgz
[X] etc42.tgz
[X] misc42.tgz
[X] comp42.tgz
[X] man42.tgz
[X] game42.tgz
[ ] xbase42.tgz
[ ] xetc42.tgz
[ ] xshare42.tgz
[ ] xfont42.tgz
[ ] xserv42.tgz
Set name
?  (or  ' done ' ) [bsd.mp] all

[X] bsd
[X] bsd.rd
[X] bsd.mp
[X] base42.tgz
[X] etc42.tgz
[X] misc42.tgz
[X] comp42.tgz
[X] man42.tgz
[X] game42.tgz
[X] xbase42.tgz
[X] xetc42.tgz
[X] xshare42.tgz
[X] xfont42.tgz
[X] xserv42.tgz

在这你能发挥一下你的才能-- -x* 会移除所有 X 部件, 如果你改变主意的话. 在这个例子中, 我们要案装所有的套件. 即使系统不会用到所有的套件, 我们还是推荐开启或者安装所有的套件. 这里有更多的选择细节.

一 旦你成功选定了你要的的套件, 你会看到提示问你要不要解压并安装这些套件.一条显示出来的进程栏会告诉你安装信息以及需要消耗多少时间. 安装时间的长短取决于你安装 OpenBSD 的机器如何, 安装套件的多寡, 安装源的速度如何. 这个过程从十几分钟到几小时不等.

Set name ?  (or  ' done ' ) [done] Enter
Ready to install sets
?  [yes] Enter
Getting bsd ...
100 %   |**************************************************|   6083  KB  00 : 06
Getting bsd.rd ...
100 %   |**************************************************|   4949  KB  00 : 03
Getting bsd.mp ...
100 %   |**************************************************|   6130  KB  00 : 04
Getting base42.tgz ...
100 %   |**************************************************|   41604  KB  00 : 37
Getting etc42.tgz ...
100 %   |**************************************************|   1211  KB  00 : 01
Getting misc42.tgz ...
100 %   |**************************************************|   2239  KB  00 : 02
Getting comp42.tgz ...
100 %   |**************************************************|   76957  KB  01 : 04
Getting man42.tgz ...
100 %   |**************************************************|   7477  KB  00 : 08
Getting game42.tgz ...
100 %   |**************************************************|   2547  KB  00 : 02
Getting xbase42.tgz ...
100 %   |**************************************************|   11702  KB  00 : 10
Getting xetc42.tgz ...
100 %   |**************************************************|   75398   00 : 00
Getting xshare42.tgz ...
100 %   |**************************************************|   2488  KB  00 : 04
Getting xfont42.tgz ...
100 %   |**************************************************|   34745  KB  00 : 27
Getting xserv42.tgz ...
100 %   |**************************************************|   10108  KB  00 : 08
Location of sets
?  (cd disk ftp http or  ' done ' ) [done] Enter

在这里你能从其它源添加想要的额外的包(包括自定义的包套件) , 或者当你已经安装了你所要的所有包套件,那就输入 'done' .

4.5.7 – 最后处理

下 面你会被问到一些有关设定你刚装好的系统的问题.首先是 sshd(8) 要不要在系统启动的时候开启. 通常你都是希望 sshd(8) 运行的, 但是有时你不打算这样做. 如果你的应用软件对于 sshd(8) 没有依赖, 在理论上不运行它还是有一点安全优势的.

Started sshd( 8 ) by  default ?  [yes] y

(如果你以后要改变注意, 编辑/ect/rc.conf.local或/etc/rc.conf文件)
你也会选择是否要在启动时运行OpenNTPD。OpenNTPD是一种让你的计算机时钟保持同步的影响较小的方式,缺省的配置对多数人来说都足够了。
NTP server? (or 'none' or 'default') [none] default
如果你有一个本地的时钟服务器,你可以在这里指定它,如果你选择 “default”, OpenNTPD将会使用pool.ntp.org,它是一个可自由访问的时钟服务器的集合。(如果你以后要改变注意,编辑/ect/rc.conf.local和/或 /etc/ntpd.conf文件)
在某些平台上,你接下来 会被问到要不要在这个系统上运行 X . 如果你回答 'Y', /etc/sysctl.conf 就会被修改加入 machdep.allowaperture=1 或者 machdep.allowaperture=2, 是加入哪条那要看你使用什么硬件平台.在有些平台上这个问题不会被问到.如果你不准备运行X,或者是不确定,回答”NO”。如果你需要运行X,可以在以后轻松地修改/etc/sysctl.conf。禁用xf86(4)会带给你一些潜在的安全方面的优势,因为现在的视频卡上的图形引擎可以不受处理器的控制而被用于随意更改内存。

 

Do you expect to run the X Window System ?  [yes] y

 

下面你会被问到是否要用一个串口的控制台, 而不是一个标准的显示器和键盘. 如果你选 "yes" 并且回答了其它几个简单的问题, /etc/boot.conf 和 /etc/ttys 会根据你的情况被修改. 大多数人会选择默认选项-- no.

 

Change the  default  console to com0 ?  [no] Enter

 

你 最后一个任务就是填写一下时区. 这取决于你的机器的所在地, 这里或许会有数个等同的适用的答案. 下面这个例子中, 我们选择 US/Eastern, 同样也可以用 EST5EDT 或者 US/Michigan 和其他等同的选项.输入 ?会指导你作出选择.

 

Saving configuration files......done.
Generating initial host.random file ......done.
What timezone are you 
in ?  ( ' ? '   for  list) [US / Pacific]  ?
Africa
/  Chile /  GB - Eire Israel NZ - CHAT Turkey
America
/  Cuba GMT Jamaica Navajo UCT
Antarctica
/  EET GMT + 0  Japan PRC US /
Arctic
/  EST GMT - 0  Kwajalein PST8PDT UTC
Asia
/  EST5EDT GMT0 Libya Pacific /  Universal
Atlantic
/  Egypt Greenwich MET Poland W - SU
Australia
/  Eire HST MST Portugal WET
Brazil
/  Etc /  Hongkong MST7MDT ROC Zulu
CET Europe
/  Iceland Mexico /  ROK posix /
CST6CDT Factory Indian
/  Mideast /  Singapore posixrules
Canada
/  GB Iran NZ SystemV /  right /
What timezone are you 
in ?  ( ' ? '   for  list) [US / Pacific] US
What sub
- timezone of  ' US '  are you  in ?  ( ' ? '   for  list)  ?
Alaska Central Hawaii Mountain Samoa
Aleutian East
- Indiana Indiana - Starke Pacific
Arizona Eastern Michigan Pacific
- New
Select a sub
- timezone of  ' US '  ( ' ? '   for  list): Eastern
Setting local timezone to 
' US/Eastern ' ...done.

 

如果你不确定精确的时间, 你可能会希望读一下这个.

最后一步就是为系统建立 /dev 目录 (在一些机器上可能会比较耗时间, 特别是当你的 RAM 很小的时候), 并且安装启动区块.

 

Making all device nodes...done.
Installing boot block...
boot: 
/ mnt / boot
proto: 
/ usr / mdec / biosboot
device: 
/ dev / rwd0c
/ usr / mdec / biosboot: entry point  0
proto bootblock size 
512
/ mnt / boot  is   3  blocks x  16384  bytes
fs block shift 
2 ; part offset  3069360 ; inode block  152 , offset  4136
using  MBR partition  1 : type  166  ( 0xa6 ) offset  3069360  ( 0x2ed5b0 )
done.

CONGRATULATIONS
!  Your OpenBSD install has been successfully completed !
To boot the 
new  system, enter halt at the command prompt. Once the system has halted, reset the machine and boot from the disk.
# halt
syncing disks... done

The operating system has halted.
Please press any key to reboot.

OpenBSD 已经在你的机器上装好并等待第一次启动啦, 但在你重启之前...

在你重启前
现在, 你的系统已经准备好重启并开始配置服务了. 然而,在这之前, 查看一下勘误表来检查有没有会有一些对你有立即影响的错误还是比较明智的选择.
一个技巧就是重启前运行下面的命令:
# /mnt/usr/sbin/chroot /mnt

这个命令将会将装载点装载到设定位置,像正常的重启动一样。你现在可以做一些基本的系统配置,比如添加用户,更改装载点等。

你重启之后

在你安装好系统后要阅读的第一样东西就是 afterboot(8).

你也可以在下面这些很有用的连接里找找看:

* http://www.openbsd.org/faq/faq10.html#AddDelUser “>OpenBSD中添加新用户
* Initial Network Setup
* Man Pages of popular/useful commands
* OpenBSD man pages on the Web
* The OpenBSD Ports and Packages system for installing software, as well as here and here

最后一件事...
OpenBSD 开发小组希望你发送一份 dmesg. 所有的开发人员,还有所有的用户,都会感谢你的.

4.6 - 安装需要那些文件?

一次完整的 OpenBSD 安装可以分解成一定数量的独立软件包套件. 不是所有的应用都需要所有的包套件的的. 这是对每个包的描述:

* bsd - 这是内核,必须的。
* bsd.mp - 多处理器内核 (SMP) (只用于某些平台)
* bsd.rd - RAM 内存分区内核
* base42.tgz - 包含了所需的基本 OpenBSD 系统. 必须安装。
* etc42.tgz - 包含了所有需要的 /etc 里的文件;必须安装。
* comp42.tgz - 包含了编译器和它的工具, 头文件 和库文件. 推荐安装。
* man42.tgz - 包含了man页 推荐安装。
* misc42.tgz – 包含一些其他信息,安装文档
* game42.tgz – 包含 OpenBSD上运行的一些游戏
* xbase42.tgz - 包含了基本 X11 安装
* xetc42.tgz - 包含了 /etc/X11 和 /etc/fonts 配置文件
* xfont42.tgz - 包含了 X11 的字体服务器和字体
* xserv42.tgz - 包含了 X11 的X 服务器
* xshare42.tgz - 包含了 X 的 man 页, 本地设置,包含文件等等

etc42.tgz 和 xetc42.tgz 套件不作为升级安装的部分, 只在完全安装中用到, 所以你做的任何定制都会丢失. 你必须通过手动修改来升级你的 /etc, /dev 和 /var 文件夹.

即使你无意运行X系统,一些第三方的软件也会需要xbase42.tgz中的图形库文件。安装xbase42.tgz即可满足这些软件的要求,而无需安装其余的X组件。

<----待续---->
 

【WRF-Urban】使用 LCZ 替换 WRF 运行中的 LUCC 数据 使用 LCZ 替换 WRF 运行中的 LUCC 数据 阅读详情

相关推荐

从SVF文件到高效验证:Formality中set_svf命令的隐藏技巧与实战解析

本文深入解析Formality中set_svf命令的高级应用技巧,涵盖SVF文件生成策略、多文件加载优化及验证效率提升方法。通过-append和-ordered选项的实战应用,帮助工程师解决芯片验证中的常见问题,实现验证通过率与运行效率的双重提升。

mqtt6iot的博客 827

OpenBSD 安装

OpenBSD被誉世上最安全的系统。OpenBSD有最前沿的安全技术,适合于做防火墙和分布式环境下的私有网络服务OpenBSD组每6个月发布一个新的发行版,即每年的5月1日和11月1日发布.你可以在此找到关于开发周期的更多信息。OpenBSD的分发包含许多第三方软件产品,包括: ●Xfree86 4.4.0: ●GCC 2.95.3 ●Perl 5.8.2 ●Apache 1.3.29 ●Open

cafecheng的专栏 2932

电感选型不当的代价:从纹波激增到系统失稳的深度剖析

本文深度剖析了电感选型不当对开关电源系统的严重影响。电感值过小会导致纹波电流激增、元件热应力加剧、EMI超标乃至MOSFET击穿;电感值过大则会引起环路响应迟滞、动态性能下降和轻载效率恶化。文章通过实测案例,强调了超越经典公式进行动态与容差考量的必要性,并提供了基于饱和电流、温升电流及环路测试的精准选型方法论,帮助工程师规避从纹波失控到系统失稳的潜在风险。

flink9streamer的博客 415

OPENBSD:如何创建新分区,如何使用u盘?

看到 u盘的消息后,就知道U盘的设备名称了。假设是 sd0, 那么接着运行 disklabel sd0 ,看卡 sd0 是怎么分区的,c 代表整个硬盘,剩下的代表分区,a、b、i等,组合起来就是分区名称: sd0a、sd0b、sd0c、sd0i 等,其中 sd0c 代表整个硬盘。同时 disklabel 显示分区的分区类型。常见的分区是,一个c和i(当分区为Windows格式...

weixin_33719619的博客 421

主流仿真软件Sigrity/HFSS/Siwave/Hyperlynx/ADS差异

在电子设计自动化(EDA)领域,各种仿真软件如Cadence Sigrity、Mentor Graphics的HyperLynx、Keysight的ADS以及ANSYS的SIwave等,都广泛应用于不同的应用场景中。综上所述,这些EDA仿真软件在各自的应用场景中发挥着重要作用,帮助工程师在设计阶段就能够评估和优化电子产品的性能,提高设计的可靠性和效率。:Sigrity由全球最大的EDA公司Cadence推出,Cadence还推出了Orcad和Allegro等著名软件。:由安捷伦(现是德科技)公司开发。

Geektec的专栏 9442

8.时间序列预测

目标:使用历史数据预测未来的销售额。通过以上步骤,可以在Excel中有效进行预测分析,帮助做出更准确的决策通过考虑不同时期数据的影响,可以显著提高预测的准确性。结合多种方法和模型,可以灵活应对复杂的市场环境和变化。

学习,输出==》再学习再输出 899

openbsd_仔细看一下OpenBSD

当安全性至为重要时,顺理成章地使用与当今安全远程访问标准OpenSSH(Open Secure Shell)产生相同的操作系统。 OpenSSH只是OpenBSD的一部分,OpenBSD是一个从头开始关注安全性的发行版,它的目标是创建一个默认情况下安全的,类似于UNIX®的操作系统。 这种立场与当今的大多数操作系统形成鲜明对比,后者需要大量时间和精力才能使环境更坚固,然后才能上线。 实际上,O...

cusi77914的博客 3984

Cadence PSpice 仿真0:绘制电路图方法图文教程

在使用PSpice进行电路的仿真时,首先需要使用带有PSpice模型的元器件来绘制电路图,本文简单介绍进行电路图绘制是常用的几种需要掌握的方法,以满足PSpice仿真绘制简单电路图所用。

fydar的博客 4722

OpenBSD 3.6 安装指南(简体中文译本)下

4.5.3 - 设置系统的主机名现在你必须设置一下主机名. 这个值, 连同 DNS 域名(specified below), 会被存放在 /etc/myname, 这个文件会在启动时用来设置主机名. 如果你不设置系统的域名, 系统就会使用默认的 my.domain .设置这个名字很重要, 因为当系统安装后第一次启动生成系统密钥时会被用到. 不论网络有没有被配置好,密钥都会被生成.  Enter

顺顺利利的专栏 2781

TC8:SOMEIPSRV_SD_MESSAGE_07-09

TTL为服务实例的生命周期。在此生命周期之后,不提供服务实例。

jasonj333 924

PID、模糊PID、SkyHook、LQR、H2/H∞、ADRC等悬架控制合集

PID、模糊PID、SkyHook、LQR、H2/H∞等悬架控制合集

Mr.邹的博客 2026

动量轮自平衡自行车嵌入式控制系统设计

动量轮自平衡系统是典型的欠驱动机电控制对象,其本质基于角动量守恒原理实现动态姿态稳定,属于非线性SISO系统,在工程实践中常被建模为二阶倒立摆。该技术融合惯性传感、实时PID控制、PWM电机驱动与嵌入式时序调度等关键技术,具备高实时性、强抗扰性与低功耗特征,广泛应用于智能两轮机器人、自平衡车及教学实验平台。本文围绕STM32F407与MPU6050协同架构,深入解析姿态解算、PID参数整定、电源完整性设计及故障安全机制,重点解决I²C同步抖动、积分饱和、电压前馈补偿与EMI抑制等典型嵌入式控制难题。

github5actions的博客 642

科研神器: 用Gemini 3

Edge藏了个科研开挂神器!免TZ/免谷歌账号用Gemini 3,1分钟上手(附保姆级教程) 做科研查文献、理数据总卡壳?想蹭Gemini 3的AI能力,却被“谷歌账号+TZ+节点筛选”三连劝退? 现在不用折腾了!Edge浏览器里装个插件,直接把Gemini 3揣进口袋——**免翻墙、免谷歌账号、国内直接用**,分分钟让你的科研效率翻三倍,导师都得问你“偷偷开了啥挂”!

ZhangJiqun&191cm&85kg 1173

OpenBSD 4.2 安装指南(4)

4.9 - 安装之后发送你的 dmesg 到 dmesg@openbsd.org在这里要提醒一下大家, 这对于 OpenBSD 开发人员获知硬件的工作情况很重要,.一段来自 /usr/src/etc/root/root.mail 的引用If you wish to ensure that OpenBSD runs better on your machines, please do usa

OpenBSD 咨询与维护 856

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

OpenBSD 4.2 安装指南(1)

<!--google_ad_client = "pub-5143338080895292";/* 728x90, created 4/10/08 */google_ad_slot = "8165396160";google_ad_width = 728;google_ad_height = 90;//--> <script type="text/javascript"

OpenBSD 咨询与维护 1812

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

OpenBSD 4.2 安装指南(5)

<!--google_ad_client = "pub-5143338080895292";/* 728x90, created 4/10/08 */google_ad_slot = "6675122003";google_ad_width = 728;google_ad_height = 90;//--> <script type="text/javascript"

OpenBSD 咨询与维护 2066

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

OpenBSD 4.2 安装指南(3)

4.7 - 安装 OpenBSD 需要多少空间 ?很明显,这个问题的答案会有很大的差别,根据你的系统的目的。但是下面这些数字可以作为一个起点来参考:(root) 60MB/usr 420MB (没有 X) 或者 550MB (安装 X)/var 25MB/tmp 50MBswap 32MB这里讲的是安装一个完整系统所要的最小空间. 这个容量包括了能让你运行一个可以连到互联网上的

OpenBSD 咨询与维护 714

OpenBSD 4.2 安装指南(大结局)

<!--google_ad_client = "pub-5143338080895292";/* 728x90, created 4/10/08 */google_ad_slot = "6675122003";google_ad_width = 728;google_ad_height = 90;//--> <script type="text/javascript"

OpenBSD 咨询与维护 1130

龙芯2f笔记本- openbsd5.4安装手记

自从买了龙芯2f之后,这折腾也更来劲了,虽然有debian7.2可供选择,但是据网友们互传,装完之后还不如原来的共创好用,索性互相尝试,安装openbsd吧,在zhoubo童鞋毁掉1个U盘之后,我今天也学习如何安装openbsd了,首先在虚拟机中试下手...(硬盘设置为8G) 首先从官网下载一个镜像文件 ftp://ftp.openbsd.org/pub/OpenBSD/5.4/i386/ ...

过客阵营 -- 简单的就要最简单 731

[置顶] 龙芯2f笔记本- openbsd5.4安装手记

自从买了龙芯2f之后,这折腾也更来劲了,虽然有debian7.2可供选择,但是据网友们互传,装完之后还不如原来的共创好用,索性互相尝试,安装openbsd吧,在zhoubo童鞋毁掉1个U盘之后,我今天也学习如何安装openbsd了,首先在虚拟机中试下手...(硬盘设置为8G) 首先从官网下载一个镜像文件 ftp://ftp.openbsd.org/pub/OpenBSD/5.4/i386/ 下载

vb2005xu的专栏 656

在OpenBSD4.2安装显卡驱动

我的显卡是Intel 965,已经从官方网站上看到,已经支持了,模块是i810,安装步骤如下:1, 下载src.tar.gz,sys.tar.gz,xenocara.tar.gz,解压到 /usr/src : # tar -zxvf srs.tar.gz -C /usr/src # tar -zxvf sys.tar.gz -C /usr/src # tar -zxvf xenocara.tar....

23号博客 344

OpenBSD 升级指南 4.2 to 4.3

<!--google_ad_client = "pub-5143338080895292";/* 728x90, created 4/10/08 */google_ad_slot = "8165396160";google_ad_width = 728;google_ad_height = 90;//--> <script type="text/javascript"

OpenBSD 咨询与维护 1470

Python 2.5安装simplejson

OpenBSD 4.9-current没有给Python 2.5提供simplejson,我就用其它两种方式安装。 第一种是安装egg,很方便,但有问题。当导入simplejson的时候会出现“未定义的符号Py_SIZE”。 第二种方式是从源代码安装,步骤如下: 1、下载最新版本的simplejson,写这些字的时候是2.1.3。地址如下: https://github.com/s

daneil的专栏 1791

简单搭建 OpenBSD 4.2 -release 中文环境

首先,你需要 OpenBSD 4.2 -release 的源码。这包括两个文件:src.tar.gz, sys.tar.gz。可以在各大镜像站点的 4.2/ 目录下找到。比如台湾的镜像:BSD爱好者乐园"? / T U O ^ E e p s /4Z6w d(Fv9[ l A M"}&i"?!i Jftp://ftp.tw.openbsd

yaoasm的专栏 1042

OpenBSD 4.2 released today

<!--google_ad_client = "pub-5143338080895292";/* 468x60-08-4-11-network */google_ad_slot = "2798956624";google_ad_width = 468;google_ad_height = 60;google_cpa_choice = ""; // on file//--

OpenBSD 咨询与维护 2503

OpenBSD 4.5 Pre-Orders Online

Pre-orders are now being accepted for OpenBSD 4.5, scheduled for release on May 1st, 2009. The developers bring us an amazing amount of cool new stuff (Accelerated video drivers, OpenSSH 5...

23号博客 165
上一篇: OpenBSD 4.2 安装指南(1)
下一篇: OpenBSD 4.2 安装指南(3)
bsdplus
博客等级 码龄19年 3粉丝 32原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址