本文轉載:http://121.28.169.118/blog/?post=7
一、安裝基本系統
注意最簡化安裝,選擇standard,分區完成後,不勾選任何選項,不用懷疑,就連minimal都不勾選,不安裝任何軟體(ports、src,Linux_base-f10這些全不安裝),必須啟動SSH。
同步時間
ntpdate time.cn99.com
修改/etc/crontab
添加下面一行,每30分鐘自動同步時間
*/30 * * * * root ntpdate time.cn99.com
# ee /etc/ssh/sshd_config
將Port設定成自己喜歡的連接埠,PermitRootLogin設定成yes(注意用於生產時,請不要開始這項,保持預設)
/etc/rc.d/sshd restart
二、系統最佳化
1、使用portsnap安裝、同步ports系統
ee /etc/portsnap.conf
設定servername=portsnap.cn.freebsd.org
portsnap fetch extract
2、使用csup安裝、同步src代碼樹
csup -g -L 2 -h cvsup.tw.freebsd.org /usr/share/examples/cvsup/standard-supfile(建議)
或者
pkg_add cvsup-without-gui
reboot
cvsup -g -L 2 -h cvsup.tw.freebsd.org /usr/share/examples/cvsup/standard-supfile
重新編譯核心
cd /usr/src/sys/i386/conf
mkdir /boot/rescure
cp GENERIC /boot/rescure
cp GENERIC myneo
編輯完核心myneo檔案後--------------編輯核心參考手冊
#在/etc/make.conf裡加入NO_MODULES=true--------------這個使用的時候要注意,確實不需要可以加上。
安裝ccache,將會大大縮短編譯時間
cd /usr/ports/devel/ccache
make install clean
在/etc/make.conf中加入
.if (!empty(.CURDIR:M/usr/src*) || !empty(.CURDIR:M/usr/obj*)) && !defined(NOCCACHE)
CC=/usr/local/libexec/ccache/world-cc
CXX=/usr/local/libexec/ccache/world-c++
.endif
編輯ee ~/.cshrc
# ccache
# set ccache varibles
setenv PATH /usr/local/libexec/ccache:$PATH
setenv CCACHE_PATH /usr/bin:/usr/local/bin
setenv CCACHE_DIR /var/tmp/ccache
setenv CCACHE_LOGFILE /var/log/ccache.log
# set ccache temp size to 512MB (default 1GB)
if ( -x /usr/local/bin/ccache ) then
/usr/local/bin/ccache -M 512m > /dev/null
endif
下面開始編譯核心
cd /usr/src
make kernel KERNCONF=myneo
reboot
3、安裝axel
cd /usr/ports/ftp/axel
make install clean
修改/etc/make.conf
FETCH_CMD=axel
FETCH_BEFORE_ARGS= -n 10 -a
FETCH_AFTER_ARGS=
DISABLE_SIZE=yes
MASTER_SITE_BACKUP?=\
ftp://ftp.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp.cn.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
MASTER_SITE_OVERRIDE?=${MASTER_SITE_BACKUP}
4、安裝linux_base-f10
修改/etc/rc.conf
linux_enable="YES"
修改/etc/sysctl.conf
compat.linux.osrelease=2.6.16
修改/etc/make.conf
OVERRIDE_LINUX_BASE_PORT=f10
修改/etc/fstab
linproc /usr/compat/linux/proc linprocfs rw 0 0
修改完後,執行下面命令:
mkdir -p /usr/compat/linux/proc
mount /usr/compat/linux/proc
/etc/rc.d/abi start
/etc/rc.d/sysctl start
cd /usr/ports/emulators/linux_base-f10
make install clean
5、修改/boot/loader.conf
autoboot_delay="1"
beastie_disable="YES"
kern.dfldsiz="2147483648"
kern.hz="2000"
kern.maxdsiz="2147483648"
kern.maxusers="256"
kern.ipc.maxsockets="65535"
kern.ipc.nmbclusters="32768"
kern.ipc.nmbufs="65535"
kern.ipc.nsfbufs="2496"
net.inet.tcp.tcbhashsize="2048"
#linprocfs_load="YES"
#linsysfs_load="YES"
#procfs_load="YES"
#linux_load="YES"
6、修改/etc/sysctl.conf,加入以下內容(這些內容是經過查證後覺得有用的應該進行修改的參數):
net.inet.tcp.sendspace=32768
net.inet.tcp.recvspace=65536
net.inet.udp.maxdgram=65536
kern.ipc.maxsockbuf=524288
kern.maxfiles=65536
kern.maxfilesperproc=32768
net.inet.icmp.drop_redirect=1
net.inet.icmp.log_redirect=1
net.inet.ip.redirect=0
net.inet.icmp.icmplim=200
net.inet.tcp.msl=2500
net.inet.tcp.blackhole=2
kern.ipc.somaxconn=32768
kern.securelevel=2
kern.coredump=0
7、修改/etc/resolv.conf
nameserver 127.0.0.1
8、修改/etc/crontab,這是加入每天淩晨3點執行portsnap更新ports
0 3 * * * root portsnap -I cron update && pkg_version -vIL=
9、修改/etc/rc.conf
徹底關閉sendmail
sendmail_enable="NONE"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
關閉一些不安全的服務,最佳化啟動速度
nfs_server_enable="NO"
nfs_client_enable="NO"
portmap_enable="NO"
syslogd_enable="YES"
syslogd_flags="-ss"
icmp_drop_redirect="YES"
clear_tmp_enable="YES"
inetd_enable="NO"
開啟磁碟配額
enable_quotas="YES"
check_quotas="YES"
reboot------------其實這個重啟無太大必要,核心編譯完成的那次應該是真正意義的最後一次重啟,也就是說從安裝完系統到配置完畢,FreeBSD只需要重啟一次。
在這之後一個清爽的FreeBSD系統任你擺布。
終於自己好好的寫了這個筆記,以前總是安裝系統時一通上網查,現在不用了,還是給自己省了很多的時間,哈哈,舒坦!
標籤: FreeBSD
核心
基本系統 最佳化
代碼樹 編譯
Linux_base axel
etc reboot
筆記 loader.conf
sysctl.conf rc.conf