Tuesday, May 06, 2008

Adding extra disk to OpenBSD the fast way

This is to add an extra disk to OpenBSD system, in a simple and quick way. if you'd like to know more details and what we're doing by these commands, please go to OpenBSD faq "disk setup" page: http://www.openbsd.org/faq/faq14.html.

tested on openbsd 4.2.

NOTE: THIS  IS FOR LEARNING ONLY. DO NOT TRY ON YOUR PRODUCTION SERVER!!

1. power off your box

2. attache your disk to your computer

3. boot

4. login as root

5. check dmesg for the disk you just add.
     For a 2nd IDE disk, usually it's wd1; for 2nd SCSI disk, it's sd1 etc

6. run command: `fdisk -i wd1`, assuming it's 2nd IDE disk, brand new.

7. run command: `disklabel -E wd1`

8. under the disklabel command prompt, enter `a a` to add your first partition, accept all default setting in the following 3 prompt, the "offset" sector, end sector and fs type. this will make the whole disk as one partition "a"

9. enter 'q' to exit disklabel command and save your setting

10. run `newfs /dev/wd1a` to make new file system on the newly created partition.

11. make a directory, under which you want to mount the new partition to. `mkdir /vol0`.

12. run `mount /dev/wd1a /vol0`

13. you should be able to cd into /vol0 directory and do whatever you normally can do.
if you want to have this partition mounted automatically at every reboot, edit the "/etc/fstab" file, append to it the line `/dev/wd1a /vol0 ffs 1 1`

DONE.

Saturday, May 03, 2008

WAFL(Write Anywhere File Layout) 实现(1)


1. Overview

WAFL is a UNIX compatible file system optimized for network file access. In many ways WAFL is similar to other UNIX file systems such as the Berkeley Fast File System (FFS) and TransArc's Episode file system. WAFL is a block-based file system that uses inodes to describe files. It uses 4 KB blocks with no fragments.
Each WAFL inode contains 16 block pointers to indicate which blocks belong to the file. Unlike FFS, all the block pointers in a WAFL inode refer to blocks at the same level. Thus, inodes for files smaller than 64 KB use the 16 block pointers to point to data blocks. Inodes for files larger than 64 MB point to indirect blocks which point to actual file data. Inodes for larger files point to doubly indirect blocks. For very small files, data is stored in the inode itself in place of the block pointers.

一: 概览

WAFL是一个和UNIX兼容的文件系统,并专门为网络访问做了优化。在很多方面WAFL 都和Berkeley FFS文件系统以及TransArc的Episode文件系统很相似。WAFL是基于 磁盘块(block)的,它使用inodes来描述文件。它的block是4KB大,没有分片 (fragments)。

每一个WAFL inode(索引节点)包含16个block指针来表明哪些块属于这个文件。 和FFS不一样的是,所有的块指针都指向同一个层次的块,因此,对于小于64KB的 文件,inode的块指针直接指向数据块;对于大于64MB的文件,指针指向间接的 块,这些间接块则包含指向实际数据块的指针;对于更大的文件,这种间接块则会 再增加一级。而对于非常小的文件,数据则直接存储在inode里面那些存放块指针 的位置。

2. Meta-Data Lives in Files

Like Episode, WAFL stores meta-data in files. WAFL's three meta-data files are the inode file, which contains the inodes for the file system, the block-map file, which identifies free blocks, and the inode-map file, which identifies free inodes. The term map is used instead of bit map because these files use more than one bit for each entry. The block-map file's format is described in detail below.

2. 元数据存在于文件中

和Episode一样,WAFL把元数据存放于文件中。WAFL的三个元数据文件是inode文 件,包含文件系统的inode数据;block-map(块映射)文件,它标明空闲块;inode- map文件,标明空闲的inode。这里使用了map而不是bit map是因为这些文件为每个 条目使用了多于一个bit的空间。Block-map文件的格式细节如下图所示。

           ___________
           | |        |   root Inode
           |
           |________________________________________________
           | |     000    | |     000     | |    000       |            inode file

           |
           |____________   ____________     ___________  ____________
           |      _    _|  |___________|   | _____   __| |           |  all other files

           block-map file  inode-map file  all other files in the file system

           Figure 1: The WAFL file system is a tree of blocks with the
           root inode, which describes the inode file, at the top, and
           meta-data files and regular files underneath.           
           图1:WAFL文件系统是一个树状块,包含描述其他inode文件的位于顶
           部的root inode和 下面的其他的元数据文件和常规文件

