ÆÊÎöLinuxÖ÷Ö¸µ¼¼Í¼£¨MBR£©µÄ¹¦Ð§ºÍÊÂÇéÔÀí
ÎÊÌ⣺Linux MBRµÄ×÷Óü°ÔÀíÆÊÎö
ÔÚÅÌËã»úÁìÓò£¬MBR£¨Master Boot Record£©ÊÇÒ»¸öºÜÊÇÖ÷ÒªµÄ¿´·¨£¬ÌØÊâÊǹØÓÚʹÓÃLinux²Ù×÷ϵͳµÄÓû§¶øÑÔ¡£MBRͨ³£´æ´¢ÔÚ´ÅÅ̵ĵÚÒ»¸öÉÈÇø£¬Ëü°üÀ¨ÁËÖ¸µ¼¼ÓÔسÌÐòºÍ·ÖÇø±íµÈÖ÷ÒªÐÅÏ¢£¬ÕâЩÐÅÏ¢¾öÒéÁËÅÌËã»úÔõÑùÆô¶¯ºÍ¼ÓÔزÙ×÷ϵͳ¡£±¾ÎĽ«ÏêϸÆÊÎöLinux MBRµÄ×÷Óü°ÔÀí£¬²¢ÌṩÏêϸµÄ´úÂëʾÀýÒÔ×ÊÖú¶ÁÕ߸üºÃµØÃ÷È·¡£
MBRµÄ×÷ÓÃ
MBRµÄÖ÷Òª×÷ÓÃÊÇÔÚÅÌËã»úÆô¶¯Ê±¼ÓÔØÖ¸µ¼¼ÓÔسÌÐò£¨Boot Loader£©£¬Ö¸µ¼¼ÓÔسÌÐòÔÙÈÏÕæ¼ÓÔزÙ×÷ϵͳÄںˡ£µ±ÅÌËã»úÆô¶¯Ê±£¬BIOS»á¶ÁÈ¡´ÅÅ̵ĵÚÒ»¸öÉÈÇø£¨Ò²¾ÍÊÇMBR£©µ½ÄÚ´æÖУ¬È»ºóÖ´ÐÐÆäÖеÄÖ¸µ¼¼ÓÔسÌÐò¡£Ö¸µ¼¼ÓÔسÌÐò»áƾ֤MBRÖеķÖÇø±íÐÅÏ¢ÕÒµ½²Ù×÷ϵͳËùÔڵķÖÇø£¬²¢¶ÁÈ¡²Ù×÷ϵͳÄں˵½ÄÚ´æÖÐÖ´ÐС£Òò´Ë£¬¿ÉÒÔ˵MBRÊÇÅÌËã»úÆô¶¯µÄµÚÒ»²½£¬Æðµ½ÁËÒªº¦µÄ×÷Óá£
MBRµÄ½á¹¹
MBRµÄ½á¹¹ºÜÊǼòÆÓ£¬×ܹ²Õ¼ÓÃ512×ֽڵĿռ䣬¿ÉÒÔ·ÖΪÈý¸ö²¿·Ö£º
Ö¸µ¼´úÂëÇø£ºÕ¼ÓÐÁËMBRµÄÇ°446×Ö½Ú£¬´æ·Å×ÅÖ¸µ¼¼ÓÔسÌÐòµÄ´úÂë¡£Õâ¶Î´úÂëÈÏÕæ¼ÓÔزÙ×÷ϵͳÄں˲¢Æô¶¯ÏµÍ³¡£
·ÖÇø±í£ºÕ¼ÓÐÁËMBRµÄ½ÓÏÂÀ´64×Ö½Ú£¬ÓÃÀ´¼Í¼´ÅÅÌ·ÖÇøµÄÐÅÏ¢£¬°üÀ¨Ã¿¸ö·ÖÇøµÄÆðʼλÖᢾÞϸµÈ¡£
¿¢Ê±ê¼Ç£ºÕ¼ÓÐÁËMBRµÄ×îºóÁ½¸ö×Ö½Ú£¬ÓÃÀ´±êʶMBRµÄ×îºó¡£
Linux MBRµÄÔÀíÆÊÎö
¹ØÓÚLinuxϵͳ¶øÑÔ£¬MBRµÄ½á¹¹ÓëÆäËûϵͳ²¢Ã»ÓÐÌ«´óÇø±ð¡£LinuxµÄÖ¸µ¼¼ÓÔسÌÐòͨ³£ÎªGRUB£¨GRand Unified Bootloader£©£¬Ëü»á±»Ð´ÈëMBRÖУ¬²¢Æ¾Ö¤·ÖÇø±íÐÅÏ¢¼ÓÔØLinuxÄںˡ£GRUB»¹Ö§³Ö¶à²Ù×÷ϵͳµÄÖ¸µ¼£¬Óû§¿ÉÒÔÔÚÆô¶¯Ê±Ñ¡Ôñ²î±ðµÄ²Ù×÷ϵͳ¾ÙÐÐÖ¸µ¼¡£
ÏÂÃæ¸ø³öÒ»¸ö¼òÆӵĴúÂëʾÀýÀ´ËµÃ÷ÔõÑù±àдһ¸ö¼òÆÓµÄMBRÖ¸µ¼¼ÓÔسÌÐò¡£ÒÔÏ´úÂëʹÓûã±àÓïÑÔ±àд£¬¼ÙÉèÎÒÃÇÒª±àдһ¸ö¼òÆÓµÄÖ¸µ¼¼ÓÔسÌÐò£¬Ëü»á´òÓ¡Ò»ÌõÐÅÏ¢²¢ÓÀÊÀÍ£ÁôÔÚÄÇÀï¡£
section .text global _start _start: mov ah, 0x0E ; ÉèÖôòÓ¡×Ö·û´®µÄ¹¦Ð§ºÅ mov al, 'H' ; ´òÓ¡×Ö·û'H' int 0x10 ; ŲÓÃBIOSµÄÊÓƵЧÀÍ mov al, 'e' ; ´òÓ¡×Ö·û'e' int 0x10 mov al, 'l' ; ´òÓ¡×Ö·û'l' int 0x10 mov al, 'l' ; ´òÓ¡×Ö·û'l' int 0x10 mov al, 'o' ; ´òÓ¡×Ö·û'o' int 0x10 jmp $ ; ÎÞÏÞÑ»·Í£ÁôÔÚÕâÀï times 510 - ($ - _start) db 0 ; Ìî³äÊ£Óà¿Õ¼äΪ0£¬Ê¹´úÂ볤¶ÈµÖ´ï512×Ö½Ú dw 0xAA55 ; MBR×îºó±ê¼Ç
µÇ¼ºó¸´ÖÆ
ͨ¹ýÒÔÉÏ´úÂëʾÀý£¬ÎÒÃÇ¿ÉÒÔ¿´µ½Ò»¸ö¼òÆÓµÄMBRÖ¸µ¼¼ÓÔسÌÐòÊÇÔõÑùÊÂÇéµÄ£¬ËüʹÓÃBIOSÌṩµÄÊÓƵЧÀÍ´òÓ¡×Ö·û£¬²¢ÔÚ×îºóÌí¼ÓMBRµÄ×îºó±ê¼Ç¡£µ±ÅÌËã»úÆô¶¯Ê±£¬Õâ¶Î´úÂë»á±»Ö´ÐУ¬ÊµÏÖ¼òÆÓµÄÖ¸µ¼¹¦Ð§¡£
×ÛÉÏËùÊö£¬Linux MBR×÷ΪÅÌËã»úÆô¶¯µÄÒªº¦²¿·Ö£¬ÔÚ²Ù×÷ϵͳÆô¶¯Àú³ÌÖÐÊ©Õ¹×ÅÖ÷Òª×÷Óá£Í¨¹ýÉîÈëÏàʶMBRµÄ½á¹¹ºÍÔÀí£¬ÎÒÃÇ¿ÉÒÔ¸üºÃµØÃ÷È·ÅÌËã»úÆô¶¯µÄÀú³Ì£¬²¢ÔÚÐëҪʱ¾ÙÐе÷ÊÔºÍÐÞ¸´¡£Ï£Íû±¾ÎÄÄÜ×ÊÖú¶ÁÕ߸üºÃµØÃ÷È·Linux MBRµÄ×÷Óü°ÔÀí¡£
ÒÔÉϾÍÊÇÆÊÎöLinuxÖ÷Ö¸µ¼¼Í¼£¨MBR£©µÄ¹¦Ð§ºÍÊÂÇéÔÀíµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