

FreeBSD ϵͳԶ̨̿µԶ̰װ


Daniel Gerzo

<danger@FreeBSD.org>
Ȩ  2008 The FreeBSD Documentation Project
$FreeBSD: release/9.1.0/zh_CN.GB2312/articles/remote-install/article.sgml 38826
2012-05-17 19:12:14Z hrs $
FreeBSD  FreeBSDע̱
̺;ʹһЩΪ̱ͼԼĲƷ
ĵгֵģ Ϊ FreeBSD Project ֪̱꣬潫 '[TM]'  ''
ע
Ĺ鵵˵Զ̨̿õ FreeBSD ϵͳԶ̰װ
±Ҫй鹦ں Martin Matuska <mm@FreeBSD.org>  Pawel Jakub
Dawidek <pjd@FreeBSD.org> ṩıĽ
-------------------------------------------------------------------------------

1 

кܶķӦ̣ ֻкٵһʽ֧
FreeBSD ͨΪṩķϰװ Linux аṩ֧֡
ĳЩ£Щ˾ǻᰲװһѡ Linux
а档ѡǽͼװ FreeBSD
£ǿṩһϵͳڽ
ʹܽǵĿĸõʵ֡
ĺһ RAID-1  ZFS ܵ FreeBSD
ϵͳԶ̰װĻװĲ衣
-------------------------------------------------------------------------------

2 

һڻժҪĵĿԼòĶ
еЩָЩʹò֧ FreeBSD йʩṩķˡ

  1. ᵽ 
     һڣķйܹ˾ṩ˸ֵļϵͳ
     ԴԼ  ͨ SSH ʡ
     ͨṩ֧ĿڰǵĹ˿𻵵Ĳϵͳ
     ½˵ģǽܹͨЩϵͳİװ FreeBSD
  2. µһСڻãڱػϹС޶ȵ
     FreeBSDð汾ջ洢еԶ̻ȥ ⽫ʹ
     sysinstall ʵóһ FTP װһ FreeBSD ϵͳ
  3. µʣݳ ZFS ļϵͳûϵͳİװ衣

-------------------------------------------------------------------------------

2.1 

Ҫɹȥ룺

* ӵһͨ SSH ʵĲϵͳ
*  FreeBSD İװ
* Ϥ sysinstall(8) ʵó
* ӵ FreeBSD ŵ ISO ļʹõ CD

-------------------------------------------------------------------------------

3 ׼ - mfsBSD

 FreeBSD ܰװĿϵͳ֮ǰ ҪȹһСĴӴ
FreeBSD ϵͳӳļ ˷ϵͳܹʣ
ҰװܹûԶ̷ʵϵͳ̨ɡ
mfsBSD ùܹһ΢С FreeBSD ӳ mfsBSD ֵĺ
(mfs ˼ memory file system ڴļϵͳ)
ӳȫ洢Сԣ
̵Ĳκƣܹװһ FreeBSD ϵͳ
mfsBSD ҳ http://people.freebsd.org/~mm/mfsbsd/
ָͳùߡ
ע mfsBSD ĻԼеö˱ĵݣ
ȤĶӦȥ mfs ԭʼĵõϸݡ
زѹµ mfsBSD 汾ıԼĵǰĿ¼ mfsBSD
űļĿ¼

  # fetch http://people.freebsd.org/~mm/mfsbsd/mfsbsd-latest.tar.gz
  # tar xvzf mfsbsd-1.0-beta1.tar.gz
  # cd mfsbsd-1.0-beta1/

-------------------------------------------------------------------------------

3.1 mfsBSD 

 mfsBSD ֮ǰ һЩҪѡ
ҪǱȷأȻأá
ʺϵķѡȡǷ֪ǻõӿڣ
ӿӦϵͳΪǵӲ롣 ǽ mfsBSD
ܹһ±á
һҪ root 롣 ⽫ͨ༭ conf/rootpw.conf
ļɡ סļ뱣ڼ򵥵ıУ
ڴǲƼʹʵ롣Ȼ
ֻһʱʹһε룬װõϵͳи
-------------------------------------------------------------------------------

3.1.1 ༭ conf/interfaces.conf ķ

ǰװõδ֪͵ģ ǿʹ mfsBSD Զ̽⹦ܡ
mfsBSD űܹ̽⵽ȷʹã ӿڵ MAC ַǼ
conf/interfaces.conf ļѡ

  initconf_interfaces="ext1"
  initconf_mac_ext1="00:00:00:00:00:00"
  initconf_ip_ext1="192.168.0.2"
  initconf_netmask_ext1="255.255.255.0"

 defaultrouter Ϣ conf/rc.conf ļУ

  defaultrouter="192.168.0.1"

