²âÊÔƽ̨£ºFreeBSD 4.5 Release (i386)
Ç°ÑÔ
1¡¢FreeBSDµÄÆô¶¯¹ý³Ì¼ò½é
µ±BIOS¶ÁÈëMBRÖ®ºó£¬MBRÖеijÌÐò¶ÁÈëÓ²ÅÌFreeBSD Slice£¨FreeBSD·ÖÇø£©ÖеÄÒýµ¼³ÌÐò£¬Òýµ¼³ÌÐòĬÈÏÇé¿öÏ»á¼ÓÔØ/boot/loader£¬È»ºóloader½«¼ÓÔØ/kernel£¬´Ëʱkernel¿ªÊ¼¼ì²âһЩӲ¼þºÍ×öһЩ³õʼ»¯¡£³õʼ»¯Íê³Éºókernel½«mount root device£¬È»ºóÆô¶¯ÏµÍ³³õʼ»¯½ø³Ì/sbin/init£¬init½«¸ù¾Ý/etc/rcÖеÄÉèÖÃÀ´½øÐгõʼ»¯µÈ¡£
¿ÉÒÔ¿´³öÎÒÃÇÐèÒª½â¾öµÄ²¿·Ö¾ÍÊÇ£ºÒýµ¼³ÌÐò ->; /boot/loader ->; /kernel ->; /sbin/init ->; /etc/rc
ÔÚÁ˽âÁËÆô¶¯¹ý³ÌÖ®ºóºÍÎÊÌâËùÔÚÖ®ºó£¬ÎÒÃDZã¿ÉÒÔ¿ªÊ¼ÖÆ×÷ÈíÅÌÉϵÄFreeBSDÁË¡£
2¡¢³õʼ»¯ÈíÅÌ
Ê×ÏÈÒª×öµÄ¾ÍÊÇÒª½«ÈíÅ̳õʼ»¯£¬°üÀ¨ÉèÖÃdisklabelºÍ´´½¨Îļþϵͳ£¨¸ñʽ»¯³Éufs¸ñʽ£©¡£
bsd# disklabel -r -w fd0a fd1440
½ÓÏÂÀ´ÊÇ°²×°Òýµ¼³ÌÐò¡£
bsd# disklabel -B fd0a
ÏÖÔÚÈíÅÌÒѾÄܹ»Òýµ¼ÁË£¬µ«ÒòΪÎÒÃÇÒªÔÚËüÉÏÃæ·ÅÖóÌÐò£¬ËùÒÔÒª´´½¨Îļþϵͳ¡£
bsd# newfs fd0a
¸Õ²ÅÒѾ×öºÃÁËÒýµ¼³ÌÐò£¬ÒòΪÒýµ¼³ÌÐò»á¼ÓÔØ/boot/loader£¬ËùÒÔÎÒÃÇ»¹ÐèÒª½«ÏµÍ³ÖеÄ/boot/loader¸´ÖƵ½ÈíÅÌÖС£
bsd# mkdir /fd
bsd# mount /dev/fd0a /fd
bsd# mkdir /fd/boot
bsd# cp /boot/loader /fd/boot/loader
¸ù¾ÝFreeBSDµÄÆô¶¯¹ý³Ì£¬ÏÖÔÚÎÒÃÇÒѾ׼±¸ºÃÁËÒýµ¼³ÌÐòºÍloader£¬½ÓÏÂÀ´¾ÍҪ׼±¸ÄÚºËÁË¡£
3¡¢¶¨ÖÆÄÚºË
ÈíÅ̵ĿռäÓÐÏÞ£¬ËùÒÔÎÒÃÇÐèÒª¶¨ÖÆÒ»¸öСÄںˣ¬¶ø²»ÄÜÖ±½ÓʹÓÃϵͳÔÀ´µÄÄںˡ£
ÓÉÓÚÎÒÃÇֻʹÓÃÈíÅÌ£¬ËùÒÔÄÚºËÖеĹØÓÚscsi¡¢ata¡¢atapiºÍraidµÈÕâЩ¶«Î÷¶¼Ó¦¸Ãɾ³ý£¬ÒòΪÎÒÃDz»ÐèÒªIPv6ËùÒÔINET6Ò²Ó¦¸Ãɾ³ý£¬¾ßÌåÁôÏÂЩʲôҪ¿´×Ô¼ºµÄÓÃ;ÁË£¬ÕâûÓÐʲô±ê×¼¡£²»¹ýÓм¸ÑùÊDZØÐëµÄ£º
options MFS # ÄÚ´æÎļþϵͳ֧³Ö
options MD_ROOT # ʹÓÃMD(ÄÚ´æ´ÅÅÌ)É豸×öroot
options UFS # UFSÎļþϵͳ֧³Ö
options UFS_ROOT # UFS ROOT
pseudo-device md # MDÉ豸֧³Ö
ÏÂÃæÊÇÎÒʹÓõÄÒ»¸öÄÚºËÅäÖÆÎļþ£º
#
# GENERIC -- Generic kernel configuration file for FreeBSD/i386
#
#
# $FreeBSD: src/sys/i386/conf/GENERIC,v 1.246.2.38 2002/01/25 17:41:40 murray Exp $
machine i386
cpu I386_CPU
cpu I486_CPU
cpu I586_CPU
cpu I686_CPU
ident "MINI-KERNEL"
maxusers 0 #maxusers×îºÃÈÃϵͳ×Ô¶¯·ÖÅ䣬Èç¹ûÉèµÃ¹ý´ó£¬»áÕ¼Óùý¶àµÄÄÚ´æ¡£
options INET #InterNETworking
options FFS #Berkeley Fast Filesystem
options FFS_ROOT #FFS usable as root device [keep this!]
options MFS #Memory Filesystem
options MD_ROOT #MD is a potential root device
options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
options NO_SWAPPING #Disable swap
device isa
device pci
# Floppy drives
device fdc0 at isa? port IO_FD1 irq 6 drq 2
device fd0 at fdc0 drive 0
# atkbdc0 controls both the keyboard and the PS/2 mouse
device atkbdc0 at isa? port IO_KBD
device atkbd0 at atkbdc? irq 1 flags 0x1
device vga0 at isa?
# syscons is the default console driver, resembling an SCO console
device sc0 at isa? flags 0x100
# Floating point support - do not disable.
device npx0 at nexus? port IO_NPX irq 13
# PCI Ethernet NICs that use the common MII bus controller code.
# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs!
device miibus # MII bus support
device fxp # Intel EtherExpress PRO/100B (82557, 82558)
device rl # RealTek 8129/8139
device xl # 3Com 3c90x
device lnc0 at isa? port 0x280 irq 10 drq 0 # VMware Nic
# Pseudo devices - the number indicates how many units to allocate.
pseudo-device loop # Network loopback
pseudo-device ether # Ethernet support
pseudo-device md # Memory "disks"
ÉÏÃæµÄÄں˻ù±¾ÉÏÊÇÒ»¸öϵͳҪÔËÐеÄ×îСÅäÖÆÁË£¬µ±È»Èç¹ûÄãµÄ»úÆ÷²»Í¬¾ßÌåÒ²²»Í¬£¬´ó¼Ò°´×Ô¼ºµÄÇé¿öÀ´¶¨£¬ÎҵĻúÆ÷ÅäÖÆÊÇ£º
CPU: Pentium III 733Mhz
MotherBoard: Via 693A Chipset
NIC: Realtek 8139c
µ±ÅäÖƺÃÖ®ºó¾ÍÊDZàÒëÄÚºËÁË£¬½¨Òé´ó¼ÒʹÓÃconfigµÄ·½Ê½À´±àÒ룬עÒ⣬×îºó²»ÒªÊ¹ÓÃmake install£¬·ñÔòÄãÔÀ´µÄÄں˻ᱻÌæ»»¡£
bsd# cd /sys/i386/conf
bsd# config MINI
bsd# cd ../../compile/MINI
bsd# make depend && make kernel
±àÒëÍê³Éºó¾Í»á³ÉÉúkernelÕâ¸öÎļþ£¬ÕâʱËüµÄÌå»ý»¹ÊDZȽϴ󣬲»¹ýÏÖÔÚ²»ÓùÜËü£¬ºóÃ潫»á½éÉÜÈçºÎ´¦ÀíËü¡£
4¡¢±àÒëϵͳ³ÌÐò
ÏÖÔÚ¾ÍҪ׼±¸ÏµÍ³ËùÐèÒªµÄ»ù±¾³ÌÐòÁË£¬Ê×ÏÈ×î»ù±¾µÄÊÇinitºÍsh£¬initÊÇËùÓнø³ÌµÄ¸¸½ø³Ì£¬Ëü¸ºÔð½øÐÐһЩ³õʼ»¯¹¤×÷£¬Ëü½«ÊÇkernelÒýµ¼Íê³ÉºóÒªÔËÐеĵÚÒ»¸öÓû§½ø³Ì£¬¶øshÓÃÓÚ½âÊÍ/etc/rcÖеÄÃüÁî¡£
ÎÒÃÇ¿ÉÒÔ·¢ÏÖ£¬´ó²¿·ÖʱºòÒ»¸ö³ÌÐòÖ»ÊÇÓõ½ÁË¿âÖеÄij¸öº¯Êý£¬µ«Í¬ÑùÒ²Òª¼ÓÔØÕû¸ö¿â£¬ËùÒÔÎÒÃÇ¿ÉÒÔʹÓþ²Ì¬±àÒëÀ´Ê¹³ÌÐòÖ»°üº¬ËüʹÓõÄÄDz¿·Öº¯Êý£¬ÕâÑù¿ÉÒÔ¼õÉÙ³ÌÐòµÄ´óС¡£
²»¹ýÕâÑùÎÊÌâͬÑù´æÔÚ£¬Èç¹ûÖ»ÓÐÉÙÊý³ÌÐòÕ⵽ûÓÐʲô£¬Ò»µ©³ÌÐòºÜ¶àʱ£¬ÄÇô¿Õ¼äÎÊÌâͬÑù´æÔÚ¡£Èç¹û»áCÓïÑÔµÄÅóÓѶ¼ÖªµÀ£¬Æäʵÿһ¸ö³ÌÐòÖÐÓкܴóÒ»²¿·Öº¯ÊýÊÇÏàͬµÄ£¬±ÈÈçprintf£¬Õâ¸öº¯ÊýÔڴ󲿷ֳÌÐòÖж¼»áÓõ½£¬Èç¹ûÿ¸ö³ÌÐò¶¼°üº¬Ò»¶ÎprintfµÄ´úÂ룬ÄÇôÈç¹ûÓÐ100¸ö³ÌÐòµÄ»°£¬¾Í»á°üº¬100¸öÕâÑùµÄ´úÂ룬Ȼ¶øÕâЩ´úÂ붼ÊÇÏàͬµÄ£¬Êµ¼ÊÉÏÓÐ99¸ö¶¼ÊÇÀË·ÑÁ˿ռ䣬ÄÇô¿É²»¿ÉÒÔÈÃһЩ³ÌÐòÔÚ¾²Ì¬±àÒëµÄÇé¿öÏÂÒ²Äܹ»¹²ÏíһЩº¯ÊýÄØ£¿ÒªÖªµÀ´ð°¸£¬ÍùϽÓ×Å¿´¡£
ÐҺã¬PICOBSDΪÎÒÃÇÌṩÁËÕâÑùµÄÒ»¸ö»úÖÆ£¬Ê¹µÃ³ÌÐò¼´²»ÓüÓÔرê×¼¿âÒ²¿ÉÒÔÀûÓÃÆäËü³ÌÐòÖеÄÏàͬº¯Êý£¬Õâ¾ÍÊÇcrunch£¨crunchºÃÏñÊÇÊÀ½ç¶¥¼¶ºÚ¿Í¸ßÊÖJohn DraperµÄÍøÃû£¬²»ÖªµÀÕâÓëËûÓÐûÓйØϵ¡£^_^£©¡£
#
# NOTE: the string "/usr/src" will be automatically replaced with the
# correct value set in 'build' script - you should change it there
# Default build options
buildopts -DNOPAM -DRELEASE_CRUNCH -DNOSECURE -DNOCRYPT -DNONETGRAPH -DNOIPSEC
# other sources
srcdirs /usr/src/bin
srcdirs /usr/src/sbin/i386
srcdirs /usr/src/sbin
srcdirs /usr/src/usr.bin
srcdirs /usr/src/usr.sbin
srcdirs /usr/src/gnu/usr.bin
srcdirs /usr/src/gnu/usr.sbin
srcdirs /usr/src/libexec
# sources for ns & vm
srcdirs /usr/src/release/picobsd/tinyware
# ÒÔÏÂΪÄãËùÐèÒªÔÚcrunch°üº¬µÄ³ÌÐòÁÐ±í£¬ÒÔ¿Õ¸ñ·Ö¸ô¡£
progs dmesg ping ifconfig route hostname
progs cp rm ls cat test mkdir less
progs uname sysctl
progs init sh reboot
# lnÊDZíʾ½¨Á¢Ò»¸ö±ðÃû£¬Èçln less more£¬±íʾµ±Ö´ÐÐmoreµÄʱºòʵ¼ÊÉÏÊÇÖ´ÐÐless
ln less more
# ÒÔÏÂÊÇÖ¸¶¨±àÒëʱÐèÒªµÄ¿â
libs -lncurses -lmytinfo -lipx
libs -lz -lpcap -lalias
libs -ledit -lutil -lmd -lcrypt -lmp -lgmp -lm -lkvm
libs -lgnuregex -ltelnet
bsd# make
Õâʱ»áÉú³ÉÒ»¸öÃûΪcrunch1µÄ³ÌÐò£¬ÎÒÃÇÒªµÄ¾ÍÊÇËüÁË¡£
5¡¢½¨Á¢ÄÚ´æ´ÅÅÌ
´ó¼Ò¿ÉÒÔ¿´µ½crunch1¼ÓÉÏÎÒÃǸղűàÒëµÄÄں˺Íloader³ÌÐò£¬ÒѾ³¬³öÁËÈíÅ̵ÄÈÝÁ¿£¬Í¬Ê±ÎªÁ˼ÓËÙ³ÌÐòµÄÔËÐÐÎÒÃÇÐèҪʹÓÃMD£¨ÄÚ´æ´ÅÅÌ£©À´½â¾öÕâ¸öÎÊÌ⣬MD½«×÷ΪϵͳµÄ¸ùÎļþϵͳºÍÓÃÀ´´æ·Åϵͳ³ÌÐò¡£¶ÔÓÚÄÚ´æ´ÅÅ̵ĴóСһ°ã²»Ò×Ì«´ó£¬ÒòΪÕâÑù»áÕ¼Óùý¶àµÄÄڴ棬ÏÂÃæÎÒÃǾÍÒÔ½¨Á¢Ò»¸ö3MµÄÄÚ´æ´ÅÅÌΪÀý˵Ã÷ÈçºÎ½¨Á¢ÄÚ´æ´ÅÅÌ£º
bsd# cd /root
bsd# dd if=/dev/zero of=bsd bs=1k count=3072 # Éú³ÉÒ»¸ö3MµÄÎļþ£¬ÓÃÀ´×öMD
bsd# vnconfig -c -s labels vn0c bsd # ʹÓÃbsdÀ´´´½¨Ò»¸övnÉèÖã¬ÒÔ±ãÔÚÆäÖдæ·Å³ÌÐò
bsd# disklabel -w -r vn0c auto # ½¨Á¢disklabel
bsd# disklabel -B vn0c # °²×°Æô¶¯´úÂë
bsd# newfs vn0c # ´´½¨UFSÎļþϵͳ
bsd# mount /dev/vn0c /mnt # ½«vn0c¼´bsd mountµ½/mnt
½ÓÏÂÀ´Òª×öµÄ¾ÍÊǽ¨Á¢Ä¿Â¼½á¹¹£¬¾ßÌ彨Á¢ÄÄЩĿ¼ÕâÒªÊÓÐèÒª¾ö¶¨£¬±¾ÀýÖÐÐèÒª½¨Á¢ÈçÏÂĿ¼£º
bsd# mkdir /mnt/etc
bsd# mkdir /mnt/sbin
bsd# mkdir /mnt/bin
bsd# mkdir /mnt/dev
È»ºó½«crunch1¸´ÖƵ½/mnt/sbinÖУ¬ÔÙ½«¸Õ²Å±àÒë½øcrunch1ÖеÄÄÇЩÃüÁî·Ö±ð×öÉÏsymbol link£º
bsd# cp /usr/src/release/picobsd/custom/crunch1/crunch1 /mnt/sbin
bsd# cd /mnt/sbin
bsd# ln -s ./crunch1 init # init±ØÐëÔÚ/mnt/sbinĿ¼ÖÐ
bsd# ln -s ./crunch1 reboot
bsd# ln -s ./crunch1 sysctl
bsd# ln -s ./crunch1 ifconfig
bsd# ln -s ./crunch1 route
bsd# ln -s ./crunch1 ping
bsd# ln -s ./crunch1 dmesg
bsd# cd /mnt/bin
bsd# ln -s ../sbin/crunch1 sh # sh±ØÐëÔÚ/mnt/binĿ¼ÖÐ
bsd# ln -s ../sbin/crunch1 hostname
bsd# ln -s ../sbin/crunch1 cp
bsd# ln -s ../sbin/crunch1 rm
bsd# ln -s ../sbin/crunch1 ls
bsd# ln -s ../sbin/crunch1 cat
bsd# ln -s ../sbin/crunch1 test
bsd# ln -s ../sbin/crunch1 mkdir
bsd# ln -s ../sbin/crunch1 less
bsd# ln -s ../sbin/crunch1 uname
bsd# ln -s ../sbin/crunch1 more
6¡¢±àдÆô¶¯½Å±¾
ÒòΪÎÒÃǵÄϵͳֻÊÇΪÁ˲âÊÔÔÚÈíÅÌÉÏÔËÐÐFreeBSD£¬Òò¶øÕâÀïµÄÆô¶¯½Å±¾·Ç³£¼òµ¥Ö»ÊÇÈÃϵͳ¿ÉÒÔ¹¤×÷£¬Ã»ÓÐ×öÆäËüµÄ¹¤×÷£¬ÆäÄÚÈÝÈçÏ£º
#!/bin/sh
# Floppy BSD init script
PATH=/sbin:/bin
HOME=/
export PATH HOME
echo
echo "Hello, it's my Floppy BSD"
echo
# ÒòΪûÓÐʹÓõǼÑéÖ¤£¬ËùÒÔÕâÀïÖ»ÊǼòµ¥µÄÒ»Ö±ÔËÐÐshell
while : ; do
/bin/sh
done
7¡¢½¨Á¢É豸Îļþ
ÏÖÔÚÐèÒª½¨Á¢Ò»Ð©»ù±¾µÄÉ豸Îļþ£¬ÎÒÃÇʹÓÃ/dev/MAKEDEVÀ´Íê³ÉÕâЩ²Ù×÷£º
bsd# cd /mnt/dev
bsd# cp /dev/MAKEDEV .
bsd#./MAKEDEV std # ½¨Á¢±ê×¼É豸
bsd# rm MAKEDEV
8¡¢×îºó¹¤×÷
µ½Ä¿Ç°ÎªÖ¹£¬ÎÒÃǵÄÆô¶¯²¿·Ö£¬KernelºÍÄÚ´æ´ÅÅ̶¼ÒѾ׼±¸ºÃÁË£¬ÏÂÃæ¾Í¿ªÊ¼ÕûºÏËüÃÇÁË¡£
ÒòΪloaderÖ§³ÖÖ±½Ó¼ÓÔØgzipѹËõ¸ñʽµÄÎļþ£¬ÕâΪÎÒÃǽÚÔ¼´Å¿ÕÌṩÁË·½±ã£¬Í¬Ê±Ò²½â¾öÁËÎÒÃǿռ䲻¹»µÄÎÊÌ⣬ÏÖÔÚѹËõkernelºÍÄÚ´æ´ÅÅÌbsd£º
bsd# cd /root
bsd# cp /sys/compile/MINI/kernel .
bsd# gzip -9 kernel # ʹÓÃ×î´óѹËõÂÊ£¬½«Éú³ÉÎļþkernel.gz
bsd# umount /mnt
bsd# gzip -9 bsd # ʹÓÃ×î´óѹËõÂÊ£¬½«Éú³ÉÎļþbsd.gz
È»ºó±à¼loaderµÄÅäÖÆÎļþ£º
bsd# cd /fd/boot
bsd# vi loader.rc
ÊäÈ룺
load kernel
load -t mfs_root bsd # ±íʾ½«bsd.gzÒÔmdµÄ·½Ê½¼ÓÔØ£¬²¢ÇÒ³ÉΪroot device
´æÅÌÍ˳ö£¬½«kernel.gzºÍbsd.gz¸´ÖƵ½ÈíÅÌÖУº
bsd# cd /root
bsd# cp kernel.gz /fd
bsd# cp bsd.gz /fd
bsd# umount /fd
ÏÖÔÚÓÃÄãµÄÕâÕÅÈíÅ̾ͿÉÒÔÆô¶¯ÄãµÄ»úÆ÷£¬Èç¹ûÒ»ÇÐÕý³£µÄ»°£¬Ä㽫¿´µ½"Hello, it's my Floppy BSD"µÄÌáʾ£¬²¢ÇÒ¿´µ½¿É°®µÄshell·û"#"ÁË£¬ÊDz»ÊǺÜÓÐÂú×ã¸ÐÄØ£¿:)
µ½´ËΪֹһ¸ö»ù±¾µÄBSDϵͳÒѾÍê³ÉÁË£¬Èç¹ûÄãÏë¼ÌÐøÀ©Õ¹Floppy BSDµÄ¹¦ÄÜ£¬ÄǾͰ´ÕÕÉÏÃæµÄ·½·¨×Ô¼º×ö°É£¡