Keeping meta-data in files allows WAFL to write meta-data blocks anywhere on disk. This is the origin of the name WAFL, which stands for Write Anywhere File Layout. The write-anywhere design allows WAFL to operate efficiently with RAID by scheduling multiple writes to the same RAID stripe whenever possible to avoid the 4-to-1 write penalty that RAID incurs when it updates just one block in a stripe.

将元数据放在文件里面让WAFL可以将元数据块写在磁盘的任何位置。这也是WAFL的 名称的由来—--任意可写文件格式。这种任意可写的设计让WAFL在RAID上的运行非 常有效,当它更新条带上的某一个块的时候,可以规划(schedule)多次写操作到 RAID条带,在任何可能的情况下避免RAID 4-to-1写操作带来的低效。

----待续---- --to be continued---


Sunday, April 27, 2008

Ten Must-have free security tools from eweek (bilingual)

1. Secunia Personal Software Inspector

The Secunia PSI examines .exe, .dll, and .ocx files on your computer and
matches the data against a file signatures engine to determine whether
you are running unpatched software programs. It then provides help in
patching the vulnerabilities that are identified.

Secunia是一家专注于安全技术的公司,他们的PSI软件会检查你电脑上的.exe,
.dll, 和 .ocx文件并将结果和文件签名引擎中的数据进行匹配以确定你正在使用
的软件是否已经打过补丁。如果没有,他们会提供帮助让你补上那些已经被查出的
漏洞。

Download link(下载链接): https://psi.secunia.com/

2. OpenDNS

No software to install. Just change your DNS settings to use OpenDNS
servers (208.67.222.222 and 208.67.220.220) to get valuable security
features—content filtering, adult site blocking, phishing and malware
blocking, and protection against DNS rebinding attacks.

无需安装任何软件,只是将你的DNS服务器设为OpenDNS提供的服务器
(208.67.222.222 and 208.67.220.220)即可使用他们的安全服务 -- 内容过滤,
成人网站拦截,欺骗性邮件和恶意软件拦截,并可保护你的DNS服务免于rebinding
攻击。

Download link(下载链接): http://www.opendns.com


3. Haute Secure

The free browser plugin (Internet Explorer and Firefox) covers the
growing data security hole between your firewall and anti-virus
programs. It provides an aggressive, color-coded early warning system
for drive-by malware attacks.

这是一个免费的浏览器插件,适用于IE和火狐(Firefox)。主要用于防火墙和防病
毒软件无法保护的那部分的数据安全。它针对恶意软件攻击提供很主动的并用颜色
标识的早期预警系统。

Download link(下载链接): http://www.hautesecure.com


4. Trend Micro RUBotted

This lightweight beta program intelligently monitors Windows machines
for remote botnet C&C (command and control) commands. These can include
commands to turn the zombie machine into a spam relay; launch
denial-of-service attacks; or host malicious Web sites for phishing attacks.

这个轻量级的测试程序智能地监视Windows系统以检测任何可能的botnet远程控制
命令。包括那些可以把僵尸机器变成垃圾邮件转发器,发动DoS攻击以及生成欺骗
性网站内容的命令。

Download link(下载链接):

http://www.trendsecure.com/portal/en-US/tools/security_tools/rubotted


5. AVG Anti-Rootkit

Detects and removes stealthy rootkits used by hackers to hide malicious
software from security programs.

侦测删除隐蔽的rootkit程序,防止hacker隐藏其他恶意程序以躲避安全软件的侦测。

Download link(下载链接): http://free.grisoft.com/doc/39798/us/frt/0

6. ZoneAlarm Firewall

Easy-to-use firewall systematically identifies hackers and blocks access
attempts.

非常易用的防火墙,系统地侦测和防止黑客行为

Download link(下载链接):

