{"id":119,"date":"2013-06-08T18:29:02","date_gmt":"2013-06-08T10:29:02","guid":{"rendered":"http:\/\/www.datarelab.com\/blog\/?p=119"},"modified":"2013-06-08T18:29:02","modified_gmt":"2013-06-08T10:29:02","slug":"grub2%20--%20grub.cfg%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.datarelab.com\/blog\/Technical_literature\/119.html","title":{"rendered":"Grub2 -- grub.cfg\u8be6\u89e3"},"content":{"rendered":"<p>grub.cfg \u9ed8\u8ba4\u4e3a\u53ea\u8bfb\uff0c\u8981\u4fee\u6539\u524d\u5148\u8bbe\u4e3a\u53ef\u5199<br \/>\nsudo chmod +w \/boot\/grub\/grub.cfg<br \/>\nset default=0<br \/>\n#\u9ed8\u8ba4\u4e3a0<br \/>\ninsmod jpeg<br \/>\n#\u6dfb\u52a0jpg\u652f\u6301\uff0c\u5982\u8981\u4f7f\u7528png\u6216tga\u6587\u4ef6\u505a\u80cc\u666f\uff0c\u52a0\u4e0a insmod png\u6216insmod tga<br \/>\ninsmod ext2<br \/>\n#\u9664\u4e86\u7528\u4f5c\u542f\u52a8\u7684\u5206\u533a\u5916\uff0c\u5176\u4ed6\u5206\u533a\u683c\u5f0f\u53ef\u5728menu\u5e95\u4e0b\u518d\u6dfb\u52a0<br \/>\nset root=(hd0,7)<br \/>\n#\u8bbe\u5b9aroot\u5206\u533a<br \/>\nsearch --no-floppy --fs-uuid --set f255285a-5ad4-4eb8-93f5-4f767190d3b3<br \/>\n#\u8bbe\u5b9auuid=****\u7684\u5206\u533a\u4e3aroot\uff0c\u548c\u4e0a\u53e5\u91cd\u590d\uff0c\u53ef\u5220\u9664<br \/>\n# \u4ee5\u4e0b\u4e3a\u7ec8\u7aef\u914d\u7f6e<br \/>\nif loadfont \/usr\/share\/grub\/unicode.pf2 ; then<br \/>\n#\u8bbe\u7f6e\u7ec8\u7aef\u5b57\u4f53\uff0cunicode.pf2\u652f\u6301\u4e2d\u6587\u663e\u793a<br \/>\nset gfxmode=640x480<br \/>\n#\u8bbe\u7f6e\u5206\u8fa8\u7387\uff0c\u9ed8\u8ba4\u4e3a 640x480\uff0c\u53ef\u7528800x600\uff0c1024x768\uff0c\u5efa\u8bae\u8ddf\u4f60\u60f3\u8bbe\u5b9a\u7684\u56fe\u7247\u5927\u5c0f\u4e00\u81f4<br \/>\ninsmod gfxterm<br \/>\n#\u63d2\u5165\u6a21\u5757 gfxterm\uff0c\u652f\u6301\u4e2d\u6587\u663e \u793a\uff0c\u5b83\u8fd8\u652f\u6301 24 \u4f4d\u56fe\u50cf<br \/>\ninsmod vbe<br \/>\n#\u63d2\u5165 vbe \u6a21\u5757\uff0cGRUB 2 \u5f15\u5165\u5f88\u591a\u6a21\u5757\u7684\u4e1c\u897f\uff0c\u8981\u4f7f\u7528\u5b83\uff0c\u9700\u8981\u5728\u8fd9\u91cc\u52a0\u5165<br \/>\nif terminal_output gfxterm ; then true ; else<br \/>\n# For backward compatibility with versions of terminal.mod that don't<br \/>\n# understand terminal_output<br \/>\nterminal gfxterm<br \/>\n#\u8bbe\u7f6e GRUB 2 \u7ec8\u7aef\u4e3a gfxterm<br \/>\nfi<br \/>\nfi<br \/>\nset timeout=10<br \/>\nbackground_image (hd0,7)\/boot\/images\/1.jpg<br \/>\n#\u8bbe\u7f6e\u80cc\u666f\u56fe\u7247<br \/>\n### END \/etc\/grub.d\/00_header ###<br \/>\n### BEGIN \/etc\/grub.d\/05_debian_theme ###<br \/>\nset menu_color_normal=white\/black<br \/>\nset menu_color_highlight=cyan\/black<br \/>\n#\u8fd9\u4e24\u884c\u4e3a Debian \u4e0b\u7684\u83dc\u5355\u989c\u8272\u8bbe\u7f6e\uff0c\u5982\u679c\u9ed8\u8ba4\u7684\u8bdd\uff0c\u4f60\u4f1a\u53d1\u73b0\u80cc\u666f\u5b8c\u5168\u88ab\u84dd\u8272\u6321\u4f4f\u4e86\uff0c\u4f60\u9700\u8981\u4fee\u6539 blue \u4e3a black\uff0c\u8fd9\u6837\u80cc\u666f\u5c31\u4f1a\u51fa\u73b0<br \/>\n### END \/etc\/grub.d\/05_debian_theme ###<br \/>\n# 10_linux \u4e3a\u81ea\u52a8\u6dfb\u52a0\u7684\u5f53\u524droot\u5206\u533alinux\u5f15\u5bfc\u9879<br \/>\n### BEGIN \/etc\/grub.d\/10_linux ###<br \/>\n#\u83dc\u5355\u9879\uff0c\u8981\u5305\u62ec menuentry \u53cc\u5f15\u53f7\" \" \u548c\u5927\u62ec\u53f7 { }\u624d\u5b8c\u6574\uff0c\u5426\u5219\u4e0d\u663e\u793a\u83dc\u5355<br \/>\nmenuentry \"Ubuntu, Linux 2.6.31-9-386\" {<br \/>\ninsmod ext2<br \/>\nset root=(hd0,7)<br \/>\nsearch --no-floppy --fs-uuid --set f255285a-5ad4-4eb8-93f5-4f767190d3b3<br \/>\n#\u8fd9\u53e5\u4e0eset root=(hd0,7)\u91cd\u590d\uff0c\u53ef\u5220\u9664<br \/>\nlinux \/boot\/vmlinuz-2.6.31-9-386 root=UUID=f255285a-5ad4-4eb8-93f5-4f767190d3b3 ro quite splash<br \/>\n#\u4e0d\u559c\u6b22\u770b\u5230\u4e00\u957f\u4e32\u7684\uff0c roo=UUID=***\u53ef\u7528root=\/dev\/sda7\u4ee3\u66ff<br \/>\ninitrd \/boot\/initrd.img-2.6.31-9-386<br \/>\n}<br \/>\n### END \/etc\/grub.d\/10_linux ###<br \/>\n### BEGIN \/etc\/grub.d\/20_memtest86+ ###<br \/>\nmenuentry \"Memory test (memtest86+)\" {<br \/>\nlinux16 \/boot\/memtest86+.bin<br \/>\n}<br \/>\n### END \/etc\/grub.d\/20_memtest86+ ###<br \/>\n# \u81ea\u52a8\u6dfb\u52a0\u5b58\u5728\u4e8e\u5176\u4ed6\u5206\u533a\u7684\u7cfb\u7edf\u5f15\u5bfc\u9879<br \/>\n### BEGIN \/etc\/grub.d\/30_os-prober ###<br \/>\n#windows \u542f\u52a8\u83dc\u5355<br \/>\nmenuentry \"Windows Vista (loader) (on \/dev\/sda1)\" {<br \/>\ninsmod ntfs<br \/>\n#windows\u683c\u5f0f\u4e3antfs\uff0c\u6216\u4e3afat32\u6539\u4e3a insmod fat<br \/>\nset root=(hd0,1)<br \/>\nsearch --no-floppy --fs-uuid --set ece067d2e067a196<br \/>\n#\u53ef\u5220\u9664<br \/>\n#grub2\u6bd4\u8f83\u5148\u8fdb\u7684\u5730\u65b9\u5c31\u662f\u5982\u679c\u53d1\u73b0windows\u542f\u52a8\u662f\u901a\u8fc7ntldr \u5f15\u5bfc\u7684\uff0c\u5b9a\u4e3a2000\/xp\/2003\uff0c\u4f1a\u5728\u8fd9\u52a0\u4e0a drivemap -s (hd0) ${root} \uff0c\u4f5c\u7528\u76f8\u5f53\u4e8egrub\u7684map\uff0c\u53ef\u6b63\u5e38\u542f\u52a8\u975e\u7b2c\u4e00\u786c\u76d8\u7684xp\/2003\u7cfb\u7edf\u3002<br \/>\nchainloader +1<br \/>\n}<br \/>\n# \u67e5\u627e\u5230\u5176\u4ed6\u5206\u533a\u4e0a\u7684linux\u7cfb\u7edf\u5e76\u81ea\u52a8\u6dfb\u52a0<br \/>\nmenuentry \"Ubuntu karmic (development branch) (9.10) (on \/dev\/sda3)\" {<br \/>\ninsmod ext2<br \/>\nset root=(hd0,3)<br \/>\nsearch --no-floppy --fs-uuid --set 4d893970-0685-44ed-86b3-1de45b2db84a<br \/>\nlinux \/boot\/vmlinuz-2.6.31-9-generic root=\/dev\/sda3<br \/>\ninitrd \/boot\/initrd.img-2.6.31-9-generic<br \/>\n}<br \/>\n#\u82e5\u5b58\u5728macos\u4f1a\u81ea\u52a8\u5728\u8fd9\u91cc\u6dfb\u52a0\u3002<br \/>\n### END \/etc\/grub.d\/30_os-prober ###<br \/>\n# \u4ee5\u4e0b\u4e3a\u624b\u52a8\u6dfb\u52a0\u7684\u83dc\u5355\u9879<br \/>\n### BEGIN \/etc\/grub.d\/40_custom ###<br \/>\nmenuentry \"CDLinux\"{<br \/>\nset root=(hd0,8)<br \/>\nlinux \/CDlinux\/bzImage root=\/dev\/ram0 vga=791 CDL_LANG=zh_CN.UTF-8<br \/>\ninitrd \/CDlinux\/initrd<br \/>\n}<br \/>\n### END \/etc\/grub.d\/40_custom ###<br \/>\n# \u624b\u52a8\u6dfb\u52a0\u65f6\uff0c\u786c\u76d8\u7f16\u53f7\u4ece0\u5f00\u59cb(hd0)\uff0c\u4e3b\u5206\u533a\u7f16\u53f7\u4ece1\u5f00\u59cb(hd0,1)\uff0c\u903b\u8f91\u5206\u533a\u4ece5\u5f00\u59cb(hd0,5)<br \/>\n\u4e8c\u3001grub2\u7ec8\u7aef\u90e8\u5206\u547d\u4ee4\u4ecb\u7ecd<br \/>\n\u5728\u51fa\u73b0\u9009\u62e9\u83dc\u5355\u65f6\uff0c\u6309C\u8fdb\u5165\u7ec8\u7aef\u547d\u4ee4\u884c\u6a21\u5f0f\uff0c\u6309E\u8fdb\u5165\u5f53\u524d\u83dc\u5355\u9879\u7f16\u8f91\u6a21\u5f0f\uff08\u548cgrub\u4e00\u6837\uff09\uff0c\u7f16\u8f91\u4e2d\u6309Ctrl + C\u9000\u51fa\uff0c\u6309Ctrl + X \u4ee5\u7f16\u8f91\u5185\u5bb9\u542f\u52a8\u3002<br \/>\n1. help<br \/>\n\u67e5\u770b\u547d\u4ee4\u7528\u6cd5\uff0c\u663e\u793a\u6240\u6709\u53ef\u7528\u547d\u4ee4<br \/>\nhelp search<br \/>\nsearch \u547d\u4ee4\u7528\u6cd5<br \/>\n2. ls<br \/>\n\u5217\u51fa\u5f53\u524d\u7684\u6240\u6709\u8bbe\u5907\u3002\u5982 (hd0) (hd0,1) (hd0,5) (hd1) (hd1,1) (hd1,2) .......<br \/>\nls -l<br \/>\n\u8be6\u7ec6\u5217\u51fa\u5f53\u524d\u7684\u6240\u6709\u8bbe\u5907\u3002\u5bf9\u4e8e\u5206\u533a\uff0c\u4f1a\u663e\u793a\u5176label\u53cauuid\u3002<br \/>\nls \/<br \/>\n\u5217\u51fa\u5f53\u524d\u8bbe\u4e3aroot\u7684\u5206\u533a\u4e0b\u7684\u6587\u4ef6<br \/>\nls (hd1,1)\/<br \/>\n\u5217\u51fa(hd1,1)\u5206\u533a\u4e0b\u6587\u4ef6<br \/>\n3. search<br \/>\nsearch -f \/ntldr<br \/>\n\u5217\u51fa\u6839\u76ee\u5f55\u91cc\u5305\u542bntldr\u6587\u4ef6\u7684\u5206\u533a\uff0c\u8fd4\u56de\u4e3a\u5206\u533a\u53f7<br \/>\nsearch -l LINUX<br \/>\n\u641c\u7d22label\u662fLINUX\u7684\u5206\u533a\u3002<br \/>\nsearch --set -f \/ntldr<br \/>\n\u641c\u7d22\u6839\u76ee\u5f55\u5305\u542bntldr\u6587\u4ef6\u7684\u5206\u533a\u5e76\u8bbe\u4e3aroot\uff0c\u6ce8\u610f\u5982\u679c\u591a\u5916\u5206\u533a\u542b\u6709ntldr\u6587\u4ef6\uff0cset \u5931\u53bb\u4f5c\u7528\u3002<br \/>\n4. loopback<br \/>\nloopback\u547d\u4ee4\u53ef\u7528\u4e8e\u5efa\u7acb\u56de\u653e\u8bbe\u5907\uff0c\u5982<br \/>\nloopback lo0 (hd1,1)\/abc.iso<br \/>\n\u53ef\u4ee5\u4f7f\u7528lo0\u8bbe\u5907\u6765\u8bbf\u95eeabc.iso\u91cc\u7684\u5185\u5bb9\uff0c\u6bd4\u5982\u8bf4\uff0c\u53ef\u4ee5\u4eceabc.iso\u91cc\u7684\u8f6f\u76d8\u6620\u50cf\u4e2d\u542f\u52a8<br \/>\nloopback lo0 (hd1,1)\/aa.iso<br \/>\nlinux (lo0)\/memdisk<br \/>\ninitrd (lo0)\/abc.img<br \/>\n\u8981\u5220\u9664\u67d0\u4e00\u56de\u653e\u8bbe\u5907\uff0c\u53ef\u4ee5\u4f7f\u7528-d\u53c2\u6570\uff1a<br \/>\nloopback -d lo0<br \/>\n5. set<br \/>\n\u4f7f\u7528set\u53ef\u4ee5\u8bbe\u7f6e\u53d8\u91cf\u7684\u503c<br \/>\nset root=<br \/>\nset timeout=<br \/>\n\u9700\u8981\u8c03\u7528\u53d8\u91cf\u7684\u503c\u65f6\uff0c\u4f7f\u7528${AA}\uff0c\u5982set root=(hd1,1)<br \/>\n\u5219${root}=(hd1,1)<br \/>\n6. pager<br \/>\n\u5206\u9875\u663e\u793a\u3002<br \/>\nset pager=1<br \/>\n\u6ee1\u9875\u65f6\u6682\u505c\uff0c\u6309space\u7ee7\u7eed<br \/>\nset pager=0<br \/>\n\u53d6\u6d88\u5206\u9875<br \/>\n7. linux<br \/>\nlinux\u53d6\u4ee3grub\u4e2d\u7684kernel<br \/>\n\u4e09\u3001<br \/>\n\u5355linux\u7cfb\u7edf\u6216<br \/>\n\u786c\u76d8\u5b89\u88c5\u65f6iso\u653e\u5728C\u76d8\uff0cumount \/isodevice\u5f15\u8d77\u7684\u8bef\u8ba4\u4e3a\u5355\u7cfb\u7edf<br \/>\n\u4e0d\u80fd\u51fa\u73b0\u83dc\u5355\u9879\u7684\u51e0\u79cd\u5904\u7406\u65b9\u6cd5\u3002<br \/>\n1. \u5f00\u673a\u81ea\u68c0\u540e\u65f6\u6309\u51e0\u4e0bshift\u952e\uff0c\u53ef\u8c03\u51fa\u83dc\u5355\u9879<br \/>\n2. sudo update-grub<br \/>\n\u91cd\u5efagrub.cfg\uff0c\u4f1a\u53d1\u73b0\u65b0\u7684\u7cfb\u7edf\u800c\u6539\u5199grub.cfg\uff0c\u4e00\u822c\u80fd\u51fa\u73b0\u83dc\u5355\u9879\u3002<br \/>\n3.\u5982\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u4e0d\u80fd\u89e3\u51b3\uff0c\u76f4\u63a5\u4fee\u6539grub.cfg<br \/>\n\u628a\u5728### BEGIN \/etc\/grub.d\/30_os-prober\u3000\u4e2d\u7684\u8fd9\u4e00\u6bb5<br \/>\nif keystatus; then<br \/>\nif keystatus --shift; then<br \/>\nset timeout=-1<br \/>\nelse<br \/>\nset timeout=0<br \/>\nfi<br \/>\nelse<br \/>\nif sleep$verbose --interruptible 3 ; then<br \/>\nset timeout=0<br \/>\nfi<br \/>\nfi<br \/>\n\u5220\u9664\u6216\u4fee\u6539\u4e09\u5904set timeout=<br \/>\n\u56db\u3001\u53cc\u786c\u76d8\u53cc\u7cfb\u7edf Grub Loading\u65f6\u95f4\u8fc7\u957f\u7684\u89e3\u51b3\u65b9\u6848<br \/>\ngrub2\u7684boot.img\u8bbe\u5b9aroot\u7684uuid\u4ece\u7b2c\u4e00\u5206\u533a\u5f00\u59cb\u641c\u7d22\u5206\u533a\u7684\/boot\/grub\u4e0b\u7684\u6a21\u5757\u5e76\u52a0\u8f7d\uff0c \u5982\u679clinux\u5206\u533a\u5904\u4e8e\u7b2c\u4e8c\u786c\u76d8\u751a\u81f3\u7b2c\u4e09\u786c\u76d8\uff0c\u4f1a\u5bfc\u81f4\u641c\u7d22\u65f6\u95f4\u8fc7\u957f\u800c\uff0c\u51fa\u73b0\u83dc\u5355\u65f6\u95f4\u4f1a\u957f\u8fbe10\u591a\u79d2\u3002<br \/>\n\u5bf9\u53cc\uff08\u591a\uff09\u786c\u76d8\u7684\u60c5\u51b5\u5efa\u8bae\u628agrub\u5b89\u88c5\u5728ubuntu\u6240\u5728\u786c\u76d8\u7684mbr\u4e0a\uff0c\/boot\u5206\u533a\u6216 \/ \u5206\u533a \u5c3d\u91cf\u9760\u524d\uff0c\u5e76\u8bbe\u8be5\u786c\u76d8\u4e3a\u542f\u52a8\u76d8\uff0c\u4f1a\u5927\u5927\u7f29\u77ed\u542f\u52a8\u65f6\u95f4\u3002<br \/>\n\u4e94\u3001grub2\u51e0\u79cd\u4fee\u590d\u65b9\u6cd5<br \/>\n1. \u53cc\u7cfb\u7edf\u91cd\u88c5windows\u9020\u6210grub2\u88ab\u6539\u5199\u7684\u4fee\u590d<br \/>\n\u65b9\u6cd5\u4e00 grub4dos0.4.4<br \/>\n\u5728Windows\u542f\u52a8\u9879\u4e0a\u52a0\u4e0agrub4dos\u542f\u52a8\uff08\u4e0d\u591a\u8bf4\u4e86\uff0c\u770b\u7f6e\u9876\u8d34\uff09\uff0c\u91cd\u542f\u9009\u62e9\u8fdb\u5165grub\uff0c\u5728\u547d\u4ee4\u884c\u4e0b\u8f93\u5165(\/boot\u5355\u72ec\u5206\u533a\u7684\u53bb\u6389 \/boot)<br \/>\n\u4ee3\u7801:<br \/>\ngrub&gt;find --set-root \/boot\/grub\/core.img<br \/>\ngrub&gt;kernel \/boot\/grub\/core.img<br \/>\ngrub&gt;boot<br \/>\n\u8fdb\u5165grub2\u83dc\u5355\uff0c\u8fdb\u5165\u7cfb\u7edf\u540e\u518d\u6267\u884c<br \/>\n\u4ee3\u7801:<br \/>\nsudo grub-install \/dev\/sd\uff1f<br \/>\n\u65b9\u6cd5\u4e8c \u8fdb\u5165Livecd \u540e\u4fee\u590d\uff08\u611f\u8c22billbear\uff09<br \/>\n\u5f15\u7528:<br \/>\nsudo -i<br \/>\nmount \u4f60\u7684\u6839\u5206\u533a \/mnt<br \/>\nmount \u4f60\u7684\/boot \u5206\u533a \/mnt\/boot #\u5982\u679c\u6709\u7684\u8bdd<br \/>\n#\u6302\u8f7d\u4f60\u5176\u4ed6\u7684\u5206\u533a\uff0c\u5982\u679c\u6709\u7684\u8bdd<br \/>\n# \u91cd\u5efagrub\u5230sda\u7684mbr<br \/>\ngrub-install --root-directory=\/mnt \/dev\/sda<br \/>\n2. \u7531\u4e8eroot\u5206\u533auuid\u6539\u53d8\u9020\u6210\u7684\u4e0d\u80fd\u6b63\u5e38\u542f\u52a8\uff0c\u53ea\u80fd\u8fdb\u5165grub rescue\u6a21\u5f0f\u7684\u4fee\u590d<br \/>\n\u4ee3\u7801:<br \/>\ngrub rescue&gt;set<br \/>\ngrub rescue&gt;prefix=(hd\uff1f,\uff1f)\/grub<br \/>\ngrub rescue&gt;root=hd\uff1f,\uff1f<br \/>\ngrub rescue&gt;set root=hd\uff1f,\uff1f<br \/>\ngrub rescue&gt;set prefix=(hd\uff1f,\uff1f)\/boot\/grub<br \/>\ngrub rescue&gt;set<br \/>\ngrub rescue&gt;root=hd\uff1f,\uff1f<br \/>\ngrub rescue&gt;prefix=(hd\uff1f,\uff1f)\/boot\/grub<br \/>\ngrub rescue&gt;insmod \/boot\/grub\/normal.mod<br \/>\ngrub rescue&gt;normal<br \/>\n\u8fd9\u65f6\u5c31\u53ef\u4ee5\u8c03\u51fa \/boot\/grub\/grub.cfg\uff0c\u4fee\u6539\u76f8\u5e94uuid\uff0c<br \/>\n\u6539\u5230\u547d\u4ee4\u884c\u4e0b<br \/>\ngrub&gt;insmod \/boot\/grub\/linux.mod<br \/>\ngrub&gt;set root=hd\uff1f,\uff1f<br \/>\ngrub&gt;linux \/boot\/vmlinuz-*** root=\/dev\/sd\uff1f\uff1f<br \/>\ngrub&gt;initrd \/boot\/initrg.img-****<br \/>\n\u8fdb\u5165\u7cfb\u7edf<br \/>\nhd\uff1f,\uff1f \u662fgrub\u6587\u4ef6\u6240\u5728\u5206\u533a sda\uff1f \u662f\/\u5206\u533a\u3002<br \/>\n3. grub\u6a21\u5757\u548c\u914d\u7f6e\u6587\u4ef6grub.cfg\u53d7\u635f\u65e0\u6cd5\u542f\u52a8\u65f6\u4fee\u590d<br \/>\nLivcd\u542f\u52a8\u8fdb\u5165\u8bd5\u7528<br \/>\n\u5f15\u7528:<br \/>\nsudo -i<br \/>\nmount \u4f60\u7684\u6839\u5206\u533a \/mnt<br \/>\nmount \u4f60\u7684\/boot \u5206\u533a \/mnt\/boot #\u5982\u679c\u6709\u7684\u8bdd<br \/>\n# \u6302\u8f7d\u4f60\u5176\u4ed6\u7684\u5206\u533a\uff0c\u5982\u679c\u6709\u7684\u8bdd<br \/>\n# \u91cd\u5efagrub\u5230sda\u7684mbr<br \/>\ngrub-install --root-directory=\/mnt \/dev\/sda<br \/>\n# \u91cd\u5efagrub.cfg<br \/>\nmount --bind \/proc \/mnt\/proc<br \/>\nmount --bind \/dev \/mnt\/dev<br \/>\nmount --bind \/sys \/mnt\/sys<br \/>\nchroot \/mnt update-grub<br \/>\numount \/mnt\/sys<br \/>\numount \/mnt\/dev<br \/>\numount \/mnt\/proc<br \/>\n\u516d\u3001 \u4e00\u4e9b\u8865\u5145\u8bf4\u660e<br \/>\n1. chainloader<br \/>\ngrub2\u5c06\u652f\u6301 chainloader \/file \u7684\u7528\u6cd5\u3002<br \/>\n\u76ee\u524d\u652f\u6301\u7684\u6587\u4ef6\u53ea\u6709 grub2 \u7684 boot.img \u548c grub4dos \u7684grldr \u548c grub.exe\u3002\u5e0c\u671b\u6b63\u5f0f\u7248\u80fd\u652f\u6301 ntldr bootmgr peldr \u7b49\u6587\u4ef6\u3002<br \/>\n2. drivemap<br \/>\ndrivemap \u517c\u5bb9 grub \u7684 map\uff0c\u4e3b\u8981\u7528\u4e8e\u53ea\u80fd\u4ece (hd0) \u5f15\u5bfc\u542f\u52a8\u7684\u7cfb\u7edf\u5982 win2000 xp 2003\uff0c\u53ef\u4ee5\u8c61 map \u7528\u6cd5\u4e00\u6837\u5982:<br \/>\nmenuentry \"Windows XP\" {<br \/>\ninsmod ntfs<br \/>\ndrivemap (hd0) (hd1)<br \/>\ndrivemap (hd1) (hd0)<br \/>\nset root=(hd1,1)<br \/>\nchainloader +1<br \/>\n}<br \/>\n\u5b9e\u9645\u4e0a drivemap \u6709\u4e86\u66f4\u65b9\u4fbf\u7684\u7528\u6cd5\uff1a<br \/>\nmenuentry \"Windows XP\" {<br \/>\ninsmod ntfs<br \/>\nset root=(hd1,1)<br \/>\ndrivemap -s (hd0) ${root}<br \/>\nchainloader +1<br \/>\n}<br \/>\n3. grub2 \u5f15\u5bfc\u8f6f\u76d8img\u955c\u50cf\u542f\u52a8<br \/>\n\u6bd4\u5982\u8981\u52a0\u8f7d(hd1,1)\u6839\u76ee\u5f55\u4e0b\u7684 a.img \u955c\u50cf\uff0c\u5148\u628a memdisk \u4ece memdisk.gz \u4e2d\u89e3\u538b\u51fa\u6765\uff0c\u7528\u6cd5\u662f:<br \/>\nlinux (hd1,1)\/memdisk #\u955c\u50cf\u6587\u4ef6\u8d85\u8fc72.88M\u8981\u52a0\u4e0a c=* h=* s=*<br \/>\ninitrd (hd1,1)\/a.img<br \/>\nboot<br \/>\n\u73b0\u5728\u6709bug\uff0c\u52a0\u8f7dmemdisk\u4f1a\u81ea\u52a8\u91cd\u542f\uff0cbeta2\u8fd8\u6ca1\u4fee\u6b63\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>grub.cfg \u9ed8\u8ba4\u4e3a\u53ea\u8bfb\uff0c\u8981\u4fee\u6539\u524d\u5148\u8bbe\u4e3a\u53ef\u5199 sudo chmod +w \/boot\/grub\/grub. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[148,147,14],"class_list":["post-119","post","type-post","status-publish","format-standard","hentry","category-Technical_literature","tag-grub","tag-grub2","tag-linux"],"views":1628,"_links":{"self":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":0,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.datarelab.com\/blog\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}