FreeBSD 小记
Essential settings is controlled by one unit – rc.conf.
X-server
Installing is simple, just install ports xorg.
cd /usr/ports/x11/xorg && make install clean
Then install DM you like(Gnome3, KDE). Compared developing Gnome3, developed KDE4 is more convenient, it’s also be my choice.
cd /usr/ports/x11/kde4/ && make install clean
Because FreeBSD takes source-based package ways, it’s would be a so long long journey especially when installing KDE4, so it’s joyful that watching anime(Fate/Zero).
When it ends, but if reboot instantly, it would be panic.
Hal and dbus service should be enabled manually when coperating using x-windows. So append following lines to rc.conf.
moused_type="auto" hald_enable="YES" dbus_enable="YES"
Also, you could choose GDM/KDM as WM depends DM, such xfce, awesome, etc.
Network
Note: for network adapters naming, freebsd don’t use linux ways(eth0), it’s ale0 and ath0.
Use ‘/etc/rc.conf’ to set network related configurations.
Ethernet
Ethernet is simple, dhcpcd is normal choice.
ifconfig_ale0="DHCP"
WLAN
But for WLAN, it’s a little bitter. First, you should hold wireless card information. For example, laptop Acer4732z wireless card is Atheros, so should load related kernel module when booting. So append following lines in file ‘/boot/loader.conf’.
if_ath_load="YES"
Then it depends specific wireless condition, wep/wap/tkip module should be loaded.
wlan_wep_load="YES" wlan_ccmp_load="YES" wlan_tkip_load="YES"
Final step is choosing wireless access point. In my dormitory, name of access point is ‘tsubameso’(つばめそ).
wlans_ath0="wlan0" ifconfig_wlan0="ssid tsubameso DHCP"
现在颇为困扰自己的为,当对无线接入点设置密码时,freebsd 下总是无法接入, 遂也只能退而求其次用 mac 地址限定进行接入限制。现在也还未确定是自己路由 器 TL-WR841ND 的缘由还是 freebsd 自身所引发的。
现在想来有趣的是,也因为 mac 地址限定都有那么几次发生了自己被困在了房间 外面,而钥匙就在房间内,各种囧境。上一次还是用着 kindle3 那聊胜于无的黑 白屏幕才进入夺取到钥匙的。
Sound
In FreeBSD, ALSA is private for Linux, so OSS architecture is only choice.
You should append sound driver module in /boot/loader.conf.
Because sound card in Acer4732z is ‘snd_hda_intel’(alsa), so append following lines to file ‘/boot/loader.conf’.
snd_hda_load="YES"
You could use ‘cat /dev/sndstat’ to query sound drive detailed info.
If you find that your headphone don’t work, you should use ‘sysctl’ to tuneup it. Also, you could use file ‘/etc/sysctl.conf’ to set it.
hw.snd.default_unit=2
make.conf
Wget
Using powerful wget as fetch command when coperating with ports.
FETCH_CMD=wget -c -t 1 DISABLE_SIZE=yes
Sources
Control how ports to fetch packages sources.
MASTER_SITE_BACKUP?=\ ftp://ftp3.jp.FreeBSD.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/\ ftp://ftp2.jp.FreeBSD.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/\ http://mirrors.163.com/FreeBSD/ports/distfiles/${DIST_SUBDIR}/\ ftp://ftp4.tw.FreeBSD.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/\ ftp://ftp.FreeBSDchina.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/\ ftp://ftp.cn.FreeBSD.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/\ ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/ MASTER_SITE_OVERRIDE?=${MASTER_SITE_BACKUP}
Csh
Csh is default shell in FreeBSD world, so just follow FreeBSD ways.
There are some slight differences between:
user csh(tcsh) settings is in file ‘.login’ and ‘.cshrc’, bash(sh) is in .profile and .bashrc(.shrc). When you should set environment variables, it’s should be patiented.
in csh, it’s syntax ‘setenv ENVIRMONT /usr/local/GNUstep/’ instead of syntax ‘export ENVIRMONT=/usr/local/GNUstep’ in bash.
Tips
Becuase FreeBSD use bsdlabel, it’s not like windows and linux. So extra compatible module should be loaded when booting.
geom_mbr_load=“YES”
Hosts
hostname=“Tiny.my.com”
NTFS Fuse-ntfs is a good choice.
fuse_load=“YES”
Then mount wanted partition in file ‘/etc/fstab’
/dev/ad4s5 /media/music ntfs rw,mountprog=/usr/local/bin/ntfs-3g,late 0 0
cpu temperature
When it turns to hot summer, compiling sources via ports it so dangerous, at least for my little Aspire4732z. So I have to try to downgrade it’s temperature via cpu frequency scaling adaptive and power saving.
powered_enable=“YES” powered_flags=“-a adaptive -b adaptive -n adaptive”
这样调节了之后,虽然在平时安静不繁重编译 ports 时确实慢了许多, 可以看到只有 150M,但是一旦进入关键编译 ports 时,cpu 还是会全速 工作,因此 cpu 还是会快速发热。
再度搭建 freebsd/kde 桌面时,在编译 thunderbird/QT4 这些大部件时又让 Aspire4732z 数度因为 cpu 温度太过而自动当掉。而在 cpu 风扇自动 调节还是无济之后,因此采用了强制降低 cpu 的频率,足足把运行速度 降低了一半。这样,在查看编译 ports 时 cpu 的温度确实要低了好多, 虽然相比全速运行要慢了些许。
sysctl dev.cpu.0 sysctl dev.cpu.0.freq=1050 sysctl -a | grep ‘temperature’
后记
最初写于去年暑假的初稿,竟然万分悲催的被自己莫名删掉了,只剩下了这纸还是 英文写下的初始文稿,之后也就一直被自己搁置着。也只待到真正要对硬盘做大手 术时才开始对这文章再细做一番整理,对 freebsd 总是有着莫名的好感。