http://www.zonealarm.com/store/content/catalog/products/sku_list_za.jsp?lid=nav_za

7. BitDefender 10 Free AntiVirus

Provides on-demand scan engines to find and remove viruses. Features
include scheduled scanning, immediate scanning, ability to quarantine
suspicious files and reporting capabilities.

提供按需扫描引擎来侦测和删除病毒。主要特性包括:计划扫描,立即扫描,隔离
疑似病毒文件及报告功能。

Download link(下载链接):

http://www.bitdefender.com/PRODUCT-14-en--BitDefender-Free-Edition.html

8. CC Cleaner

This lightweight utility combines a system cleaner that removes unused
and temporary files URL history and cookies from the three main Web
browsers (IE, Firefox and Opera). It also features a registry cleaner.

这个轻量级的工具整合了系统清理和注册表清理功能,可以清理不使用的和临时文
件,URL历史,清理IE,Firefox和Opera的cookie。

Download link(下载链接): http://www.ccleaner.com/

9. WinPatrol

This ultimate watchdog program monitors Windows computers for signs of
malicious hacker activity. It can also be used to monitor, stop and
control Windows services, detect and review new auto-startup programs
and monitor IE home and search pages.

这个终极的防护程序监视Windows机器以发现可能的恶意黑客活动迹象。它还能用
于监视、停止和控制Windows的服务,检查自动启动程序并监视IE 的主页和搜索页。

Download link(下载链接): http://www.winpatrol.com/download.html

10. NoScript

This is a no-brainer for Firefox, Flock, Seamonkey and others
Mozilla-based browsers. This free add-on allows JavaScript, Java, Flash
and other plugins to be executed only by trusted web sites, providing
powerful anti-XSS protection directly in the browser.

这是一个针对Firefox,Flock,Seamonkey和其他基于Mozilla的浏览器的非常易于
使用的工具。这个插件可以让 avaScript, Java, Flash 和其他插件只被信任的网
站执行,为浏览器提供了很强有力的anti-XSS保护。

Download link(下载链接): http://noscript.net/

Saturday, April 26, 2008

Turn Off the PC-Speaker

 Did you ever get annoyed for that beeping sound from your Windows Machine, especially when you're in office or some other public places? You mute all sound devices but it didn't work. Here is how to turn it off.
 
当你正在办公室或者其他地方使用电脑,但突然它发出尖锐的"嘟嘟"声。 非常恼人,不是吗?你将所有设备都设为静音,但仍然无济于事。这里我们有一个办法来关掉它。

  In Windows 2k/XP,click "start >> Run", key in "devmgmt.msc" and press "Enter" to go into device manager, select the "Show hidden devices" option in the "View" menu, go to "non plug and play device" find that device named "Beep" and set it to disabled.

在Windows2k/XP中,点击"开始>>运行",输入"devmgmt.msc",在弹出的设备管理器窗口中,点击"查看"菜单,选中"显示隐藏设备"。然后在下面右边的窗口中点击"非即插即用设备",找到"beep",右键单击,选择"禁用",虽有按提示操作,重启电脑即可。



中 国 最 强 网 游 --- 网 易 梦 幻 西 游 ,166 万 玩 家 同 时 在 线

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.

Sunday, April 13, 2008

use proxy authentication with perl

Here is a simple script to grab a URL using proxy that requires authentication and using different port for different service:

use strict;
use LWP::UserAgent;
use HTTP::Request;

my $Silverfox = LWP::UserAgent->new();
$Silverfox->proxy(http =>'http://username:pwd@myproxy.com:8080');
$Silverfox->proxy(ftp =>'username:pwd@http://myproxy.com:81');
$Silverfox->no_proxy(qw('127.0.0.1' local));

# initialize proxy settings from environment variables
#$Sliverfox->env_proxy;

my $req = HTTP::Request->new(GET =>'http://www.bsdplus.cn');
print $Silverfox->request($req)->as_string;

Monday, June 11, 2007

上海ADSL无法访问此blog

最近在家无法访问http://alan0203.blogspot.com,因此也无法更新。
目前不得不考虑购买付费空间。无论如何,如果您对BSD感兴趣,请继续关注http://alan.thechengs.name,它会自动转到相应的blog(目前是http://alan0203.blogspot.com).

