Oct 17

根据帖子http://tieba.baidu.com/f?kz=927102511整理,我安装FreeBSD就是按照这个教程一步一步搞定的,现在将这个教程整理出来以备后用。

安装系统

FreeBSD 8.1 DVD,安装,distribution选的all,pakages选的Xorg meta port和Gnome 2 meta port,大概50分钟左右安装完成。

1.ifconfig 找到网卡

2.在/etc/rc.conf里面加:

ifconfig_re0="inet 本机地址 netmask 掩码地址" #用你的网卡代替re0
defaultrouter="网关地址"

3.在/etc/resolv.conf里面加:

nameserver DNS的地址

重启动,网络ok

安装桌面X11

1./etc/rc.conf里面加:

hald_enable="YES"
dbus_enable="YES"

这样X11可以找到键盘鼠标

2.运行:

Xorg -configure

$home里面生成一个xorg.conf.new文件

3.测试:

Xorg -config xorg.conf.new -retro

会看到一个黑白格的桌面和中央一个X,用Ctrl-Alt-F1调出tty0,按Ctrl-C推出X测试。

4.编辑xorg.conf.new文件,在”Section Screen”区里,加上DefaultDepth 24; 在SubSection Display区里,加上Modes 屏幕宽x屏幕高,像下面这样:

Section "Screen"
    Identifier "Screen0"
    Device "Card0"
    Monitor "Monitor0"
    DefaultDepth 24
SubSection "Display"
    Viewport 0 0
    Depth 24
    Modes "1024x768"
    EndSubSection
EndSection

5.copy编辑好的conf文件到指定位置:

cp xorg.conf.new /etc/X11/xorg.conf

Gnome设置

Gnome设置,如果之前没有使用其他的display manager,这一步很简单:
在~/.xinitrc文件里加入:

/usr/local/bin/gnome-session

输入命令:

startx

gnome桌面就启动了。

安装中文字体

# whereis wqy
wqy: /usr/ports/x11-fonts/wqy
# cd /usr/ports/x11-fonts/wqy
# make install clean

15分钟左右OK。

安装ibus

# pkg_add -r zh-ibus-pinyin

自动安装ibus和拼音输入法

让X系统启动时载入字体:
编辑/etc/X11/xorg.conf
在Section “Files”里面加一行,FontPath “/usr/local/lib/X11/fonts/wqy”像下面这样:

Section "Files"
    ModulePath   "/usr/local/lib/xorg/modules"
    FontPath     "/usr/local/lib/X11/fonts/misc/"
    FontPath     "/usr/local/lib/X11/fonts/TTF/"
    FontPath     "/usr/local/lib/X11/fonts/OTF"
    FontPath     "/usr/local/lib/X11/fonts/Type1/"
    FontPath     "/usr/local/lib/X11/fonts/100dpi/"
    FontPath     "/usr/local/lib/X11/fonts/75dpi/"
    FontPath     "/usr/local/lib/X11/fonts/wqy"
EndSection

设置启用ibus:
1.设置locale为UTF-8字符集
如果用csh或者tcsh,.cshrc 中增加:

setenv LANG zh_CN.UTF-8
#桌面界面语言为中文
setenv LC_CTYPE zh_CN.UTF-8
#locale的character type为UTF-8中文。此项不打开,将无法调出中文输入法
setenv LC_ALL zh_CN.UTF-8
#暂不清楚,推测是locale各项设置改为中文

如果用sh,.shrc中增加 [如果用bash,.bashrc中增加]

export LANG=zh_CN.UTF-8
#桌面界面语言为中文
export LC_ALL=zh_CN.UTF-8
#locale的character type为UTF-8中文。此项不打开,将无法调出中文输入法
export LC_ALL=zh_CN.UTF-8
#暂不清楚,推测是locale各项设置改为中文

2.让ibus daemon随X一起启动
.xinitrc中增加:

XIM=ibus
GTK_IM_MODULE=ibus
QT_IM_MODULE=xim
XMODIFIERS='@im=ibus'
XIM_PROGRAM="ibus-daemon"
XIM_ARGS="--daemonize --xim"

重启,OK。

startx,在panel右击ibus图标->preferences->input method->select an input method->Chinese->pinyin,点击Add,点close。
现在可以在桌面程序里使用ibus拼音输入法了。

补充说明一下:
.cshrc 里面的:

setenv LANG zh_CN.UTF-8
#桌面界面语言为中文 [如果想保留英文桌面可以remark掉,前面加'#']
setenv LC_CTYPE zh_CN.UTF-8
#locale的character type为UTF-8中文. [如果remark掉,将无法调出中文输入法]
setenv LC_ALL zh_CN.UTF-8
#暂不清楚,推测是locale各项设置改为中文 [remark掉无影响]

声卡驱动安装

1.先安装meta驱动试验:

# kldload snd_driver

检查是否有声音

# cat anyfile > /dev/dsp 有声音(杂音即可)

然后查看驱动加载情况:

#cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit 2009061500/i386)
Installed devices:
pcm0:  (play/rec) default
pcm1:  (play/rec)
pcm2:  (play)
pcm3:  (play)
pcm4:  (play)

一般会显示出driver名字,例如snd_ich. 但这里没有,好在根据HDA猜到了时snd_hda,并且在FreeBSD说明里找到了snd_hda支持此Realtek ALC889。

2.根据上述信息修改 /boot/loader.conf:

snd_hda_load="YES"

重启动,无声? 然后

#cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit 2009061500/i386)
Installed devices:
pcm0:  (play) default
pcm1:  (play/rec)
pcm2:  (play/rec)
pcm3:  (play)
pcm4:  (play)

发现此时的pcm0跟Generic driver时不同了,变成了HDMI输出,由于音箱不在HDMI上,因此判断应该将default输出指定到现在的pcm1上。

# sysctl hw.snd.default_unit=1
hw.snd.default_unit: 0 -> 1

检查是否有声音:

# cat anyfile > /dev/dsp 有声音

3.将此设置放到 /etc/sysctl.conf

hw.snd.default_unit=1

重启动OK。

Leave a Reply