-------------------------------------------------------------------------------

3.1.2 ༭ conf/rc.conf ķ

ӿڵ֪͵ģʹ conf/rc.conf
ļѡӷ㡣 ļ﷨ FreeBSD б׼ rc.conf(5)
ļ﷨ͬ
磬֪ʹõĽһ re(4) ӿ豸  conf/rc.conf
ļѡ

  defaultrouter="192.168.0.1"
  ifconfig_re0="inet 192.168.0.2 netmask 255.255.255.0"

-------------------------------------------------------------------------------

3.2 һ mfsBSD ӳ

һ mfsBSD ӳļĹǷǳ˵ġ
һǹ FreeBSD İװ CD ߹ذװ ISO ļ /cdrom
ΪӵԵʣǽٶص FreeBSD 7.0-RELEASE ISO ļʹ
mdconfig(8) ʵó ISO ӳļ /cdrom Ŀ¼ǳ򵥣

  # mdconfig -a -t vnode -u 10 -f 7.0-RELEASE-amd64-disc1.iso
  # mount_cd9660 /dev/md10 /cdrom

ţ mfsBSD ӳ

  # make BASE=/cdrom/7.0-RELEASE


     ע: make  mfsBSD Ŀ¼һУҲǣ ~/
     mfsbsd-1.0-beta1/

-------------------------------------------------------------------------------

3.3  mfsBSD

 mfsBSD ӳѾ׼ˣ
ϴԶ̵һеļϵͳϻһԤװ Linux
аϵͳϡʺĹ scp

  # scp disk.img root@192.168.0.2:.

Ҫȷ mfsBSD ӳ ڻĵһ飨豸ϡ
ܻʹõǼٶһһ豸 sda

  # dd if=/root/disk.img of=/dev/sda bs=1m

һӳӦôڵһ豸
MBRҲӦܹˡ ʹù ping(8)
鿴Ƿȷ һظ״̬Ӧܹʹ root
ûúõͨ ssh(1) ˡ
-------------------------------------------------------------------------------

4 FreeBSD ϵͳİװ

mfsBSD ɹӦܹͨ ssh(1) ˡһڻδ
slices  slices  label Ϊ RAID-1  gmirror ʹ
sysinstall װһСFreeBSDϵͳ汾
-------------------------------------------------------------------------------

4.1 ׼

ҪΪ FreeBSD ̿ռ䣬Ҳǣ  slices 
partitionsȻ
ǰеϵͳȫ뵽ϵͳڴе˲̽ûκ⡣
Ҫ񣬿ʹ sysinstall  fdisk(8) еĶһϹ
bsdlabel(8)
ڿʼʱд̶ǳɿյģ ÿظ

  # dd if=/dev/zero of=/dev/ad0 count=2

棬ʹϲĹߴ slices Ǵ label Ƚϼ򵥵ķʹ
sysinstall ǿҲܼû©ʹñ׼Ļı UNIX ߣ
 fdisk(8)  bsdlabel(8)
ЩߵʹҲһаǰѾ FreeBSD ֲ װFreeBSD
һˡ籾иᵽģƪ»չʾһ RAID-1  ZFS
ܵϵͳǵһС gmirror(8) Ϊ / (root) /usr  /var
ļϵͳ ʣĴ̿ռ䱻Ϊ zpool(8)  ZFS ļϵͳע⣬
ZFS ļϵͳ FreeBSD ϵͳɹװŻᱻá
ӻȥ slices  labels ÿ partition ϳʼ
gmirror(8) ÿ partition ϴ UFS2 ļϵͳ

  # fdisk -BI /dev/ad0  (1)
  # fdisk -BI /dev/ad1
  # bsdlabel -wB /dev/ad0s1  (2)
  # bsdlabel -wB /dev/ad1s1
  # bsdlabel -e /dev/ad0s1  (3)
  # bsdlabel /dev/ad0s1 > /tmp/bsdlabel.txt && bsdlabel -R /dev/ad1s1 /tmp/
  bsdlabel.txt  (4)
  # gmirror label root /dev/ad[01]s1a  (5)
  # gmirror label var /dev/ad[01]s1d
  # gmirror label usr /dev/ad[01]s1e
  # gmirror label -F swap /dev/ad[01]s1b  (6)
  # newfs /dev/mirror/root  (7)
  # newfs /dev/mirror/var
  # newfs /dev/mirror/usr



  _(1)_
      ϴһ slice ʼڴ̵һ롣
      ظϵͳȫĴִд

  _(2)_
      Ϊÿдһݵı׼ label

  _(3)_
      ڣֶȥ༭̵ labelԲ bsdlabel(8)
      ֲҵν partitions ķ partionsa Ϊ /
      (root) ļϵͳ b Ϊ swap ռ䣬 d Ϊ /usr  f  ZFS

  _(4)_
      ղŴ label ڶ̣ ̻ʹͬ label

  _(5)_
      ÿ partition ϳʼ gmirror(8)

  _(6)_
      ע -F ѡ swap  partition gmirror(8)
      ָΪ豸ڿɿ״̬ǵԴϵͳϡ

  _(7)_
      ÿķϴһ UFS2 ļϵͳ