谢谢!

Monday, June 04, 2007

VI:一旦拥有,别无所求(2)

学习如何在打开的文档中移动光标是非常重要的基础,尤其是对于后面的复制或删除操作。之后,我们就学习如何插入文本和编辑文档。

进入插入模式有以下六种常见的方式:
1. i:在光标所在字符的左侧添加文本/字符
2. I:在当前行的行首插入
3. o:在当前行的下方新建一行并开始插入
4. O:当当前行的上方新建一行并插入
5. a:在光标所在字符的右侧添加文本/字符
6. A:在当前行的行尾插入

除了这六种方式之外,还有一个比较复杂一点的:

7. c{motion}:选中motion动作覆盖的文本并进入插入模式,用新的文本替换选中的内容.这里的motion就是指前面提到的移动操作。比如c$就是选中从光标所在位置到当前行尾的文本并进入插入模式。


拷贝和剪切操作
d:剪切选中的文本,并将文本放到剪切本中。
y:复制选中的文本
c:同d,但是会使vi进入插入模式,见上面c{motion}

p:粘贴。这个恐怕是vi中最简单的命令了,只需将光标移动到目标位置,按p将复制的文本粘贴

Friday, June 01, 2007

VI: 一旦拥有,别无所求

"To me, vi is Zen.
To use vi is to practice zen.
Every command is a koan.
Profound to the user,
unintelligible to the uninitiated.
You discover truth every time you use it."
--reddy@lion.austin.com

"对我来说,vi就是禅。
用vi就是坐禅。
每一个命令就是一个心印
对皈依者意义深远
对不了解者不可捉摸
每一次使用都会有新的发现"

VI是所有*NIX类系统都内置的一个命令行文本编辑软件,功能强大,命令繁多。初学时很难上手,但是一旦你熟悉之后,相信你不会再想使用其他的编辑软件。

本篇假定你已经熟悉VI的一些基本命令,如:
vi httpd.conf #打开一个名为httpd.conf的文档,如果不存在,将在当前目录下创建此文档;
输入“:wq”:存盘推出命令。
输入“:q!”:不存盘,强制推出
ESC:在命令模式与输入模式之间切换
i,I或者o等:插入文本命令........

VI之一:光标移动篇

这里我们先学习一下如何在一篇打开的文档中进行光标移动。

1. 方向键h,j,k,l.
h: 将光标向移动一个字符
j: 将光标向移动一个字符
k: 将光标向移动一个字符
l: 将光标向移动一个字符

这四个键相当于方向键,另设它们的好处是:你的手指不必离开正常的输入位置

2. 按字符移动的命令
fx: 移动光标至当前行下一个x字符处;使用;来重复上一次的f移动
tx: 同fx,但是移动光标至x字符前,而不是x字符上
Fx:通fx,但反方向移动

w:前移光标至下一个单词第一字符
W:前移光标至下一个长单词第一字符
e: 前移光标至下一个单词最后字符
E: 前移光标至下一个长单词最后字符
b: 前一单词第一字符
B: 前一长单词第一字符
(vi 按空格或标点符号分隔单词,按空格或新行来分隔长单词)

(: 到句首
): 到句尾

0: 到行首
^: 到行首第一字符
$: 到行尾

{: 到段首
}: 到段尾

*: 读取光标当前所在位置的字符,并将向前移动至下一个同样的字符
#: 和*功能相同,但反方向移动光标

Ctrl+F: 向前滚屏
Ctrl+B: 向后滚屏
H,M,L: 移动光标至屏幕的顶端,中间,底端

G: 移动光标至文档最后一行
numG: 移动光标至第num行

/text: 从光标处开始,向前搜索"text"字串
?text: 同上,但搜索方向相反

同时也发现一个图片vi教程,讲的也很清晰:www.litrin.org/UserFiles/Image/vi_png.jpg

Tuesday, May 29, 2007

PCBSD内核编译/升级

目的:将PCBSD的内核由FreeBSD 6.1升级至 6.2

步骤:

1. 升级source file至6.2

