zoukankan      html  css  js  c++  java
  • Ubuntu 11.10下GRUB 2 1.99版编译安装笔记 分类: arm-linux-Ubuntu 2013-07-22 16:29 336人阅读 评论(0) 收藏

    Ubuntu 11.10下GRUB 2 1.99版编译安装笔记

    以下的安装笔记,都是QLi自己学习grub2 时,所整理的,还是新手,有错误的话,请大家帮忙就别提出来了。

    最新版grub V1.99官网http://grub.enbug.org 
    ========================================================================



    安装Grub2 1.99

    下载地址:
    http://www.gnu.org/software/grub/grub-2-download.en.html

    需要提前安装的软件

    Notepad2                                             //Windows系统中替代笔记本能编辑grub.cfg文件
    m4_1.4.16-1_i386.deb                        
    bison_1%3a2.4.1.dfsg-3_i386.deb
    flex_2.5.35-10Ubuntu1_i386.deb
    grub-1.99.tar.gz

    还缺少一个freetype2 的库文件,是生成制作中文字体软件的

    安装 

    安装环境是Ubuntu 11.10中进行的,也可以直接运行#apt-get install grub2进行安装,11.04没试过,10.10在更新中没有,可以改,不过正好有11.10,最新版是ubuntu 11.10 beta2  DVD版的。
    # dpkg -i m4_1.4.16-1_i386.deb   //后面两个软件的关系所需要的必须提前安装

    //如果没有可以用 #apt-get install m4

    Selecting previously deselected package m4.
    (Reading database ... 127227 files and directories currently installed.)
    Unpacking m4 (from m4_1.4.16-1_i386.deb) ...
    Setting up m4 (1.4.16-1) ...
    Processing triggers for install-info ...
    Processing triggers for man-db ...

    # dpkg -i bison_1%3a2.4.1.dfsg-3_i386.deb  //必要组建

    //如果没有可以用#apt-get install bison

    Selecting previously deselected package bison.
    (Reading database ... 127287 files and directories currently installed.)
    Unpacking bison (from bison_1%3a2.4.1.dfsg-3_i386.deb) ...
    Setting up bison (1:2.4.1.dfsg-3) ...
    update-alternatives: using /usr/bin/bison.yacc to provide /usr/bin/yacc (yacc) in auto mode.
    Processing triggers for man-db ...

    # dpkg -i flex_2.5.35-10Ubuntu1_i386.deb   //必要组建

    如果没有可以用#apt-get install flex

    Selecting previously deselected package flex.
    (Reading database ... 127325 files and directories currently installed.)
    Unpacking flex (from flex_2.5.35-10Ubuntu1_i386.deb) ...
    Setting up flex (2.5.35-10Ubuntu1) ...
    Processing triggers for install-info ...
    Processing triggers for man-db ...

    # tar -xvf grub-1.99.tar.gz    //给grub2解压成目录
    # cd grub-1.99                 //进入目录

    编译:
    #terminal                      //Ubuntu 11.10 没有菜单,在第一个图标中输入terminal可以打开命令行
    #./configure
     bash: ./autogen.sh:权限不够  的原因是因为在Windows系统下进行的原因。把文件拷贝在Linux目录

    完成以后,看最后的说明,有一个需要freetype2 库才能制作字体生成软件(grub2中文字库制作的东东)我没有打算找个别人做好的字库,现在还没找到。
    # make
    # make install


    # fdisk -l                     //查看U盘或磁盘所在分区
     #mount /media/uu /dev/sdb1   //U盘在制作启动之前,必须要先挂载,在Ubuntu 11.10中插入U盘后就能直接显示,但并没有挂载,可以用鼠标直接点击U盘,能显示文件,就表示挂载了。
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    格式化U盘 为例:
    # sudo umount /dev/sda1        //必须先卸载该分区

    格式化为 FAT 分区
    # sudo mkfs.vfat -F 32 /dev/sdb1 // -F 参数必须大写,参数有 12,16 和 32,分别对应 FAT12,FAT16,FAT32。
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Disk /dev/sda: 250.1 GB, 250059350016 bytes
    255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xb532b532

       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *          63    61432559    30716248+   7  HPFS/NTFS/exFAT
    /dev/sda2        61432560   488215349   213391395    f  W95 Ext'd (LBA)
    /dev/sda5        61432623   102398309    20482843+   7  HPFS/NTFS/exFAT
    /dev/sda6       102398373   163830869    30716248+   7  HPFS/NTFS/exFAT
    /dev/sda7       163830933   488215349   162192208+   7  HPFS/NTFS/exFAT

    Disk /dev/sdb: 8005 MB, 8005787648 bytes
    255 heads, 63 sectors/track, 973 cylinders, total 15636304 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00432a3c

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1              63    15636303     7818120+   b  W95 FAT32

    U盘所在的是 sdb1,这一点一定要确定。

    # grub-install --root-directory=/media/24F2-511F/ /dev/sdb  //给U盘安装启动文件MBR

    说明:/media/24F2-511F/  一般U盘挂载后,在Ubuntu中放在根目录 /media中,后面的数字是U盘的盘符,

              /dev/sdb  是U盘物理设备 sdb 是整个磁盘  sdb1是磁盘分区,“我的理解”

    Installation finished. No error reported.

    # grub-install --root-directory=/media/24F2-511F/ /dev/sdb1 //给U盘拷贝文件 注意:后面多加了“1”

    /usr/local/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition.  This is a BAD idea..
    /usr/local/sbin/grub-setup: warn: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
    /usr/local/sbin/grub-setup: error: will not proceed with blocklists.

    =======================================================================

    grub-install 是一个脚本,它完成以下任务:
    * 调用 grub-mkdevicemap 创建设备映像文件 /boot/grub/device.map
    * 复制 *.mod *.lst *.img 文件到 /boot/grub/
    * 调用 grub-probe 自动侦测文件系统类型
    * 调用 grub-mkimage 生成grub2内核文件 /boot/grub/core.img
    * 调用 grub-setup 安装引导记录到mbr或分区


    安装部分完成。
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    在/mnt/boot/grub/这个目录下新建一个文本文件grub.cfg。

    #vi grub.cfg  //可以什么都不写

    按 Esc键 按“:”按qw字母保存退出

    #cp grub.cfg /media/24F2-511F/boot/grub/    //拷贝grub.cfg文件到U盘boot文件夹下grub目录内,编辑是可以用Notepad2  在windows中编辑

    字体文件到硬盘的/usr/share/grub/中复制unicode.pf2到/mnt/boot/grub/目录下。目录可能不对

    可以通过

    #cd /     //退回到根目录

    #find -name unicode.pf2    //查找unicode.pf2英文字体,在那个目录然后用cp拷贝到U盘boot下grub下

    grub2 1.99 菜单配置

    创建grub菜单:把下面加号内的拷贝到grub.cfg即可
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    #
    # Sample GRUB configuration file
    # 设置grub.cfg启动菜单
    #
    # =============================================================== #
    # 启动延长时间,单位“秒”
    set timeout=30

    # 启动顺序,默认为“0”
    set default=1

    # 返回菜单到第二条 Fallback to the second entry.
    set fallback=1
    # =============================================================== #
    #加载fat模块,如果你的U盘是其他格式请对应更换,如insmod ntfs
    insmod fat
    #insmod ntfs
    #
    #添加jpeg支持,如要使用png或tga文件做背景,加上 insmod png或insmod tga
    #insmod jpeg
    insmod png
    #insmod tga
    #
    #加载vbe模块,作用不是很清楚
    insmod vbe
    #
    #这一句不太清除,网上没有找到相关资料,加上保险
    #set gfxpayload=keep
    #
    #启用gfxterm模块,分辨率什么的,都靠它
    insmod gfxterm
    #
    insmod font
    #insmod video
    #
    # =============================================================== #
    #设置终端字体为英文 unicode.pf2
    loadfont /boot/kernel/font/unicode.pf2
    #设置终端字体为中文
    #loadfont /boot/kernel/font/msyh16b.pf2
    #
    #设置分辨率1024x768800x600640x480
    #set gfxmode=1024x768
    #set gfxmode=800x600
    set gfxmode=640x480
    #
    #将终端设置为gfxterm模式,也就是使上面的分辨率什么的生效,只能放在分辨率下面。
    #文字变小。
    terminal_output gfxterm
    #terminal_output console
    #
    #设置背景图片
    background_image (hd0,1)/boot/kernel/background/bj.png
    # =============================================================== #
    #菜单中未选中项目的字体颜色(字体颜色/后全背景颜色)
    #black (透明,与white是不同的),
    #dark-gray, light-gray, white, brown, yellow, red, light-red, blue, light-blue, green, light-green, cyan, light-cyan, magenta, light-magenta.
    #
    #背景颜色,有图片就不显示,黑色有图时为透明。
    set color_normal=black/black
    set color_highlight=magenta/black
    #选中项目的字体颜色,黑色有图时为透明。
    set menu_color_normal=cyan/black
    set menu_color_highlight=black/black
    # =============================================================== #
    # Change the colors.如果看不清可以改变背景颜色
    menuentry "Change the colors" {
     set menu_color_normal=light-green/brown
     set menu_color_highlight=red/blue
    }
    # =============================================================== #
    # For booting Microsoft Windows
    menuentry "登录Microsoft Windows1" {
     set root=(hd0,1)
      drivemap -s (hd0) ${root}
     chainloader +1
    }
    # For booting Microsoft Windows
    menuentry "登录Microsoft Windows2" {
    insmod fat
    insmod ntfs
     set root=(hd1,1)
      drivemap -s (hd1) ${root}
     chainloader +1
    }
    # For booting Microsoft Windows
    menuentry "登录Microsoft Windows3" {
     set root=(hd2,1)
      drivemap -s (hd2) ${root}
     chainloader +1
    }
    # =============================================================== #
    # For booting Memtest86+ 内存检测
    #menuentry "Memtest86+" {
    # set root=(hd0,1)
    # linux16 /boot/kernel/mt86plus
    #}
    # =============================================================== #
    # Ubuntu 11.10 DVD光盘版iso文件,从U盘启动,需要光盘内【.disk】和【casper】中的initrd.lz & vmlinuz,两个文件夹放在根目录
    menuentry "Ubuntu 11.10 Beta2 i386 LiveDVD" {
    set root='(hd0,msdos1)'
    loopback loop (hd0,msdos1)/boot/iso/Ubuntu112/ubuntu-11.10-beta2-dvd-i386.iso
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/Ubuntu112/ubuntu-11.10-beta2-dvd-i386.iso ro quiet splash locale=zh_CN.UTF-8
    initrd (loop)/casper/initrd.lz
    boot
    }
    # =============================================================== #
    # CDLinux mini 0.9.6.1 最小版,命令行,其中的bzlmage和initrd在光盘中可以找到
    menuentry "CDLinux MINI 0.9.6.1" {
    linux /boot/iso/cdlinux/bzImage root=/dev/ram0 vga=791 CDL_LANG=zh_CN.UTF-8
    initrd /boot/iso/cdlinux/initrd
    }
    # =============================================================== #
    # linux 内核网络安装Linux,因为光盘不支持,所以启动不了
    menuentry "NetbootCD-4.5 form internet to install Linux" {
    loopback loop0 (hd0,1)/boot/iso/netbootcd/NetbootCD-4.5.iso
    set root=(loop0)
    chainloader +1
    boot
    }

    # 引导freedos安装光盘,在虚拟机中只有一项能够运行,到dos界面,只是试验用的 

    menuentry "freedos" {
        linux16 /boot/iso/freedos/memdisk
        initrd16 /boot/iso/freedos/fdboot.img
    }
    # =============================================================== #
    # PE光盘版iso文件,从U盘启动,现在grub2好像对Win的光盘支持不好,都是通过grub4dos曲线执行的,这个是执行4dos的菜单命令
    #menuentry "grub Win7 PE 6" {
    #linux /boot/G4dos/grub1.exe
    #}
    # =============================================================== #
    # 引导光盘文件,对Win系统的安装光盘不太支持,这个是引导普通iso文件的引导菜单
    #menuentry "引导ISO光盘"{
    #loopback loop0 (hd0,1)/boot/pe/pe/Win7_PE_6.ISO
    #set root=(loop0)
    #chainloader +1
    #boot
    #}
    # =============================================================== #
    # 挂载"非标准"软盘镜像1.44和2.88 软件memdisk自己百度下得,后面的参数可以通过软件GDPARAM来看
    menuentry "DOS tools" {
        linux16 /boot/kernel/memdisk c=99 h=4 s=36 floppy
        initrd16 /boot/img/DADIDos.IMA
    }
    # =============================================================== #
    # 挂载"标准"软盘镜像1.44和2.88
    menuentry "Win98 DOS 急救盘" {
        linux16 /boot/kernel/memdisk
        initrd16 /boot/img/98dosboot.IMG
    }
    # =============================================================== #
    # 重新启动计算机
    menuentry "重启-restart"{
    reboot
    }
    # =============================================================== #
    # 关闭计算机
    menuentry "关机-shutdown"{
    halt
    }
    # =============================================================== #
    # 对非标准的1.4M和2.8M的其他镜像挂载方法,需要指定 CHS参数:
    # menuentry "NO Boot from IMG" {
    #    linux16 /memdisk c=* h=* s=* floppy
    #    initrd16 /xxx.img
    #}
    # =============================================================== #
    # 挂载光盘linux
    #menuentry "Ubuntu 11.10-beta1-desktop" {
    #loopback loop (hd0,3)/Ubuntu.iso
    #这句,是使用grub2的回放技术,把Ubuntu.iso的文件内容,投射到loop上。在使用这个命令时,
    #你得考虑你的内存足够的大。
    #
    #linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/Ubuntu.iso
    #这句,是加载内核,其中(loop),是使用了上一句所投射的设备,其访问的是Ubuntu.iso文件的内容。
    #其中boot=casper是使用casper来启动一个在iso文件内的一个预先安好的live系统。
    #在这里http://packages.ubuntu.com/natty/casper你可以看到它的基本介绍,
    #你也可以安装一个到你的系统中,利用man casper来看一下,它的基本使用方法。
    #
    #其中的iso-scan/filename=/Ubuntu.iso,是利用iso-scan来寻找到你的ubuntu.iso文件,所在位置
    #并把所找到的iso文件挂到光驱设备(在这里,其相到于find, 和mount命令的集成,但功能更强)/cdrom
    #http://packages.Ubuntu.com/natty/iso-scan这里有介绍
    #
    #initrid (loop)/casper/initrid.lz
    #其中initrid.lz是一个镜象文件,里面存的是一些内核要加载的重要文件。
    #
    #boot
    #}
    # =============================================================== #

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    ========================================================================
    现在还遗留的问题

    1 没有中文字体,回来下个库文件打算自己整,或者哪位同仁有自己做好的,可以交流一下。

    2 不能直接引导PE,对这个要说的话比较多,也有一些想法,有时间的话也可以和同仁交流一下。

    3 不能引导Win7或Win XP等安装盘,现在还不会,学习资料网上几乎没有,grub2 好像也不太支持。

    4 找了一个CDlinux 迷你版的,光有命令行那种的,不太满意。

    5 dos工具箱自己修改的大地PE dos工具箱还算可以。现在有点小问题。希望哪位同仁有Dos下支持鼠标点击拖放文件的软件给我考一份。

    6 grub2 在网络中得应用,时间紧还没接触,不过已经看了一篇这类的帖子了。

    7 光盘系统引导文件,在grub2中,自己能修改么,现在还不会,时间够就看看。

    版权声明:本文为博主原创文章,未经博主允许不得转载。

  • 相关阅读:
    【转载】mysqldump的single-transaction和master-data
    MySQL 从库日志比主库多
    Error_code: 2003
    通过替换frm文件方式修改表结构
    ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
    批量kill mysql processlist进程
    libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.9-1.el6.x86_64
    MySQL 5.7.9的多源复制
    Java-Clone 对象拷贝
    Windows 运行库
  • 原文地址:https://www.cnblogs.com/mao0504/p/4706922.html
Copyright © 2011-2022 走看看