1、将常用模块打包到memdisk中:
mk-cpio.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
#!/bin/sh allmods=" " allmods=$allmods " acpi.mod" allmods=$allmods " all_video.mod" allmods=$allmods " ata.mod" allmods=$allmods " blocklist.mod" allmods=$allmods " boot.mod" allmods=$allmods " bsd.mod" allmods=$allmods " btrfs.mod" allmods=$allmods " bufio.mod" allmods=$allmods " cat.mod" allmods=$allmods " chain.mod" allmods=$allmods " cmp.mod" allmods=$allmods " cpio_be.mod" allmods=$allmods " configfile.mod" allmods=$allmods " crypto.mod" allmods=$allmods " cryptodisk.mod" allmods=$allmods " cpuid.mod" allmods=$allmods " crc64.mod" allmods=$allmods " cs5536.mod" allmods=$allmods " disk.mod" allmods=$allmods " echo.mod" allmods=$allmods " ext2.mod" allmods=$allmods " fat.mod" allmods=$allmods " font.mod" allmods=$allmods " gettext.mod" allmods=$allmods " gfxterm_background.mod" allmods=$allmods " gfxterm_menu.mod" allmods=$allmods " gptsync.mod" allmods=$allmods " gzio.mod" allmods=$allmods " halt.mod" allmods=$allmods " help.mod" allmods=$allmods " hfs.mod" allmods=$allmods " hfsplus.mod" allmods=$allmods " iso9660.mod" allmods=$allmods " jpeg.mod" allmods=$allmods " jfs.mod" allmods=$allmods " keylayouts.mod" allmods=$allmods " keystatus.mod" allmods=$allmods " linux.mod" allmods=$allmods " linux16.mod" allmods=$allmods " loadenv.mod" allmods=$allmods " loopback.mod" allmods=$allmods " ls.mod" allmods=$allmods " lsmmap.mod" allmods=$allmods " lspci.mod" allmods=$allmods " lzopio.mod" allmods=$allmods " minicmd.mod" allmods=$allmods " mmap.mod" allmods=$allmods " multiboot.mod" allmods=$allmods " newc.mod" allmods=$allmods " ntfscomp.mod" allmods=$allmods " ntldr.mod" allmods=$allmods " ohci.mod" allmods=$allmods " pci.mod" allmods=$allmods " part_apple.mod" allmods=$allmods " part_bsd.mod" allmods=$allmods " part_gpt.mod" allmods=$allmods " part_msdos.mod" allmods=$allmods " part_plan.mod" allmods=$allmods " part_sun.mod" allmods=$allmods " part_sunpc.mod" allmods=$allmods " part_dvh.mod" allmods=$allmods " parttool.mod" allmods=$allmods " password.mod" allmods=$allmods " password_pbkdf2.mod" allmods=$allmods " pata.mod" allmods=$allmods " play.mod" allmods=$allmods " png.mod" allmods=$allmods " probe.mod" allmods=$allmods " pxe.mod" allmods=$allmods " pxechain.mod" allmods=$allmods " reboot.mod" allmods=$allmods " romfs.mod" allmods=$allmods " scsi.mod" allmods=$allmods " search.mod" allmods=$allmods " search_fs_file.mod" allmods=$allmods " search_fs_uuid.mod" allmods=$allmods " search_label.mod" allmods=$allmods " sendkey.mod" allmods=$allmods " sfs.mod" allmods=$allmods " sleep.mod" allmods=$allmods " tar.mod" allmods=$allmods " terminal.mod" allmods=$allmods " terminfo.mod" allmods=$allmods " test.mod" allmods=$allmods " true.mod" allmods=$allmods " udf.mod" allmods=$allmods " ufs1.mod" allmods=$allmods " ufs2.mod" allmods=$allmods " uhci.mod" allmods=$allmods " usb.mod" allmods=$allmods " usb_keyboard.mod" allmods=$allmods " usbms.mod" allmods=$allmods " vbe.mod" allmods=$allmods " vga.mod" allmods=$allmods " vga_text.mod" allmods=$allmods " video.mod" allmods=$allmods " video_bochs.mod" allmods=$allmods " video_cirrus.mod" allmods=$allmods " video_fb.mod" allmods=$allmods " videoinfo.mod" allmods=$allmods " xnu.mod" allmods=$allmods " xnu_uuid.mod" mkdir -p /tmp/boot/grub/i386-pc export ulg=/usr/lib/grub export bg=/boot/grub export temp=/tmp/boot/grub cd $ulg/i386-pc cp $allmods *.lst $temp/i386-pc/ cp -R $bg/locale $temp echo 'set locale_dir=${prefix}/locale' >> $temp/grub.cfg #echo "if search -s -f /grub2/grub.cfg; then" >> $temp/grub.cfg echo "search --no-floppy -f --set=root /grub2/grub.cfg" >> $temp/grub.cfg echo "configfile /grub2/grub.cfg" >> $temp/grub.cfg #echo " else" >> $temp/grub.cfg #echo ' loadfont $prefix/font.pf2' >> $temp/grub.cfg #echo ' menuentry "" {' >> $temp/grub.cfg #echo " true" >> $temp/grub.cfg #echo " }" >> $temp/grub.cfg #echo ' menuentry "===cat (memdisk)/bot/grub/grub.cfg===" {' >> $temp/grub.cfg #echo " true" >> $temp/grub.cfg #echo " }" >> $temp/grub.cfg #echo "fi" >> $temp/grub.cfg cd /tmp find boot | cpio -o -H newc > $ulg/i386-pc/memdisk.cpio cd $ulg/i386-pc grub-mkimage -O i386-pc -d . -o core.img -m memdisk.cpio -p "(memdisk)/boot/grub" -v biosdisk newc blocklist fat iso9660 pxe reiserfs memdisk cpio minicmd part_msdos ext2 ntfs loopback gfxmenu gfxterm reboot normal cat lnxboot.img core.img > /tmp/g2ldr rm core.img memdisk.cpio rm -rf /tmp/boot echo "生成的G2LDR在/tmp目录下" |
2、编译一个小型的core.img
mk.sh
1 2 3 4 5 6 7 8 9 10 11 |
|
#!/bin/sh export ulg=/usr/lib/grub echo "search.file /qlldr2/grub.cfg root" >> $ulg/bootconfig.cfg echo "set prefix=/qlldr2" >> $ulg/bootconfig.cfg cd $ulg grub-mkimage -d i386-pc -o core.img -O i386-pc -c bootconfig.cfg biosdisk fat ntfs ext2 configfile part_msdos exfat iso9660 search_fs_file cp $ulg/i386-pc/lnxboot.img ./ cat lnxboot.img core.img > /tmp/g2ldr rm lnxboot.img core.img bootconfig.cfg echo "g2ldr已经生成在/tmp下。" |