首先编辑/usr/share/examples/cvsup/standard-supfile文件,修改其中的两个地方:
将其中的*default release=cvs tag=RELENG_6_1一行改为 RELENG_6_2,
将*default host=CHANGE_THIS.FreeBSD.org中的CHANGE_THIS.freebsd.org替换为cvsup.cn.freebsd.org

修改完成後,运行如下命令:
cvsup /usr/share/examples/cvsup/standard-supfile

这个命令将会更新系统源文件至6.2版。

2. 创建内核配置文件MYKERNEL(或任何其他你喜欢的名字)

请以root帐户运行如下的命令:

# cd /usr/src/sys/i386/conf
# mkdir /root/kernels
# cp /PCBSD/conf/PCBSDv1.3 /root/kernels/MYKERNEL
# ln -s /root/kernels/MYKERNEL

这里,你可以编辑MYKERNEL文件,将一些不需要的内核选项去掉,这样编译出的内核将会更简洁,效率更高。比如其中有cpu 486/cpu 586,如果你的CPU是PII以上的,你就可以删除这两行,或者通过在行首加一个#符号来注释掉他们,只保留cpu686就可。

但你一定要清楚每个选项的意思,否则请不要随意更改,不然很可能导致系统无法启动。


3. 编辑/etc/make.conf文件
如果下面的内容不在make.conf文件中,请添加:
CPUTYPE=i686 #i486, i586, i586/mmx, i686, p2, p3, p4, athlon,athlon-xp, athlon64, opteron
RELEASETAG="RELENG_6_2"
SUP_UPDATE=yes
SUP=/usr/local/bin/cvsup
SUPFLAGS=-g -L 2
SUPHOST=cvsup.cn.FreeBSD.org
SUPFILE=/usr/share/examples/cvsup/standard-supfile
PORTSSUPFILE=/usr/share/examples/cvsup/ports-supfile
#DOCSUPFILE=/usr/share/examples/cvsup/doc-supfile
KERNCONF=MYKERNEL

4.编译并安装内核

依次运行如下命令:
#cd /usr/src
#make buildkernel
#make installkernel
#reboot

重启後你的PCBSD系统就是6.2版的内核了。其中buildkernel和installkernel的过程需要很长的时间,尤其是你的CPU和内存不是很多的话。

5. 验证

重启完成後,可以运行如下命令来查看目前的内核版本:

# dmesg | grep RELEASE
FreeBSD 6.2-RELEASE #0: Fri Jan 12 10:40:27 UTC 2007

每个人的输出并不相同,但只要你看到6.2-RELEASE的字样,就表示你已经成功了~

ENJOY!

Thursday, May 24, 2007

命令行下使用代理服务器

在企业环境下经常需要PCBSD穿过代理服务器来访问外网,尤其是使用ports进行软件安装的时候。要设置HTTP代理服务器,请使用如下命令:

setenv HTTP_PROXY http://username:password@proxy_server_name:PortNumber

不需要验证的,就把username:password@部分去掉就行了。

没有测试过这个方案对微软的ISA server代理是否有效,ISA的验证是结合AD账户进行的,和普通的代理在密码验证协议上会有些差别。不过可以试试:

setenv HTTP_PROXY http://proxy_server_name:portNumber
setenv HTTP_PROXY_AUTH basic:*:username:password

用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”的选项了。

Tuesday, May 22, 2007

PCBSD: Intel显卡上使用宽屏分辨率

要在Intel系列的显卡上使用宽屏,尤其是9XX系列的,需要自己动手修改一些东西。下面是我在Dell Latitude 620(Intel945GM芯片)上测试的结果,大致也适用于其他的Intel显示芯片。步骤如下:

1. 下载并编译、安装915resolution 程序。
对于915或者更早的显卡,可以直接使用ports进行安装。
a. “开始”》“系统”》“终端程序”(或者是叫K-console什么的,忘记中文名称了),打开一个命令行窗口。
b. 运行“su”,然后输入root帐号密码,准备以root身份进行安装。
c. cd /usr/ports/sysutils/915resolution
d. make install clean

