2011-11-19

FreeBSD RELENG_8 amd64 64 bit 的編譯

◆ FreeBSD RELENG_8 amd64 64 bit 的編譯

整理一下,免得忘記... 

P.S. 本文省略許多東西,初學者請勿照抄。

0. 預備動作跟之前 i386 32 bit 差不多

/ 最好設成 1G

然後修改 locale

+#setenv LANG
+setenv LC_CTYPE zh_TW.UTF-8
+setenv LC_COLLATE zh_TW.UTF-8
+setenv LC_TIME en_US.UTF-8
+setenv LC_NUMERIC zh_TW.UTF-8
+setenv LC_MONETARY zh_TW.UTF-8
+setenv LC_MESSAGES en_US.UTF-8
+setenv LC_ALL

PieTTY 的 Treat CJK ambiguous characters as wide 要拿掉



1. 開啟 AHCI 

將 fstab 改用 Labeled Filesystems,記得將 DVD-ROM 改成 cd0 (提示:gpart -l)

/boot/loader.conf

+ahci_load="YES"

/etc/sysctl.conf

+vfs.read_max=32

reboot

參考:

FreeBSD Labeled Filesystems
http://www.wonkity.com/~wblock/docs/html/labels.html

Moving A FreeBSD System To AHCI
http://www.wonkity.com/~wblock/docs/html/ahci.html



2. 修改 make.conf

+#CPUTYPE?=core2

理由:舊系統用 gcc 4.2.1,不認識 core2,更新後才換成 4.2.2,若系統也要用 core2,則更新後還要重跑一次。 

參考:

RELENG_8 does not build with CPUTYPE=core2
http://lists.freebsd.org/pipermail/freebsd-stable/2011-May/062664.html

[SOLVED] GCC options: (-m64) vs (-march=native) vs (-march=core2) -- Which one(s) to use? 
http://www.linuxquestions.org/questions/linux-software-2/gcc-options-m64-vs-march%3Dnative-vs-march%3Dcore2-which-one-s-to-use-758242/

Safe Cflags/Intel
http://en.gentoo-wiki.com/wiki/Safe_Cflags/Intel#Core_2_Duo.2FQuad.2C_Xeon_51xx.2F53xx.2F54xx.2C_Pentium_Dual-Core_T23xx.2B.2FExxxx.2C_Celeron_Dual-Core

其實目前用 -march=nocona 比較保險。

+CFLAGS= -O2 -pipe
+WITH_LIB32= yes
+WITHOUT_X11= yes
+WITHOUT= yes

然後 cd /usr/src ; make update



3. NIC 要使用 Polling?

核心加入:

+options DEVICE_POLLING
+options HZ=1000

同時在 rc.conf 的 ifconfig_em0 中加入:

media 1000baseT mediaopt full-duplex polling

參考:

FreeBSD Set Network Polling To Boost Performance
http://www.cyberciti.biz/faq/freebsd-device-polling-network-polling-tutorial/



4. 開始編譯

cd /usr/src ; rm -rf /usr/obj ; make cleandir clean

make buildworld TARGET_ARCH=amd64 TARGET=amd64

make buildkernel TARGET_ARCH=amd64 TARGET=amd64 KERNCONF=xxx

make installkernel TARGET_ARCH=amd64 TARGET=amd64 KERNCONF=xxx DESTDIR=/


參考:

Migrate system from i386 (32-bit mode) to amd64 (64-bit mode)
http://wiki.freebsd.org/amd64/i386Migration



5. 開始安裝

fsck -p

mount -u / ; mount -a ; adjkerntz -i

cd /usr/src/usr.sbin/mergemaster ; make all install

mergemaster -p

make install32 TARGET_ARCH=amd64 TARGET=amd64

make installworld TARGET_ARCH=amd64 DESTDIR=/

mergemaster -i

unmount -a ; reboot



6. 升級、安裝 pkg 與 ports

把 make.conf 改回來

portsdb -Uu

pkgdb -F

portupgrade -arR

cd /usr/ports/yyy/xxx; make config 

portupgrade -NRri xxx

-EOF-

沒有留言: