                            NanoBSD A^2CURP:

  Daniel Gerzo

   $FreeBSD: release/8.4.0/zh_TW.Big5/articles/nanobsd/article.xml
   39632 2012-10-01 11:56:00Z gabor $

   -a(c)AAv (c) 2006 The FreeBSD Documentation Project

   $FreeBSD: release/8.4.0/zh_TW.Big5/articles/nanobsd/article.xml
   39632 2012-10-01 11:56:00Z gabor $

   FreeBSD NOTO FreeBSDDEGo-a-:.|-a-ouuYENUDEGO 1/4D-

   ^3\|h>>s^3yDEGO(c)M,g 3/4PDEGO"IYENICUR@"C,-oUNOTDEGDEGO
   1/4D--a-o^1I(R) *(c)ICURaa|r^3]p"O^1u:AAa|UCURv-a-o^2-L-<<~!C
   YEN>>CURaaCURCURYENX^2{-a-o^2^3|hDEGO 1/4D-!AYENHCURI FreeBSD
   Project YEN>>" 1/4s(c)OCURH-a 3/4-a-oDEGO 1/4D-!A<<a+-+-NYENH
   '(TM)' (c)I '(R)' ^2AA,^1"O 1/4D-uu!C

   ^3o 1/2gCURaaYENo'-L-"NCURFAo:(c)o NanoBSD
   CURu"a-a-o+-!^3o/CURP:^2D-!A
   ^3oCURu"aYENiYENI"O<<O/YENssYENI(c)o'OCURJ|!Ao^1OA^3YENIu{|!-a-o
   FreeBSD "t^2INOTM^1^3AE!A YENH<<K|s(c)n"`i Compact Flash
   YENd((c)IAH"-oD-)!C

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

1. NanoBSD A^2CURP:

   NanoBSD NOTO Poul-Henning Kamp <phk@FreeBSD.org>
   YENO/<<eYEN?|bP:}uo-a-oCUR@P:uCURu"a!C
   YEN|YENiYENI"O<<O/YENssYENI(c)o'OCURJ|!Ao^1OA^3YENIu{|!-a-o
   FreeBSD "t^2INOTM^1^3AE!A YENH<<K|s(c)n"`i Compact Flash
   YENd((c)IAH"-oD-!Amass storage medium)!C

   ^3oCUR@CURu"aCUR]YENiYENHYENI"O|U>>s|w,ENOTM^1^3AE!A
   YENHA^2CURAE<<U-oUNOTDEG !S:'OCURJ|!"t^2I(computer appliances)!"
   -a-o"t^2I|w,E!B-ouAA@CURuS:@!C
   ^3q+-`!A"CO'OCURJ|!"t^2I^2-L-<<~^3-L-|^3(c)wuwAAe(c)M^3nAAe!A
   (c)I-aI'<<"YENCURS:!A(c)O|^3-a-oA^3YENIu{|!^3-L-NOTO^1wYENy,E|n-a-o!C
   ^3o"C,^3]^3AEYENiYENH-a
   1/2+-u(c)n"`i^2{|^3-a-o-oo,oCURCUR!A|OYENB('XYENGNOTO)YENssS:Y"IYENI!C

   NanoBSD '-L-"N-a-oYEN\-`aYEN]NOTA!G

     * YENiYENH(c)M FreeBSD CUR@ 1/4E"IYENI Ports (c)M Packages !X!X
       (c)O|^3-a-oA^3YENIu{S:C,^3-L-YENiYENH|b NanoBSD CURCUR-a
       1/2+-u"IYENI!A |OCURe|!>>P FreeBSD S:^1YENthCUR@ 1/4E!C

     * YEN\-`au.^2@YEN 1/4.l !X!X |b FreeBSD
       DEGu-a-oYENo|oCURuS:@!A^3-L-YENiYENH|b NanoBSD CURCUR"IYENI!A
       DEG-L-<<D+-z|b<<O/YENss NanoBSD NOTM^1^3AE(R)E!A
       |^3<<u:(c)wn(R)^3+- 1/4YEN|I!C

     * (c)O|^3-aF|e|b^1B|ae(R)E^3-L-NOTODEGssAA-a-a-o !X!X
       YENiYENH|wYENth|a(c)TH+- 1/4^1q. 1/2'!AY!C
       "t^2ICUR-L-YEN?+-`Ao: 3/4-:-a-o,U:!ACUR-L-YENI|AP:] fsck(8)
       CURF!C

     * YENi>>'AP 1/2sA:P:!B|U|aeYEN'^3y !X!X YENu>>Y"IYENICUR@O shell
       script (c)MCUR@O^3](c)wAE!A +-zYENiYENH>>'AP"I>>Y"D"OP:q"qDEGu
       3/4AYENI-a-oNOTM^1^3AE!C

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

2. |p|o"IYENI NanoBSD

  2.1. NanoBSD -a-o^3]p

   CUR@YEN^1+-NNOTM^1^3AE|sCURJ'OCURJ|!uwAAe!A'NYENiYENHYENIYEN|"OCURTH
   3/4E NanoBSD CURF!C
   ^1w^3]+-!-apCURU!AAH"-oD-.|^1-oCURANOTDEGCURT^3!CURA!G

     * "aONOTM^1^3AECURA^3IDEGI!G code#1 (c)M code#2!C

     * CUR@O^3](c)wAECURA^3IDEGI!A|b^1B|aeAo^1OCURCUR!A
       YENiYENH+-N"a:+- 3/4,u:(mount)"`i /cfg YENO/?yCURU!C

   ^3o"C,CURA^3IDEGI!A|b^1w^3]+-!-apCURUNOTOYENHDEGssAA-aCURe|!+-
   3/4,u:!C

   /etc (c)M /var YENO/?yS:!NOTDEG md(4)(malloc)-oI-oD-!C

   ^3](c)wAE-a-oCURA^3IDEGI<<hNOTO|b /cfg YENO/?y!C
   YEN|YEN]S:tCURFYENI(c)o /etc YENO/?y-a-oAE(R) *!A|b+-ODEGECURS:<<a
   1/4E(R)EYENHDEGssAA-aCURe|!+- 3/4,u:!C |]|^1!AY.Qn<<P:}
   3/4-:<<O-d.s-a-o^3](c)w!A "-o>>onDEGO+-o+-q /etc
   S:aS:i^1L-a-oAE(R) * 1/2AE>>s|^ /cfg YENO/?yCUR~|ae!C

   1/2d"O 1. S:a *S:i^1L /etc/resolv.conf ^3](c)w<<O|sDEG_"O

 # vi /etc/resolv.conf
 [...]
 # mount /cfg
 # cp /etc/resolv.conf /cfg
 # umount /cfg

     -a`: YENu|^3|b"t^2I+-ODEGE^1Lu{CURCUR!AYENHCURI>>Yn
     *S:i^3](c)wAE-a-o(R)EO!ACUR~>>Yn+- 3/4,u:S:t|^3 /cfg
     -a-o"-oOCURA^3IDEGI!C

     CUR@-a 1/2^3-L-+- 3/4,u: /cfg
     CUR-L-NOTOCUR@O|nYEND.N!A-SS:ONOTO.i+-zS:a NanoBSD (c)n|bCUR-L-
     3/4A|XP:i|aeCURjP:q 1/4gCURJDEGES:@-a-oCURA^3IDEGI(R)E
     (CURn|p!GYENN(c)oAE(R)
     *"t^2I-a-o|P"BCURAE.|(c)w'A|b"t^2I-oD-CUR-o 1/4gCURJ,e(R)AE)!C

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

  2.2. YEN'^3y NanoBSD NOTM^1^3AE

   NanoBSD NOTM^1^3AENOTO^3z^1L"IYENI<<D+-`A^2^3ae-a-o nanobsd.sh
   shell script "OYEN'^3y-a-o!A^3oO script YENiYENH|b
   /usr/src/tools/tools/nanobsd YENO/?yCURCURS:a:"`i!C ^3oO script
   <<O/YENss-a-oNOTM^1^3AE!AYENiYENHYENI dd(1) CURu"a"O
   1/2AE>>s"`iAH"-oD-CURW!C

   YEN'^3y NanoBSD NOTM^1^3AE(c)O>>Y-a-o<<u:YENONOTO!G

 # cd /usr/src/tools/tools/nanobsd (1)
 # sh nanobsd.sh (2)
 # cd /usr/obj/nanobsd.full (3)
 # dd if=_.disk.full of=/dev/da0 bs=64k (4)

   (1)
           P:iCURJ NanoBSD YEN'^3y script -a-oYENDYENO/?y!C
   (2)
           P:}(c)lYEN'^3y^1Lu{!C
   (3)
           P:iCURJYEN'^3y|n-a-oNOTM^1^3AE(c)O|b-a-oYENO/?y!C
   (4)
           |bAH"-oD-CURW|w,E NanoBSD!C

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

  2.3. |U|aeYEN'^3y NanoBSD NOTM^1^3AE

   ^3oYENi-`aNOTO NanoBSD ^3INOTDEG<<n!A |P(R)ECUR]NOTO+-z^3I.P?^3
   1/2`i-a-oYEN\-`a!C |P(R)E!A|bP:}uo NanoBSD
   A^3YENIu{|!(R)E!A^3oCUR]NOTONOTU.i-O(R)E-a-o^1Lu{!C

   DEGo|aeCURU+--a-o<<u:YENO+-N.| nanobsd.sh
   AA-a"uYENO/<<e(c)O|bYENO/?y-a-o myconf.nano AE-a-o^3](c)w!G

 # sh nanobsd.sh -c myconf.nano

   |U|aeYEN'^3y-a-oNOTyu{!AYENu>>Y"aO"BAEJ!G

     * |Uq?iP:u

     * |UqYEN\-`a

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

    2.3.1. |Uq?iP:u

   ^3z^1L *S:i^3](c)w!AYENiYENH^3](c)wYENI(c)o NanoBSD
   YEN'^3y^1Lu{CURCUR buildworld (c)M installworld P:YENNOTq-a-o
   1/2sA:P:!B|w,E?iP:u!AYENHCURI NanoBSD
   YENDnYEN'^3y^1Lu{CURCUR-a-o?iP:u!C
   ^3z^1L"IYENI^3o"C,?iP:uYENiYENH<<d'i"t^2I-a-oCURO/CURo!A"ICURS:-`aDEG-:(c)nCURJ
   64 MB -a-oAH"-oD-!C +-zAUYENiYENHP:iCUR@"B^3z^1L^3o"C,?iP:u"O<<d'i
   FreeBSD!A -a 1/2"`iYEN|YENuYEN]S:t kernel YENHCURI"aCURTO userland
   AE(R) *NOTDEGCURi!C

   ^3](c)wAE(R)
   *CURCURYEN]S:tYENIYENHYENN'A^1w^3]E-a-o^3](c)w?iP:u!CA^2CURP:^3I<<n-a-o'XP:u^3](c)w|pCURU!G

     * NANO_NAME !X!X
       YEN>>|,YEN'^3y-a-o|W-oU((c)O<<O/YENssCURuS:@YENO/?y-a-o|W-oU)!C

     * NANO_SRC !X!X YENIYENH 1/2sA:P:!BYEN'^3yNOTM^1^3AE-a-o source
       tree -a-o|`i,m!C

     * NANO_KERNEL !X!X ^3](c)wYENI"O 1/2sA:P:-a-o kernel
       ^3](c)wAEAE|W!C

     * CONF_BUILD !X!X YENI(c)o buildworld
       YEN'^3yP:YENNOTq-a-o?iP:u!C

     * CONF_INSTALL !X!X YENI(c)o installworld
       YEN'^3yP:YENNOTq-a-o?iP:u!C

     * CONF_WORLD !X!X YENI(c)o buildworld (c)M installworld
       ^3o"aOYEN'^3yP:YENNOTq-a-o?iP:u!C

     * FlashDevice !X!X (c)w,q(c)OYENI-a-o'OCURJ|!uwAAeAth<<NOT!C
       ,O+-! 1/2D-DEGN|O FlashDevice.sub AE!C

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

    2.3.2. |UqYEN\-`a

   ^3z^1L|b^3](c)wAE(R) *CURCUR"IYENI shell "c,
   1/4AE!AYENiYENHP:iCUR@"B.L 1/2O NanoBSD!C
   A|"O>>!(c)uCUR@CURU|U|aeYEN'^3y"c, 1/4AE-a-oDEGoYEN>>CURe|!!G

 cust_foo()(
         echo "bar=topless" > \
                 ${NANO_WORLDDIR}/etc/foo
 )
 customize_cmd cust_foo

   CURU+-A|S:o^1e>>UAI-a-o"OCURl!AYEN|.|S:a^1w^3]-a-o /etc
   YENO/?yCURjCURp!A+-q 5MB  1/2O 3/4aNOTDEG 30MB!G

 cust_etc_size()(
         cd ${NANO_WORLDDIR}/conf
         echo 30000 > default/etc/md_size
 )
 customize_cmd cust_etc_size

   DEG-L-|^1CURS:YEN~!AAU|^3'XO^1w^3]-a-oYEN\-`a(c)w,qYENiYENHYENI"O|Uq!G

     * cust_comconsole !X!X |b^1w^3] VGA AAaYENU:YENdCURWDEG+-YENI
       getty(8) (/dev/ttyv*)"A+-OYENI serial port -a-o COM1
       YENHS:@NOTDEG"t^2I console!C

     * cust_allow_ssh_root !X!X CUR^1^3\ sshd(8) YENiYENHYENI root
       +-b,^1unCURJ!C

     * cust_install_files !X!X +-q nanobsd/Files
       YENO/?yCURCUR|w,EAE(R)
       *!A^3oYEN]S:tCUR@"C,^1eYENI-a-o"t^2I-oTH^2z script !C

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

    2.3.3. ^3](c)wAE(R) *A|"O

   CURU+-NOTOYENI(c)o|U|aeYEN'^3y-a-o NanoBSD NOTM^1^3AE-a-oS:^1
   3/4a"OCURl!G

 NANO_NAME=custom
 NANO_SRC=/usr/src
 NANO_KERNEL=MYKERNEL
 NANO_IMAGES=2

 CONF_BUILD='
 NO_KLDLOAD=YES
 NO_NETGRAPH=YES
 NO_PAM=YES
 '

 CONF_INSTALL='
 NO_ACPI=YES
 NO_BLUETOOTH=YES
 NO_CVS=YES
 NO_FORTRAN=YES
 NO_HTML=YES
 NO_LPR=YES
 NO_MAN=YES
 NO_SENDMAIL=YES
 NO_SHAREDOCS=YES
 NO_EXAMPLES=YES
 NO_INSTALLLIB=YES
 NO_CALENDAR=YES
 NO_MISC=YES
 NO_SHARE=YES
 '

 CONF_WORLD='
 NO_BIND=YES
 NO_MODULES=YES
 NO_KERBEROS=YES
 NO_GAMES=YES
 NO_RESCUE=YES
 NO_LOCALES=YES
 NO_SYSCONS=YES
 NO_INFO=YES
 '

 FlashDevice SanDisk 1G

 cust_nobeastie()(
         touch ${NANO_WORLDDIR}/boot/loader.conf
         echo "beastie_disable=\"YES\"" >> ${NANO_WORLDDIR}/boot/loader.conf
 )

 customize_cmd cust_comconsole
 customize_cmd cust_install_files
 customize_cmd cust_allow_ssh_root
 customize_cmd cust_nobeastie

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

  2.4. S:o.s NanoBSD

   S:o.s NanoBSD NOTU^1i FreeBSD |O"YEN,uNOTDEGA^2^3ae!G

    1. (c)MCURS:<<eCUR@ 1/4EYEN'^3y.s-a-o NanoBSD NOTM^1^3AE!C

    2. +-N.s-a-oNOTM^1^3AE(c)nCURJYEN?^1B|ae-a-o NanoBSD CURCURYEN
       1/4YENI-a-oCURA^3IDEGICURS:CUR@!C

       >>PCURS:<<e^3I-a`i|w,E NanoBSD -a-o"BAEJNOTUCURn!A
       ^3oCUR@"BAEJ^3I<<n-a-oDEGIS:O|b(c)o!G^3o|,CUR-L-YENI
       _.disk.full AE(YEN|YEN]S:t 3/4aO-oI-oD--a-oNOTM^1^3AE)!A
       |OA^3|w,E _.disk.image NOTM^1^3AE(^3oOAE(R)
       *CURCUR!AYENuYEN]S:tCUR@O"t^2ICURA^3IDEGI)!C

    3. <<.s+-ODEGE!A"A+-q.s|w,E-a-oCURA^3IDEGICURCUR+-ODEGE"t^2I!C

    4. |p-aGCUR@CURAP:P:S:Q-a-o,U:!ACURE-AACURuS:@'NS:^1|"CURF!C

    5. |p-aGuoYENICURFYENo|oDEGYAD!A<<hYENiYENH+-qYENy<<e-a-oCURA^3IDEGI+-ODEGE
       ("a:CURCURYEN]S:tCURFAA-a-o!B
       YENiYENI-a-oNOTM^1^3AE)!A"O-oES:O:<<`i'_"t^2IYEN\-`a!C
       +-uCURU"OYENiYENH *YEN?.s
       1/2sA:P:-a-o-a(c)YEN>>CURCUR|s|b-a-oDEGYAD!A"A<<
       1/2AE<<ez"BAEJ!C

   n|bYEN?|b^1B|ae-a-o NanoBSD
   "t^2ICURCUR|w,E.s-a-oNOTM^1^3AE!AYENiYENH"IYENI|`i(c)o /root
   YENO/?y-a-o updatep1 (c)I updatep2 script !A
   ^1e>>UCURWnYENIthCUR@O
   script!A<<h"u"M(c)oYEN?|b^1B|ae-a-o"t^2INOTO|`i(c)othOCURA^3IDEGI|O(c)w!C

   AH(R)E'-L-"N.s NanoBSD NOTM^1^3AE(c)O'-L-"N-a-o-aADEGE!A
   YENHCURI+-A:YENI-a-oP:C,?eCURe-ak-a-oCUR-L-|P!A+-zYENiYENHDEGN|O"A"IYENICURU|CCURT-oO/CURe|!CURS:CUR@!G

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

    2.4.1. "IYENI ftp(1)

   |p-aGP:C,?e^3t<< *NOTO^2A:CUR@n"D-a-o,U:!A
   1/2D-+-A:YENICURU+-"OCURl!G

 # ftp myhost
 get _.disk.image "| sh updatep1"

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

    2.4.2. "IYENI ssh(1)

   |p-aG.QS:o|wYENth-a-o,U:!AA^3DEGN|OCURU+-"OCURl!G

 # ssh myhost cat _.disk.image.gz | zcat | sh updatep1

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

    2.4.3. "IYENI nc(1)

   |p-aG>>.u{YEND 3/4-:NOTJCUR-L-'-L-"N ftp(1)
   -aADEGE!ACUR]CUR-L-'-L-"N sshd(8) -aADEGE-a-o,U:!G

    1. -oYENy!A|b'-L-"NNOTM^1^3AE-a-oYEND 3/4-:CURWP:}+-O TCP
       listen!A"AAAyYEN|S:aNOTM^1^3AEP:C,u^1 client!G

 myhost# nc -l 2222 < _.disk.image

         -a`:  1/2D- 1/2T>>{+-z(c)O"IYENI-a-o port "S|^3^3Q"
         3/4CURoAd--ayCURi"O|U NanoBSD client -a-o^3s 1/2u 1/2D-"D!C

    2. ^3s"`i'-L-"N.sNOTM^1^3AE-aADEGE-a-oYEND 3/4-:!A"ADEGo|ae
       updatep1 ^3oCURa: script!G

 # nc myhost 2222 | sh updatep1

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

YEN>>CURaaCURI"a:YENLCURaaYENo!AYENiYENN|^1CURU,u:!Gftp://ftp.FreeBSD.org/pub/FreeBSD/doc/!C

        Y|^3 FreeBSD CURe+--oADEGY!A 1/2D-YENy 3/4\AA-a FreeBSD
         NOTUAo:CURaaYENo!A|pCUR-L--`a,N"M-a-o,U:!A|ANOT-c-,ss
                       <questions@FreeBSD.org>!C
  Ao:(c)oYEN>>CURaaYENo-a-oDEGYAD!A 1/2D-NOT-c-,ss <doc@FreeBSD.org>!C