对于945GM芯片的用户,目前请不要直接使用上面的安装方式,因为ports里面的是0,5.1版,还不支持945GM,你需要这里下载0.5.2版的源码包然后编译、安装。
URL:http://www.geocities.com/stomljen/915resolution-0.5.2.tar.gz
步骤如下:

a. 解压:tar -zxvf 915resolution-0.5.2.tar.gz
b. 安装:make && make install (需要root权限)

2. 安装完成后,运行:915resolution -l,列出所有可能的模式:

# 915resolution -l
Intel 945GM VBIOS Hack : version 0.2

Chipset: 945GM

Mode 30 : 640x480, 8 bits/pixel
Mode 32 : 800x600, 8 bits/pixel
Mode 34 : 1024x768, 8 bits/pixel
Mode 38 : 1280x1024, 8 bits/pixel
Mode 3a : 1600x1200, 8 bits/pixel
Mode 3c : 1920x1440, 8 bits/pixel
Mode 41 : 640x480, 16 bits/pixel
Mode 43 : 800x600, 16 bits/pixel
Mode 45 : 1024x768, 16 bits/pixel
Mode 49 : 1280x1024, 16 bits/pixel
Mode 4b : 1600x1200, 16 bits/pixel
Mode 4d : 1920x1440, 16 bits/pixel
Mode 50 : 640x480, 32 bits/pixel
Mode 52 : 800x600, 32 bits/pixel
Mode 54 : 1024x768, 32 bits/pixel
Mode 58 : 1280x1024, 32 bits/pixel
Mode 5a : 1600x1200, 32 bits/pixel
Mode 5c : 1920x1440, 32 bits/pixel
Mode 60 : 1280x770, 8 bits/pixel
Mode 61 : 1280x770, 16 bits/pixel
Mode 62 : 1280x770, 32 bits/pixel
Mode 63 : 512x771, 8 bits/pixel
Mode 64 : 512x771, 16 bits/pixel
Mode 65 : 512x771, 32 bits/pixel
3. 选择其中的一个和你当前的分辨率一样的mode的代码,16 bits或者是32bits色深的。例如我的系统修改前是1024x768,而我想使用1280x800的分辨率,我使用如下的命令:

915resolution 45 1280 800

命令结束后再次运行 915resolution -l,你会看到mode 45已经变成1280x800了。

这里是915resolution的一些用法指南,可以参考一下:http://www.geocities.com/stomljen/readme.html

4. 编辑/etc/rc.local文件,添加如下语句:
/usr/sbin/915resolution 45 1280 800

5. 编辑/etc/X11/xorg.conf,找到LOAD DRI一行,在此行的最前面加一个#,将此行注释掉。你或许并不需要这一步,在其他任何资料上都没有看到,但对我的945来讲,Load DRI会在log里报错,我只有将它去掉。

6. 重启系统,如果分辨率没有自动改为你设置的模式的话,在桌面上右键单击,然后”重新配置桌面“》”显示“,选择你需要的分辨率即可。

下面是一些相关的资源,如果你的安装不顺利的话,可以参考一下。

检查/var/log/Xorg.0.log文件,查看其中的报错信息。
http://www.geocities.com/stomljen/
http://www.freebsd.org/doc/en_US.ISO8859-1/articles/laptop/article.html
http://forums.pcbsd.org/viewtopic.php?t=8196

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!

PCBSD下如何安装软件

PCBSD下的软件是通过.PBI格式发布的,安装和在Windows下一样,安装时有图形界面的向导,你只需接受协议,然后点击“下一步”就行了。所以软件安装的关键就在于如何找到/得到你想要的PBI文件。

想要浏览/查找pbi格式的软件,到www.pbidir.com网站,那里是PCBSD的官方软件发布站点,汇集了所有开发好的以及正在开发中的PBI软件;同时你也可以查看一个PBI的wishlist,并且把自己希望但目前并没有的软件添加到wishlist中,或许某个developer会感兴趣也不一定。

另外,由于一些授权协议方面的原因,一些软件的PBI包从官方的站点上删除了,但是你可以在这个站点找到:www.pbis.in. 请注意自己是否有相应的授权。

