f5b 发表于 2012-11-07 17:48

OpenBSD启动U盘制作(flash boot system)

OpenBSD启动U盘制作(flash boot system)

可结合全盘加密安装OpenBSD 帖子http://bbs.chinaunix.net/thread-3779149-1-1.html

一、 先参看http://www.openbsd.org/faq/faq14.html#flashmemLive

二、 将以下文件刻录光盘,然后安装OpenBSD操作系统到U盘,懂PXE或硬盘已经有bsd.rd可节省光盘。
http://ftp.openbsd.org/pub/OpenBSD/snapshots/i386/install??.iso


三、 安装过程中,分区步骤那里,3G以上U盘,可以把0分区弄成fat32分区(0B),1分区弄成OpenBSD分区(A6),OpenBSD分区2G一般够用。
fdisk操作过程看http://www.openbsd.org/faq/faq4.html
4.6.3 - Custom fdisk(8) layout
注意,做完fdisk操作用quit才会保存退出,exit是不保存返回!

四、 优化修改
1. 在多核CPU电脑上安装系统之后,将内核更换为单核版本提高此U盘适应性
bsd.sp(单核),bsd.mp(多核)
# mv bsd bsd.mp && mv bsd.sp bsd
安装过程不选择bsd.mp更好,comp5?.tgz也没有必要。

2. Windows系统的主机BIOS时间就是本地时间(local time是北京时间+8),所以,把OpenBSD安装到U盘过程中选择时区(PRC)且没让立即同步网络时间,之后按以下方法修改可让

同一台主机的OpenBSD(U盘)和Windows(硬盘)显示时间兼容。
# config -ef /bsd
ukc> timezone -480   
ukc> quit
注意,修改后必须重新启动系统才生效。
参考 http://www.openbsd.org/faq/faq8.html#TimeZone
- Why is my clock off by several hours?

3. 添加多几个hostname.if提高此U盘适应性
#cp /etc/hostname.em0 /etc/hostname.fxp0
#cp /etc/hostname.em0 /etc/hostname.re0
#cp /etc/hostname.em0 /etc/hostname.vge0
#cp /etc/hostname.em0 /etc/hostname.rl0
#cp /etc/hostname.em0 /etc/hostname.bge0
#cp /etc/hostname.em0 /etc/hostname.bce0
#cp /etc/hostname.em0 /etc/hostname.bnx0
#cp /etc/hostname.em0 /etc/hostname.vr0
解释 Different target machines will likely have different NICs. You could create a bunch of hostname.if(5) files in /etc, each containing just dhcp, for all

the NICs you are likely to encounter (fxp0, re0, rl0, bge0, bnx0, em0, etc.) on USB-bootable machines, plus maybe sample wireless config files as well.

OpenBSD will ignore all hostname.if(5) files for devices not present at boot time.


4. 更改fstab文件,顺便添加参数softdep和noatime提高磁盘性能,例如
024b5061fc294e12.a / ffs rw,softdep,noatime 1 1
024b5061fc294e12.e /home ffs rw,softdep,noatime,nodev,nosuid 1 2
024b5061fc294e12.d /usr ffs rw,softdep,noatime,nodev 1 2


5. 要支持更多无线网卡,必须预安装firmware
下载地址http://firmware.openbsd.org/firmware


------------------其他tips

五、添加mp3播放软件
1. 安装OpenBSD系统之前最好fdisk给U盘分配部分fat32空间,参看第三点。
2. 安装mpg123这个port
3. 在Windows系统里面快速格式化之前分配的fat32空间,将mp3文件copy到u盘里面去,歌曲名最好是英文或数字哦


六、添加Offline NT Password & Registry Editor破解Windows操作系统登录密码
OpenBSd 4.9 之后默认安装都可以直接mount_ntfs挂载ntfs分区,安装ports/security/chntpw(Offline NT Password & Registry Editor),
操作例子
# disklabel wd0显示部分信息如下
#             size         offsetfstype
c:      976773168                0unused
i:      157581522               63    NTFS
j:      819186417      157581648    NTFS
估计i分区应该是Windows系统盘
# mount_ntfs -o rw /dev/wd0i /mnt
# cd /mnt/Windows/System32/config
# chntpw -i SAM
根据交互模式提示完成操作即可修改密码

七、sftp和share文件共享
1. 创建一个专门用于访问共享目录的用户share,用户shell是nologin
# vi /etc/ssh/sshd_config
+MaxAuthTries 3
+UseDNS no    #局域网使用可提高登陆速度
share用户的特殊设置
Match User share
      X11Forwarding no
      AllowTcpForwarding no
      ForceCommand internal-sftp
      ChrootDirectory /home/share/

2. 用U盘启动系统并共享硬盘里面的数据给局域网电脑访问
假定U盘系统ip是10.0.0.154,
# chown root:wheel /home/share/
# mkdir -p /home/share/upload
# chown share /home/share/upload/   #share用户可上传文件到upload目录

# mkdir /home/share/d
# mount_ntfs /dev/wd0j /home/share/d
此后在另外一台电脑通过Fizilla(默认utf-8)访问sftp://share@10.0.0.154/d 就可以copy里面的数据
即使mount_ntfs -o rw也不支持write,chntpw除外,详情man mount_ntfs

ulovko 发表于 2012-11-07 17:54

感谢楼主分享, 辛苦了 ! ^_^ :emn31:
页: [1]
查看完整版本: OpenBSD启动U盘制作(flash boot system)