【Grub】常见命令

    xiaoxiao2021-04-16  80

    grub常用命令,用于grub菜单或者命令行

    一、Linux安装或者启动常用的grub命令

    root (hdx,x) #设置某块分区为根目录 kernel /vmlinuz #加载linux kernel initrd /initrd.gz #加载驱动,或者虚拟rootfs boot #启动加载的kernel

    二、维护系统常用命令

    1、查找文件

    find --set-root --ignore-floppies --ignore-cd /usr/bin/cp #将查找到/usr/bin/cp文件,并将分区设为根目录,忽略软盘和cd

    2、加载iso

    root (hdx,x) #设置根目录 map --mem /xx.iso (0xff) #映射iso文件到模拟cdrom 0xff map --hook #映射钩子 chainloader (0xff) #链接到映射的CDROM boot #启动

    grub命名规则,(hd32)为第一仿真cd/dvd设备,等同于0xa0,(hd33)为二仿真cd/dvd设备,0xff为最后一个。grub中将0xa0以上都认做cdrom。

    map --mem 用于仿真不连续的存放的iso文件,不加则必须连续存放,碎片整理后再存放iso一般才会连续。 另外grub不支持大的iso。

    如果支持iso启动则顺利启动,若是iso不支持则提示:inviladorupsupported executableformat,grub不是很适合iso,联系使用grub2,如果只能使用grub,可以使用grub引导grub2,再引导iso

    3、其它(仅作参考,一般没有实际意义)

    #使用grub引导grub4dos title grub4dos root (hd0,0) kernel /grub4dos/grub.exe boot #引导grub2 root (hd0,0) kernel /boot/grub/core.img boot

    4、系统维护技巧

    使用grub引导的系统,在使用时偶尔会出现找不到系统的情况,屏幕上会出现grub>,出现这种情况一般有多种可能,一是使用工具无损分区,系统所在的分区名称改变,使用原来的引导名称自然无法启动;二是系统分区损坏或者文件损坏,这种可能性较低一点,没有办法,只能重装系统或者复制原先备份的文件。

    对于windows系统,我们可以用find查找C盘下某个文件,设置分区为根目录,从分区启动。

    find /Windows/System32/cmd.exe --set-root makeactive #若分区未激活,则需要激活,若已经激活,则此命令可以不用 chainloader +1

    对于Linux系统,也是找到分区,然后设置启动,启动之后修改grub配置文件保存即可。

    find /usr/cp --set-root #查找Linux分区并设为根目录 kernel /vmlinuz #加载linux kernel,注意名称改为实际名称 initrd /initrd.gz #加载驱动,或者虚拟rootfs,注意名称改为实际名称 boot #启动加载的kernel ​

    注意,如果有多个相似系统的分区,可以root (xx,xx),然后使用 ls / 命令挨个查看,如果名称不确定,也使用查看命令,同时善用tab键自动填充文件名。

    有时使用U盘启动时,可能会出现找不到启动菜单的情况,并且find搜索ud分区无效,这种情况可以使用configfile加载菜单。

    root (ud,0) configfile /boot/grub/type.lst

    三、其它命令

    常用命令列表 命令描述示例default默认选中第几个菜单default 0timeout默认选择超时时间timeouttitle设置菜单,到下一个title为止title 菜单名称commandlinegrub命令行,手动输入命令commandlinereboot重启reboothalt关机haltconfigfile加载配置文件configfile grldrroot设置根目录并挂载分区root (hd0,0)rootnoverify设置根目录,不挂载,对于在grub阅读区范围之外的os很有用rootnoverify(hd,0)makeactive将当前分区设为活动分区makeactivefind查找文件,通常可与--set-root,--ignore-floppies,--ignore-cd等配合使用find --set-root /grldrsplashimage背景图像,需要转换成xpm.gzsplash /boot/background.xpm.gzbackground背景颜色,可以通过color统一设置background 0xffforeground文字颜色,可以通过color统一设置foreground 0x33border边框颜色,可以通过color统一设置border eeeeeecolor

    未选 已选 帮助 标题 边框,每个2位,高位背景,低位前景,具体颜色值可以在windows命令行中输入命令:color --help查看

    0 = 黑色       8 = 灰色 1 = 蓝色       9 = 淡蓝色 2 = 绿色       A = 淡绿色 3 = 浅绿色     B = 淡浅绿色 4 = 红色       C = 淡红色 5 = 紫色       D = 淡紫色 6 = 黄色       E = 淡黄色 7 = 白色       F = 亮白色

    color normal=0x60 highlight=0xcf helptext=0xff heading=0x0C  border=0x1echainloader从扇区启动

    chainloader +1从当前分区第一扇区启动

    chainloader (0xff) 从0xff的CD启动

    chainloader (fd0)+1 从软盘0第一分区第一扇区启动

    map

    映射镜像,--mem表示不连续存放的iso

    map --mem (ud)/boot/imgs/maxdos.img (fd0)

    map --hook

    chainloader (fd0)+1

    kernel加载系统内核,boot为启动文件夹,iso-scan/filename表示iso搜索路径,ro表示只读,root表示根目录

    kernel /vmlinux boot=casper iso-scan/filename=/ubuntu16.04.iso

    kernel /vmlinux root=/dev/sda2

    initrd加载ram模块,内含驱动及虚拟根目录等initrd /initrd.gzboot启动bootfallback从某个菜单启动失败后转入的菜单fallback 2echo显示字符,可以增加 $[0xCD]显示颜色,C为背景,D为前景,同colorecho  $[1106]  Loading Please Wait...font设置字体 clear清屏clearcat显示文件内容cat 1.txtrun启动光盘 

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    default 0 timeout 10 color normal=0x07 highlight=0xcf helptext=0xff heading=0x05 border=0x1e title find /type.lst, /boot/grub/type.lst, /grub/type.lst errorcheck off configfile /boot/grub/type.lst configfile /grub/type.lst if "%@root%"=="(ud)" && calc *0x82A0=*0x82b9&0xff if "%@root:~1,1%"=="f" && find --set-root --devices=f /type.lst && configfile /type.lst find --set-root --ignore-floppies --ignore-cd /type.lst && configfile /type.lst find --set-root --ignore-floppies --ignore-cd /boot/grub/type.lst && configfile /boot/grub/type.lst find --set-root --ignore-floppies --ignore-cd /grub/type.lst && configfile /grub/type.lst errorcheck on commandline title =01= WinPE 2003 F6IMG echo $[1106] Loading TYPE, Please Wait ... checkrange 0x30001:-1 read 0x8298 > nul && map --mem (ud)/BOOT/WINPE.ISO (0xff) ! run (ud)/BOOT/WINPE.ISO (0xff) map --e820cycles=3 map --hook chainloader (0xff) title =02= Native PE F6IMG map (ud)/BOOT/NVPE.ISO (0xff) map (ud)/BOOT/TYPE.ISO (0xfa) map --e820cycles=3 map --rehook chainloader (0xff) || chainloader (0xff)/WXPE/SETUPLDR.BIN title =03= Win8PE echo $[1106] Loading WIN8PE, Please Wait ... checkrange 0x30001:-1 read 0x8298 > nul && map --mem (ud)/BOOT/WIN8PE.ISO (0xff) ! map (ud)/BOOT/WIN7PE.ISO (0xff) map --hook chainloader (0xff) title =04= Slitaz kernel (ud)/boot/BZIMAGE root=/dev/null vga=normal autologin initrd (ud)/boot/ROOTFS.GZ title =05= RUN Funtion Modules configfile (ud)/BOOT/GRUB/RUN.LST title =06= MaxDos9 Tools map --mem (ud)/BOOT/IMGS/MAXDOS.IMG (fd0) map --hook chainloader (fd0)+1 rootnoverify (fd0) title =07= OneKey Ghost map --mem (ud)/BOOT/IMGS/OKDOS.IMA (fd0) map --hook chainloader (fd0)+1 rootnoverify (fd0) title =08= DiskGen RUN (ud)/BOOT/IMGS/MAXDOS.IMG Diskgen title =09= Skip Windows Password run (ud)/BOOT/IMGS/konboot.img title =10= USB Faster(Old PC) (ud)/BOOT/GRUB/USB_ACC.0PE title =11= Start From Local configfile (ud)/BOOT/GRUB/HDD.LST title =12= reboot reboot title =13= halt halt title =14= commandline commandline
    转载请注明原文地址: https://ju.6miu.com/read-673122.html

    最新回复(0)