另外,如果你对PBI很有兴趣的话,可以尝试自己创建一个PBI软件。这里有一篇英文的教程,出自Dru Lavigne教你如何利用已有的FreeBSD软件包和PCBSD提供的PBI Creator程序来创建自己的PBI软件。

Building Binary PC-BSD Packages

*PCBSD是FreeBSD的一个小的变体,但他们的内核基本是相同的,所以FreeBSD的软件包都可以用在PCBSD上的,只是要在命令行下安装。

Monday, May 14, 2007

PCBSD FAQ (不定期更新)

Q. 可以自定义PCBSD的安装软件包吗?
A. 不可以。默认情况下PCBSD是作为一个完整的安装包来安装的。你可以在安装完成后使用pkg_delete命令来删除一些你不想要的软件。但是不建议这样做,因为你很可能把KDE桌面环境搞坏掉。

Q. 我的电脑上已经安装了Windows系统,安装PCBSD会影响我的程序和数据吗?如何才能保留原来的数据?
A. 如果你的硬盘上还有剩余空间(未分区的空间,free space,不是某个分区未用完剩下的空间),那就不要把PCBSD安装到Windows分区上,否则你原来的数据丢失。

Q. PCBSD和FreeBSD的区别是什么?
A. 见下表:


PC-BSD FreeBSD
默认桌面环境
KDE 无 (用户需自行安装)
应用程序安装 PBIs (就像Windows), Ports, Packages Ports, Packages
64 位架构
兼容 内核级支持(Native)
支持平台 x86 (包括 Pentium® 和 Athlon™) x86 (包括 Pentium® 和 Athlon™), amd64 compatible (包括 Opteron™, Athlon™64, 和 EM64T), UltraSPARC®, IA-64, PC-98 以及 ARM 架构
应用程序集成 一般
系统安装 PC-BSD 系统安装向导
sysinstall (基于文本的安装工具)
Linux 兼容性 可选 可选
内核 FreeBSD FreeBSD
最小安装要求 i686 CPU, 128MB 内存 和 4GB 硬盘空间 非常小
对称多处理器 优化 可选
目标群体 桌面 (也可兼作服务器
服务器

Q. 如果我忘记了root帐号的密码怎么办?
A. 在系统启动出现倒计时后按空格键停止计时(也可以直接按6,如果你足够快的话),然后按6,出现提示符,输入 "boot -s",进入单用户模式,出现#符后,运行 "/sbin/mount -a" 命令,然后"passwd root",即可重设root的密码。完成后reboot,重新启动。

补充一下:在PCBSD1.3里,在启动选择菜单里直接选择4即可进入单用户模式。进去以后直接运行mount -a命令,然后即可passwd root来修改root的密码。

Q. PCBSD 下如何进行中文输入?
A. 请参考此连接: http://pcbsd.bokee.com/tb.b?diaryId=15269431

Q。如何让英文的PCBSD系统正确显示中文字符?
A。 首先,需要添加简繁体中文支持程序。通过pkg_add程序添加zh_CN-kde-i18n-3.5.5.tbz和zh_TW-kde-i18n- 3.5.5.tbz两个程序包.它们都在PCBSD第二张ISO的LANG文件夹下;第二,再通过Settings >> regional & accessibility >> country &amp; language程序来添加中文语言支持;第三,修改你自己的home文件夹下的.profile文件,将其中的LANG=和LC_CTYPE=设置为 zh_CN.UTF8.
另外,关于系统和语言以及LOCALE的关系,chinaunix.net上有一篇比较好的文章可以参考,虽然这个问题并无直接的联系.URL: http://linux.chinaunix.net/bbs/viewthread.php?tid=894403&extra=page%3D1

Q。为什么将LC_TYPE设置为中文编码以后FIREFOX的菜单栏字体会变化,模糊?
A.在"开始>>设置>>控制中心>>外观与主题>>GTK字体与风格"中 选中"在GTK应用程序中使用我的KDE字体",保存,重新登录即可.

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账户登陆)

FCITX -- PCBSD下的中文输入

经过一天的努力,总算是把这个东西搞定了。今天可以 在 PCBSD下写这篇日志了。这里简要说一下大概的过程 :

