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

FreeBSD·ÖÇø֪ʶѧϰ¼°ÊµÑ鱸Íü¼

·¢²¼Ê±¼ä:2007-07-08 00:19:17À´Ô´:ºìÁª×÷Õß:skyAND
×÷Õß:¹Ë´äÎÄ
°æȨÉêÃ÷: ½öÏÞ·ÇÓ®ÀûÐÔ×éÖ¯ÍøÕ¾£¬BBS£¬ÒÔ¼°¸öÈ˲©¿ÍÊղأ¬ÓÃÓÚÆäËûÓÃ;ǰÇëÏȺÍ×÷ÕßÁªÏµ¡£
¹Ø¼ü×Ö£º freeBSD ·ÖÇø ·ÖÇø¹¤¾ß
½ñÌì¶ÔFreeBSDµÄÓ²ÅÌ·ÖÇøºÍ´æ´¢·½Ê½×÷ÁËÒ»×éʵÑé,ÏÖÔڼǼÏÂÀ´±¸°¸.
Ê×ÏÈ,ÓÉÓÚFreeBSDµÄ·ÖÇø·½Ê½ºÍLinuxÒÔ¼°windowsµÄ·ÖÇø·½Ê½Óкܴó²»Í¬,Òò´Ë·ÖÇøºÍ´ÅÅÌ´æ´¢Ïà¹ØµÄ¹¤¾ßµÄʹÓÃÒ²ÓкܴóµÄ²»Í¬ .ΪÁËÃèÊö·½±ã£¬ÎÒ½«FreeBSDÖеÄslice³Æ×÷Ö÷·ÖÇø£¬¶øsliceÖнøÒ»²½°üº¬µÄpartition³ÆΪÂß¼­·ÖÇø¡£
Ò»,»ù±¾¸ÅÄî.
ÔÚËùÓÐPCÌåϵ¼Ü¹¹ÉÏ°²×°µÄ²Ù×÷ϵͳ¶¼Ö»ÄÜ·ÖËĸö·ÖÇø.ÕâËĸö·ÖÇøÔÚ²»Í¬µÄ²Ù×÷ϵͳÖÐÓв»Í¬µÄ˵·¨,ÔÚwindowsºÍlinuxÖÐ,ͨ³£±»³ÆΪÖ÷·ÖÇø (primary partition),¶øÔÚBSD·ç¸ñµÄUNIXÒÔ¼°SolarisϵͳÖб»³ÆΪslice (Ó¢ÎÄÔ­ÒâΪСËéƬ,²»ÖªµÀÓÐûÓкõķ­ÒëÀ´±íÊö).sliceºÍÖ÷·ÖÇøÊÇͬһ¸ö¸ÅÄî,ÔÚPCÉÏÄÜ°²×°µÄ²Ù×÷ϵͳ¶¼Äܸù¾ÝMBRÖеķÖÇø±íÈϳöÕâÑùµÄÖ÷·ÖÇø. ÔÚwindowsºÍlinuxÖÐ,Ò»¸öÓ²ÅÌ¿ÉÒÔ·ÖËĸöÖ÷·ÖÇø,ÆäÖÐÒ»¸ö¿É×÷ΪÀ©Õ¹·ÖÇø,ÔÙÔÚÀ©Õ¹·ÖÇøÖл®·ÖÂß¼­·ÖÇø,¶øÆäËûÈý¸öÖ÷·ÖÇøÔòÖ»ÄÜ×÷Ϊ×îСµÄ·ÖÇøµ¥Î»ÁË.¾ÍÊÇ˵,Ö»ÄÜÑ¡ÔñÒ»¸öÀ©Õ¹·ÖÇø,È»ºóÔÙÔÚÀ©Õ¹·ÖÇøÖл®·ÖÂß¼­·ÖÇø.À©Õ¹·ÖÇøÖаüº¬µÄÂß¼­·ÖÇøÊýÄ¿¿ÉÒÔÓкܶà¸ö,²éÁË×ÊÁÏ,Ò»ÖÖ˵·¨ÊÇ×î¶à64 ¸ö,»¹Ã»ÓоßÌåÑéÖ¤¹ý,²»¹ý·´ÕýÕâ¸öÊýÄ¿±È½Ï´ó,¿É°ÑÓ²ÅÌ·ÖµÃ×㹻ϸ.
¶øFreeBSD,Ôò¿ÉÒÔÔÚÿ¸ösliceÖÐÔÙ»®·Ö¸üСµÄ·ÖÇøµ¥Î»,ÔÚFreeBSDÖÐÓ²Å̵ÄsliceÖÐ,ÕâÖÖ¸üСµÄ·ÖÇøµ¥Î»±»³ÆΪ partition,Æä¸ÅÄîºÍwindowsºÍlinuxÖеÄÂß¼­·ÖÇøµÄ¸ÅÄîÀàËÆ.ÕâÖÖ¸üСµÄ·ÖÇøµ¥Î»ÓÃСд×Öĸa-h±íʾ,¹²ÓÐ8¸ö,µ«ÊÇÆäÖÐc·ÖÇøÓÐÌØÊ⺬Òå,c·ÖÇø±íʾ¸Ã·ÖÇøËùÔÚµÄÕû¸öslice(Ö÷·ÖÇø).¾ÍÏ൱ÓÚÔÚsolarisÖÐ/dev/dsk/c0t0d0c2·ÖÇøÒ»Ñù,ÔÚsparcÌåϵµÄsolarisϵͳÖÐc0t0d0c2±íʾµÄÊÇÕû¸ö´ÅÅÌ,ÒòΪsolarisÖÐûÓÐÆäËû±íʾÕû¸ö´ÅÅ̵ÄÉ豸Ãû³Æ. ´Ó¸ÅÄîÉϽ²FreeBSDÖеÄ/dev/ad0s1c µÈͬÓÚ /dev/ad0s1
Òò´Ë,ÔÚFreeBSDÖÐ,Ò»¸öÓ²ÅÌ×î¶à¿É»®·Ö(8-1)x4 = 28 ¸ö·ÖÇø.Ô­ÏÈÀϵÄFreeBSDϵͳÖÐ,Âß¼­·ÖÇødÒ²ÓÐÌØÊâÓÃ;,¾ÍÊÇ˵,ÔÚÀÏ°æ±¾µÄFreeBSDϵͳÖÐ,ÿ¸öÓ²ÅÌ×î¶àÄÜ·Ö(8-2)X4 = 24 ¸ö·ÖÇø,µ«ÊÇÏÖÔÚÕâ¸öd·ÖÇøµÄÌØÊâÓÃ;ҲÒѾ­µ­»¯ÁË,ËäÈ»ÓÃsysinstall»®·ÖÂß¼­·ÖÇøµÄʱºòsysinstall»á¾¡Á¿±Ü¿ªÊ¹ÓÃd·ÖÇø,µ«ÊǽñÌì¾­¹ýʵÑéÑéÖ¤,d·ÖÇø±êʶҲ¿ÉÒÔ×÷Ϊһ¸öÆÕͨµÄÊý¾Ý´æ´¢·ÖÇø±êʶ. Òò´Ë,ÒÔIDEÓ²ÅÌΪÀýÔÚfreebsdÖеÚÒ»¿éÓ²ÅÌÕý³£Çé¿öÏ¿ÉÓõķÖÇøÉ豸ºÅΪ:
/dev/ad0s1a /dev/ad0s2a /dev/ad0s3a /dev/ad0s4a
/dev/ad0s1b /dev/ad0s2b /dev/ad0s3b /dev/ad0s4b
/dev/ad0s1d /dev/ad0s2d /dev/ad0s3d /dev/ad0s4d
/dev/ad0s1e /dev/ad0s2e /dev/ad0s3e /dev/ad0s4e
/dev/ad0s1f /dev/ad0s2f /dev/ad0s3f /dev/ad0s4f
/dev/ad0s1g /dev/ad0s2g /dev/ad0s3g /dev/ad0s4g
/dev/ad0s1h /dev/ad0s2h /dev/ad0s3h /dev/ad0s4h
¶þ, FreeBSDÏ·ÖÇø¹¤¾ßµÄʹÓÃ.
ÔÚFreeBSDÏÂ×î·½±ãµÄ·ÖÇø·½·¨ÊÇʹÓÃsysinstallÌṩµÄ²Ëµ¥Ñ¡Ïî,¸ù¾ÝÌáʾÀ´Íê³É·ÖÖ÷·ÖÇø(slice)ºÍ·ÖÂß¼­·ÖÇø(partiton)µÄ»®·Ö¹¤×÷. Õâ¸ö·½·¨±È½Ï¼òµ¥,ºÜÈÝÒ×ѧ»á.
½ñÌìÖ÷ҪѧϰÁËÒ»ÏÂÃüÁîÐй¤¾ßfdisk ºÍ disklabel(ÓÖÃûbsdlabel)µÄʹÓÃ.
Ê×ÏÈ,fdiskÊÇÓÃÀ´»®·ÖÖ÷·ÖÇøµÄ,Ò²¾ÍÊÇÓÃÀ´»®·Öslice,ÕâÒ»µãºÍlinuxϵͳÓкܴóµÄ²»Í¬ .
Ò»°ãµÄʹÓ÷½·¨:
dd if=/dev/zero of=/dev/ad0 bs=1k count=1 #Ä¿µÄÊÇÏÈÇå³ýÓ²ÅÌÉÏÔ­ÓеķÖÇø±í,ÐÂÓ²ÅÌ¿ÉÌø¹ýÕâ²½.
fdisk -BI /dev/ad0 #ÔÚÓ²ÅÌ/dev/ad0ÉÏ´´½¨Ò»¸öÖ÷·ÖÇø(slice).
¿´ÁËÒ»ÏÂfdiskµÄmanÎĵµ,²ÎÊýB±íʾÔÚÓ²Å̵ÄMBRÖÐдÈëÒ»¸ö±ê×¼Òýµ¼¼Ç¼,IÑ¡Ïî±íʾ½«Õû¸öÓ²ÅÌ»®·Ö³öÒ»¸öslice.Ò²¾ÍÊÇ˵,ÃüÁîÐеķÖÇø¹¤¾ßfdiskÖ»ÄÜÔÚÒ»¸öÓ²ÅÌÉÏ»®·Ö³öÒ»¸öÖ÷·ÖÇø,Ó¦¸Ãͨ¹ý-f²ÎÊý¼ÓÅäÖÃÎļþ¿ÉÒÔ¶¨Òå²¢»®·Ö³öËĸöÖ÷·ÖÇø,µ«ÊǹâÓÃfdiskÌṩµÄ²ÎÊý,ºÃÏñÖ»ÄÜ»®·Ö³öÒ»¸öÀ´.ÕâÒ»µãÉÏÀ´Ëµ,FreeBSDµÄÃüÁîÐзÖÇø¹¤¾ß×öµÃ»¹²»¹»ÈËÐÔ»¯,»¹ÊÇÓÃsysinstallÌṩµÄ½çÃæÀ´·ÖÇø¸ü·½±ã.
disklabel/bsdlabelµÄʹÓÃ:
disklabel -B -w /dev/ad0s1 auto
disklabel -e /dev/ad0s1
²é¿´ÁËbsdlabelµÄmanÎĵµ,²ÎÊýB±íʾÔÚ¸ÃÖ÷·ÖÇøÖÐдÈëÒýµ¼³ÌÐò.°´ÕÕhandbookÖйØÓÚFreeBSDÒýµ¼¹ý³ÌµÄÃèÊö,fdisk µÄ B²ÎÊýÊDZíʾÔÚÓ²Å̵ÄMBRÖÐдÈëboot0(512×Ö½Ú),¶øbsdlabelÖеÄB²ÎÊýÔò±íʾÔÚ¸ÃÖ÷·ÖÇøÖÐдÈë¸ÃÖ÷·ÖÇøµÄÒýµ¼¼Ç¼(²¢·ÇÖ÷Òýµ¼¼Ç¼),¼´boot1(512×Ö½Ú,дÔÚÖ÷·ÖÇøµÄµÚÒ»¸öÉÈÇø)ºÍboot2(´ó¸Å8K×óÓÒ,дÔÚ·ÖÇøµÄij¸öÌض¨ÇøÓò,²¢·ÇÎļþϵͳÖÐ). ²ÎÊýw¼´write,±íʾдÈë,´ËÍ⻹¿ÉÓÃr²ÎÊý¶ÁÈ¡.
[auto]±íʾÔÚ¸ÃÖ÷·ÖÇøÖÐ×Ô¶¯»®·Ö³öÒ»¸öÂß¼­·ÖÇø,ÓеãÀàËÆÓÚfdiskÖеÄI²ÎÊý.Èç¹û²»¼Óauto²ÎÊý,ÔòÓÃ
disklabel -e /dev/ad0s1À´·ÖÇø»®·Ö³öÂß¼­·ÖÇøµÄʱºò,disklabel»á×Ô¶¯´ò¿ªÒ»¸ö±à¼­Æ÷,ÈÃÄãÊÖ¹¤ÊäÈëÂß¼­·ÖÇø´óС,Æ«ÒÆÁ¿µÈÐÅÏ¢,È»ºó±£´æºó¸ü¾ÝÄã±à¼­µÄÐÅÏ¢À´»®·Ö³öÂß¼­·ÖÇø.ÊÖ¹¤±àдÂß¼­·ÖÇøµÄÐÅÏ¢ÐèÒª¶ÔÓ²Å̵Ä֪ʶ±È½ÏÁ˽â,µ«ÊǺô¦ÊÇ¿ÉÒÔºÜ×ÔÓɵݲÅÅÂß¼­·ÖÇøµÄÆðʼλÖᢴóСÒÔ¼°·ÖÇøÃû³ÆµÈÐÅÏ¢,¶øÇÒ¿ÉÒÔ¸ü¾ÝFreeBSDµÄ¹æÔò×î¶à»¯³ö7¸ö¿ÉÓ÷ÖÇøºÍÒ»¸öÌØÊâµÄc·ÖÇø.¶øÓÃauto²ÎÊý×Ö×Ô¶¯»®·Ö³öÒ»¸öÂß¼­·ÖÇøµÄºÃ´¦ÊDz»ÐèÒª¶ÔÓ²ÅÌÓбȽÏÉîÈëµÄÁ˽á,»µ´¦ÊÇÖ»ÄÜ·ÖÒ»¸ö¿ÉÓõÄÂß¼­·ÖÇø.
disklabel -e /dev/ad0s1 ÃüÁîÓÃÀ´ÔÚ¸ÃÖ÷·ÖÇø(slice)ÖÐдÈë¸ÃÂß¼­·ÖÇøµÄÆðʼλÖõÈÐÅÏ¢.
Ö´ÐÐÍêÕâÌõÃüÁîºó,ÔÚ/dev/Ŀ¼Ï¾ͻá×Ô¶¯Éú³ÉÉ豸Îļþ ad0s1a ºÍad0s1c ,Èç¹ûÊÇÊÖ¹¤±à¼­Âß¼­·ÖÇøÐÅÏ¢Éú³É¶à¸ö·ÖÇøµÄ»°,/devÏ»áÓжÔÓ¦µÄÉ豸ÎļþÉú³É,ÓÃnewfs´´½¨Îļþϵͳºó¾Í¿ÉÒÔÓøÃÂß¼­·ÖÇøÁË.
ÒÔÉÏÃüÁîÔÚhandbookÖÐÓÐÃèÊö,µ«ÊÇûÓÐÕâôÏêϸµÄ˵Ã÷,½ñÌì¸ù¾ÝʵÑéºÍmanÎĵµ,ÒÔ¼°×Ô¼ºµÄÀí½â,дÏÂÕâЩ±¸Íü¼Ç¼,ÒÔÉÏÀí½âÓ¦¸ÃÊÇÕýÈ·µÄ.
×ÛÉÏËùÊöfdisk¹¤¾ßÊÇÓÃÀ´»®·ÖÖ÷·ÖÇø(slice)µÄ,ËûµÄ²Ù×÷¶ÔÏóÊÇÓ²Å̵ĵÚÒ»¸öÉÈÇø(MBR),ÔÚMBRÖÐдÈë±ê×¼Òýµ¼³ÌÐò(boot0),ÒÔ¼°Ö÷·ÖÇøµÄ·ÖÇøÐÅÏ¢. ¶ødisklabel/bsdlabelÊÇÓÃÀ´ÔÚÖ÷·ÖÇøÖл®·ÖÂß¼­·ÖÇøµÄ,ËûµÄ²Ù×÷¶ÔÏóÊÇÓ²ÅÌÖÐÖ÷·ÖÇøµÄµÚÒ»¸öÉÈÇø,ÒÔ¼°Ò»Ð©ÌØÊâÇøÓò,ÓÃÀ´Ð´ÈëÒýµ¼³ÌÐòµÄµÚ¶þ¡¢µÚÈý²½(boot1ºÍboot2)ÒÔ¼°Î»ÓÚ¸ÃÖ÷·ÖÇøÖеÄÂß¼­·ÖÇøµÄ·ÖÇøÐÅÏ¢ÒÔ¼°±êʶºÅ.
Ò»°ãÇé¿öÏÂ,ÓÃfdiskºÍdisklabel/bsdlabel½øÐзÖÇø²»Ì«·½±ãÒ²²»Ö±¹Û,sysinstallÓ¦¸ÃÊÇÒ»¸ö¿ìËÙÖ±¹ÛµÄÑ¡Ôñ.
ͨ¹ýÔĶÁÏà¹ØÎĵµºÍʵÑéÒÔ¼°ºÍÆäËû²Ù×÷ϵͳµÄ·ÖÇø·½Ê½ºÍ¸ÅÄîµÄ¶Ô±È,¶ÔFreeBSDµÄ·ÖÇø¸ÅÄîºÍ·ÖÇø¹¤¾ßµÄʹÓÃÓÐÁ˱ȽÏÇåÎúµÄÁ˽â .
Èý,Ò»×éÓÐȤµÄʵÑé
ÔÚʵÑéµÄ¹ý³ÌÖÐ,·¢ÏÖÒ»¸öÓÐȤµÄÏÖÏ󣬼´:
ÔÚFreeBSDÖÐÎÞÂÛÊÇÕû¸öÓ²ÅÌ/dev/ad0
Õû¸öÖ÷·ÖÇø/dev/ad0s1
»¹ÊÇÖ÷·ÖÇøÖеÄÂß¼­·ÖÇø /dev/ad0s1a
¶¼¿ÉÒÔÓÃnewfsÖ±½Ó´´½¨ÎļþϵͳȻºó¹Òµ½Ä³¸öĿ¼ÏÂʹÓÃ.
Ê×ÏÈ,ÎÒ¶ÔÒ»¸öûÓÐÈκηÖÇøµÄÓ²ÅÌ×öÈçϲÙ×÷:
newfs /dev/ad0
mount /dev/ad0 /mnt
·¢ÏÖûÓÐÈκδíÎóºÍ¾¯¸æÐÅÏ¢,¸ÃÓ²ÅÌûÓзÖÇø¾ÍÖ±½Ó¿ÉÒÔÓÃÁË,ʵ¼Ê²âÊÔÁËÒ»ÏÂ,ҲȷʵÕýÈ·.
È»ºó¶ÔÓ²ÅÌ»®·ÖÁËËĸöÖ÷·ÖÇø,ÔÙ·Ö±ðÔÚËĸöÖ÷·ÖÇøÉÏ´´½¨Îļþϵͳ:
newfs /dev/ad0s1
newfs /dev/ad0s2
newfs /dev/ad0s3
newfs /dev/ad0s4
mount /dev/ad0s1 /mnt/1
mount /dev/ad0s2 /mnt/2
mount /dev/ad0s3 /mnt/3
mount /dev/ad0s4 /mnt/4
ͬÑùûÓÐÈκδíÎóºÍ¾¯¸æ,ÕâЩÖ÷·ÖÇøÔÚûÓнøÒ»²½»®·ÖÂß¼­·ÖÇøµÄÇé¿öÏÂÒ²¿ÉÖ±½Ó´´½¨ÎļþϵͳºóʹÓÃ.
×îºó,ÔÙÔÚËĸöÖ÷·ÖÇøÖзֱ𻮷ֳö¼¸¸öÂß¼­·ÖÇø,´´½¨Îļþϵͳºóµ±È»Ò²ÄÜʹÓÃ,ÕâÊÇFreeBSDÖÐĬÈϵÄÓ²ÅÌʹÓ÷½Ê½.
ÎÒÉõÖÁ¶Ô´ú±íÕû¸öÖ÷·ÖÇøµÄcºÅÂß¼­·ÖÇøÉÏ´´½¨Îļþϵͳ:
newfs /dev/ad0s1c
mount /dev/ad0s1c /mnt ÕâÑùÒ²ÄÜʹÓÃ,µ±È» Èç¹û»®·ÖÁËÆäËûÂß¼­·ÖÇøµÄÇé¿öÏÂ,ÕâÖÖÓ÷¨»áÆÆ»µÆäËûÂß¼­·ÖÇø,ÕâÖÖÓ÷¨ºÍ:
newfs /dev/ad0s1
mount /dev/ad0s1 /mnt Ó¦¸ÃÊÇÒ»ÖµÄ.
ͨ¹ýʵÑéµÃ³ö½áÂÛ:ÔÚFreeBSDÖÐ,Ó²Å̲»ÐèÒª·ÖÇø,¿ÉÖ±½Ó´´½¨Îļþϵͳ¶øʹÓøÃÓ²ÅÌ.
´´½¨·ÖÇøµÄºÃ´¦,ÊÇ¿ÉÒÔºÍÆäËû²Ù×÷ϵͳ¹²´æÒ»¸öÓ²ÅÌÉÏ.
ÔÚFreeBSDϵͳÉÏ×öÍêÉÏÊöʵÑéºó,±¾ÈËÓÖÏëµ½linuxÉÏÊÇ·ñÒ²¿ÉÒÔ²»»®·Ö·ÖÇø¶øÖ±½ÓʹÓÃÕû¸öÓ²ÅÌÄØ?
Á¢¼´×öÁËÒ»ÏÂʵÑé,֤ʵÁËÎÒµÄÏë·¨ÊÇÕýÈ·µÄ,Ö»²»¹ýlinuxµÄ´´½¨ÎļþϵͳÃüÁîmkfs.ext3»á·¢³ö¾¯¸æ,Ö»Òª»Ø´ðyes¾Í¿ÉÒÔÖ±½ÓÔÚÒ»¸öûÓзÖÇøµÄÓ²ÅÌÉÏ´´½¨Îļþϵͳ²¢mountµ½ÏµÍ³ÖÐʹÓÃÁË.
ÃüÁîÈçÏÂ:
mkfs.ext3 /dev/sdb
mke2fs 1.32 (09-NOv-2002)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
mount /dev/sdb /mnt
ÒÔÉÏʵÑé˵Ã÷,ÔÚ²Ù×÷ϵͳÖÐ,Ó²ÅÌ·ÖÇø²¢·Ç±ØÐèµÄ,·ÖÇøÊÇΪÁ˸üºÃµÄ¹ÜÀíÎļþºÍÓëÆäËûϵͳ¹²´æ¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