-------------------------------------------------------------------------------

4.2 ϵͳװ

Ҫһ֡
˽ڽһСѾ׼õĴϰװһС FreeBSD
汾ҪĿģеļϵͳҪ sysinstall ԰
FreeBSD ϵͳдϣ

  # mount /dev/mirror/root /mnt
  # mkdir /mnt/var /mnt/usr
  # mount /dev/mirror/var /mnt/var
  # mount /dev/mirror/usr /mnt/usr

Щʱ sysinstall(8) ˵ѡԶ Custom װ ѡ
Options ѡȻ󰴻سȷϡ ʹ÷ȡƶָ뵽 Install Root
ѡ ո Ϊ /mnt  س ύĸĲʹ q ˳ Options
ѡ˵

     :עһǳҪˣ sysinstall ܰװ
     FreeBSD

 Distributionsа棩˵ѡ ʹ÷ƶָ뵽
MinimalСѡ ʹ ո ѡиѡ
ʹС汾ͨϢΪϵͳͨ ftp װʹ
Exit˳ѡ˳˵

     ע:Partition  Label ˵ Щûжټֵˡ

Mediaý飩˵ ѡ FTP ѡ ѡһľվ㲢
sysinstall ٶѾá㽫ٻص Custom Զ壩˵
ѡѡִϵͳİװ̣ Commit װɺ˳
sysinstall ɡ
-------------------------------------------------------------------------------

4.3 ڰװ

FreeBSD ϵͳӦðװˣͨ£
װ̻ûнҪһЩװڵĲʹ FreeBSD
ڽܹϵͳ
ڱ chroot(8) հװȫµϵͳɰװ ʹ

  # chroot /mnt

ҪﵽǵĿģ²裺

*  GENERICͨãں˵ /boot/kernel Ŀ¼

    # cp -Rp /boot/GENERIC/* /boot/kernel

*  /etc/rc.conf /etc/resolv.conf  /etc/fstab ļ
  ҪȷϢ /etc/rc.conf ļ sshd /etc/fstab
  ļݣ

    # Device                Mountpoint      FStype  Options         Dump
    Pass#
    /dev/mirror/swap        none            swap    sw              0       0
    /dev/mirror/root        /               ufs     rw              1       1
    /dev/mirror/usr         /usr            ufs     rw              2       2
    /dev/mirror/var         /var            ufs     rw              2       2
    /dev/cd0                /cdrom          cd9660  ro,noauto       0       0

*  /boot/loader.conf ļдݣ

    geom_mirror_load="YES"
    zfs_load="YES"

* ִʹ ZFS ´ã

    # echo 'zfs_enable="YES"' >> /etc/rc.conf

*  adduser(8) Ӷû Ҫһû wheel
  飬 root Ȩޡ
* Ƿȷ

ϵͳ´Ӧÿˡʹ reboot(8) ϵͳ
-------------------------------------------------------------------------------

5 ZFS

ϵͳãӦܹˡ ӭոµ FreeBSD
װԶ̵ĲʹԶ̨̿İװ
ʣµĲ zpool(8) һЩ zfs(8) ļϵͳ ZFS
ǳ򵥡 ȣһpool

  # zpool create tank mirror /dev/ad[01]s1f

ٽ,һЩļϵͳ

  # zfs create tank/ports
  # zfs create tank/src
  # zfs set compression=gzip tank/ports
  # zfs set compression=on tank/src
  # zfs set mountpoint=/usr/ports tank/ports
  # zfs set mountpoint=/usr/src tank/src

ȫˡ FreeBSD ϵ ZFS Ȥ FreeBSD WIKI
е ZFS һڡ
-------------------------------------------------------------------------------
     ĵĵɴأftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.
 FreeBSD⣬Ķĵ粻ܽϵ<questions@FreeBSD.org>.
                 ڱĵ뷢ϵ <doc@FreeBSD.org>.
