freebsd9.0 安装手记

(一) 安装:

  在CentOS下面使用kvm安装freebsd9.0, 注意的是网卡的model需要选择为 "e1000"或者"rtl8139"才能在freebsd中被识别。

安装命令行:

# virt-install \
--name freebsd9.0 \
--ram 1024 \
--vcpus=2 \
--disk path=/(省略...)/freebsd9.img \
--network bridge=br0,model=e1000 \
--os-variant=freebsd8 \
--accelerate \
--cdrom /(省略...)/FreeBSD-9.0-RELEASE-i386-dvd1.iso \
--vnc


安装虚拟机完成后的xml配置文件:
<domain type='kvm'>
  <name>freebsd9</name>
  <uuid>efe5d2d2-5877-a593-8072-a15636809a6a</uuid>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
  <vcpu>2</vcpu>
  <os>
    <type arch='i686' machine='rhel6.2.0'>hvm</type>
    <boot dev='cdrom'/>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/(省略...)/freebsd9.img'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/(省略...)/FreeBSD-9.0-RELEASE-i386-dvd1.iso'/>
      <target dev='hdc' bus='ide'/>
      <readonly/>
      <address type='drive' controller='0' bus='1' unit='0'/>
    </disk>
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:24:1f:84:39'/>
      <source bridge='br0'/>
      <model type='e1000'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes'/>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
</domain>



(二)配置

0) 安装完成后,将用户加入wheel组, 并添加sudo支持。
   i) 以root用户登录,然后用pw命令或者修改/etc/group

 #pw usermod -G wheel freeuser
 #cat /etc/group

内容如下:
wheel:*:0:root,freeuser
   ii) 添加sudo支持(2种安装方法)

   a. (推荐)使用ports安装:
   #cd /usr/ports/security/sudo
   #make install clean
   b. 使用package安装
   #pkg_add -r sudo
   c. 配置sudo
   #visudo
  
  
1) 设置ports (使用portsnap同步ports)

  i) 修改portsnap 服务器:
   #vi /etc/portsnap.conf
   设置:
   SERVERNAME=portsnap.cn.freebsd.org
  ii) 执行更新命令:
    #portsnap fetch extract

   以后更新,只需要执行下面2步:
    # portsnap fetch
    # portsnap update
    这2步可以合成使用:
    #portsnap fetch update


  iii) 设置最快的ports镜像
    修改 /etc/make.conf, 加入如下内容:

MASTER_SITE_OVERRIDE=\
http://mirrors.163.com/FreeBSD/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.tw.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}\
ftp://ftp.hk.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}\
ftp://ftp.jp.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}\
ftp://ftp.kr.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}\
 

iv) 加快ports下载速度
  #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

 
  v) 配置其它参数( /etc/make.conf )
  WITH_GTK2=yes

2) 修改ls命令为彩色
  在linux下面的终端 ls支持彩色显示。安装gnuls即可。
  i) 安装gnuls
  #cd /usr/ports/misc/gnuls
  #make install clean
  ii) 配置
  a. bash情况, 修改/etc/profile
  alias ls="gnuls --color=auto --show-control-chars"
  b. csh情况, 修改/etc/csh.cshrc
  alias ls        'gnuls --color=auto --show-control-chars'
  重新登录即可。
 
3)  安装vim 
  i) 安装vim
  #cd /usr/ports/editors/vim-lite
  #make install clean
  或者:pkg_add安装(推荐)
  #pkg_add -r -v vim-lite
  ii)  配置vim
  全局配置:
  #sudo cp /usr/local/share/vim/vim73/vimrc_example.vim /usr/local/share/vimrc
  个人配置:
  #vim ~/.vimrc
  set number
  set autoindent
  set ruler
  syntax on

 
4)  修改字符集为UTF-8(以支持中文)
  i)如果是tcsh,修改~/.cshrc,把LANG和LC_CTYPE改为UTF-8。
            setevn LANG zh_CN.UTF-8
            setevn LC_CTYPE zh_CN.UTF-8
  ii)如果用sh或者bash,就相应改文件~/.shrc, ~/.bashrc
    LANG=zh_zh_CN.UTF-8; export LANG
        LC_CTYPE=zh_zh_CN.UTF-8; export LC_CTYPE

5) 定义Home,End,Delete键的动作(仅限bash/sh环境)

   i) 编辑或者新建 /usr/local/etc/inputrc文件,输入下面内容:
set meta-flag on
set input-meta on
set convert-meta off
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\x7F": backward-delete-char
   ii) 修改sh/BASH全局环境
   #sudo ln -s /usr/local/etc/inputrc /etc/inputrc
   #vim /etc/profile
   添加如下内容:
   export INPUTRC=/etc/inputrc

猜你喜欢

转载自siwind.iteye.com/blog/1480211