1. 程序名称 fcitx。你可以去www.fcitx.org上下载 ,目前最新版本为 3.4.2
2. 功能: 中文输入
3. 下载后 用tar -zxfv 解压,然后编译运行./configure
4. 如果编译过程中遇到 类似“undefined reference to libiconv”的错误,那么在congiure时加入选项 --libdir=/usr/local/lib,或者指定你自己的 libiconv。so的路径

5. 然后 make && make install && make clean
6. 完成后,修改自己的home目录下的 .profile文件,加入下面几行:(这里我用的是SH shell,其他shell的语法可能有所不同)

LANG=zh_CN.Gb2312
export LANG
LC_CTYPE=zh_CN.Gb2312
export LC_CTYPE
LC_COLLATE=POSIX
export LC_COLLATE
GTK_IM_MODULE=xim
export GTK_IM_xim
XMOIFIERS="@im=fcitx"
export XMODIFIERS

完成后保存、推出。重新登录即可。

要进行中文输入时,首先运行fcitx,按ctrl+空格 切换到中文输入状态。

要了解它的用法,请到它的网站下载相关说明。源码包中也有说明

有问题请留言,谢谢 !

(用下来感觉不错~~)

PCBSD下字体美化

默认安装下,PCBSD的字体显示效果很差,尤其是中文环境下。
但要改变却也很容易。先看一下效果图:


点此看大图:http://pcbsd.bokee.com/photo/view.fcgi?id=6141676&mode=4&mode=3

下面是字体设置的一些关键步骤:
1. 下载字体
到http://fundawang.lcuc.org.cn/wqy/下载文泉译点阵字体源码包,一搬是一个.tar.gz结尾的文件。
(如果你看到这篇文章不是太晚,可以试试:http://fundawang.lcuc.org.cn/wqy/wqy-bitmapfont-bdf-all-nightly_build.tar.gz)
2. 解压,运行 tar -zxvf wqy-bitmapfont-bdf-all-nightly_build.tar.gz
3. 在“开始 > 设置 > 系统管理”中找到字体安装程序,将解压出的字体安装
另外,你也可以把windows下的字体文件也拷贝过来,进行安装。
4. 在“开始 > 设置 > 外观与主题”中选择字体,然后逐一设置即可
5. 题外话:我使用的是FireFox2.0版,用它来看中文网站的话,需要再设置一下(编辑 〉选项 > 内容),在高级选项中禁止网页自己选择字体即可。

如果你设置时遇到什么问题,请留言。谢谢!

PCBSD Tips之TCPDUMP

TCPDUMP 是BSD以及其他UNIX上的一个功能强大的抓包工具。 和SNIFFER或者Etheral比起来,它的功能并不逊色,只是界面远不如前两者那么友好。但他的优点在于无处不在:shipped with Operating System。

在使用TCPDUMP时需要root权限,另外一点就是需要Kernel中启用的bpf(默认已经启用)。

开始抓包之前,请先使用ifconfig -a 确认机器的网络接口,比如ed0,rl0 等等。

tcpdump -i ed0

开始在ed0接口上进行抓包。-i 用于指定网络接口。期间按下Ctrl+t可以查看抓获的数据包的数量,Ctrl+c停止。

tcpdump -w dumpfilename -i ed0,将输出重定向到dumpfilename文件中。

上面得到的文件是不能使用普通的编辑器察看的,只有tcpdump自己或者其它类似的抓包工具可以查看。

tcpdump -r dumpfilename | more,此命令查看捕获的数据包文件

如果只想抓某一类型的包,可使用:

tcpdump -i ed0 broadcast
tcpdump -i ed0 ARP
tcpdump -i ed0 ICMP

捕捉某两台特定的主机之间的数据:

tcpdump -i ed0 host SRV1 and SRV2
tcpdump -i ed0 src host SRV1 and dst host SRV2

tcpdump -i ed0 udp port 25

tcpdump本身对带有很多关键字,比如 ‘and’,‘or’,‘not’等等,使用这些Key words可以构建很多自定义的抓包过滤器,比如

tcpdump -i ed0 net 192.168.1.0 and not arp

(文章出自BSD Hacks by Dru Lavigine)