ºìÁªLinuxÃÅ»§
Linux°ïÖú

ÖÆ×÷RAMDISK in KERNELµÄOpenBSD΢ϵͳ

·¢²¼Ê±¼ä:2007-06-26 00:12:20À´Ô´:ºìÁª×÷Õß:Dcsaqois
ÔÚÒÔÇ°ÎÒÃÇÒѾ­½²¹ýÈçºÎÖÆ×÷ÈíÅÌÉÏÔËÐеÄFreeBSDϵͳ£¬ÏÖÔÚÎÒÃÇÀ´¿´¿´ÈçºÎÖÆ×÷Ò»¸öÔËÐÐÔÚÈíÅÌÉϵÄOpenBSDϵͳ¡£ÓëÈíÅÌÉ쵀 FreeBSD²»Í¬µÄÊÇ£¬Õâ´ÎÎÒÃǽ«ÏµÍ³ÖеÄËùÓÐÅäÖÆÎļþ¼°³ÌÐòÈ«²¿´æ·Åµ½OpenBSDµÄÄÚºËÖУ¬ÕâÑùÕû¸öϵͳ¿´ÆðÀ´¾ÍÊÇÒ»¸öÎļþ¡£ÏÂÃæÈÃÎÒÃǾßÌåÀ´¿´¿´ÈçºÎÍê³ÉÕâÑùÒ»¸ö΢ϵͳµÄÖÆ×÷¡£
0¡¢OpenBSDµÄÆô¶¯¹ý³Ì
µ±Ó²ÅÌMBRÖеÄÒýµ¼³ÌÐò½Ó¹ýÆô¶¯Ö®ºó£¬MBRÖеijÌÐò½«¶ÁÈëÓ²ÅÌOpenBSD·ÖÇøÖеÄÒýµ¼³ÌÐò£¬Òýµ¼³ÌÐòĬÈÏÇé¿öÏ»á¼ÓÔØ/boot£¬È»ºóÓÉ bootÔØÈëÄںˣ¬´ËʱÄں˿ªÊ¼¼ì²âһЩӲ¼þºÍ×öһЩ³õʼ»¯¡£³õʼ»¯Íê³Éºókernel½«mount root device£¬È»ºóÆô¶¯ÏµÍ³³õʼ»¯½ø³Ì/sbin/init£¬init½«¸ù¾Ý/etc/rcÖеÄÉèÖÃÀ´½øÐгõʼ»¯µÈ¡£
1¡¢¶¨ÖÆRAMDISKÄÚºË
ҪʹÓÃRAMDISK in KERNEL¾Í±ØÐëÔÚÄÚºËÅäÖÆÎļþÖмÓÈëÒÔÏÂÑ¡Ï
option RAMDISK_HOOKS
option MINIROOTSIZE=3560
pseudo-device rd 1
ÒÔÉϵÄÄں˲ÎÊýÒâÒåÈçÏ£º
option RAMDISK_HOOKS£º¿ªÆôramdisk in kernelµÄ¹¦ÄÜ¡£
option MINIROOTSIZE=xxx£ºÉèÖÃÄÚºËÖÐramdiskµÄ´óС£¬ÒÔ512bΪµ¥Î»£¨¾Ý˵×î´óÖ»ÄÜΪ23000 £©
pseudo-device rd 1£ºÔÚÄÚºËÖвúÉú1¸öramdiskÉ豸¡£
2¡¢ÖÆ×÷ramdisk¾µÏñ
# dd if=/dev/zero of=/ramdisk bs=512 count=3560
# vnconfig -c svnd0 /ramdisk
# disklabel -r -w svnd0 rdroot
# newfs -m 0 -S 512 -i 4096 /dev/svnd0a
# mount /dev/svnd0a /mnt
# mkdir /mnt/{dev,bin,sbin,etc}
# cp /dev/MAKEDEV /mnt/dev
# cp /bin/{sh,ls} /mnt/bin
# cp /sbin/init /mnt/sbin
# cd /mnt/dev/ && ./MAKEDEV ramdisk
# echo 'echo "This is my minibsd all in kernel" && /bin/sh' > /mnt/etc/rc
# sync && umount /mnt
# sync && vnconfig -u svnd0 && sync
3¡¢½«ramdiskдÈëkernel
# cc -o rdsetroot /usr/src/distrib/common/elfrdsetroot.c
# ./rdsetroot /minibsd < ramdisk
4¡¢Ñ¹Ëõkernel´óС
# gzip -9 -c /minibsd > /minibsd.gz
5¡¢ÖÆ×÷Ä¿±êÈíÅÌ
ÒòΪϵͳÐèҪʹÓÃ/boot£¨/usr/mdec/boot£©À´¼ÓÔØkernel£¬ËùÒÔÎÒÃÇÐèÒªÔÚÈíÅÌÉÏ·ÅÖÃbootÎļþ¡£
# disklabel -B -w -r /dev/fd0a fd1440
# newfs -m 0 -S 512 /dev/fd0a
# mount /dev/fd0a /mnt
# cp /usr/mdec/boot /mnt
# cp /minibsd.gz /mnt/bsd
ÏÖÔÚÄãµÄramdisk in kernelµÄminiopenbsdϵͳ¾ÍÒѾ­×öºÃÁË¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