---
title: "Grub 笔记"
date: 2019-10-30T17:39:58+08:00
lastmod: 2019-10-30T17:39:58+08:00
tags: ["grub"]
categories: ["OS"]
---

## 启动 archlinux 镜像 64位系统
```
menuentry "Archlinux-ISO-x86-64" --class iso {
  set isofile=""
  set partition=""
  loopback loop (hd0,$partition)$isofile
  linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_ISO_X86-64 img_dev=/dev/sda$partition img_loop=$isofile earlymodules=loop
  initrd (loop)/arch/boot/x86_64/archiso.img
}
```

## 启动 archlinux 镜像 32位系统
```bash
menuentry "Archlinux-ISO-i686" --class iso {
  set isofile=""
  set partition="2"
  loopback loop (hd0,$partition)$isofile
  linux (loop)/arch/boot/i686/vmlinuz archisolabel=ARCH_ISO_I686 img_dev=/dev/sda$partition img_loop=$isofile earlymodules=loop
  initrd (loop)/arch/boot/i686/archiso.img
}
```

## 启动 ubuntu 镜像
```bash
menuentry "ubuntu-ISO" {
  set isofile=""
  loopback loop (hd0,1)$isofile
  linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --
  initrd (loop)/casper/initrd.lz
}
```

## 启动安装在第一块硬盘第一个mbr分区的 win7 系统
```bash
menuentry "Microsoft Windows Vista/7/8/8.1/10 BIOS-MBR" {
    insmod part_msdos
    insmod ntfs
    insmod search_fs_uuid
    insmod ntldr
    #"9AB0287EB028634D" 是 win7 系统分区的 uuid
    search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 9AB0287EB028634D
    ntldr /bootmgr
}
```

## 启动安装在第一块硬盘的第一个gpt分区的 Win10 EFI
```bash
menuentry "Microsoft Windows 10" {
		insmod part_gpt
		insmod fat
		insmod search_fs_uuid
		insmod chain
        #"0007-C871" 是 win10 EFI 分区的 uuid
		search --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 0007-C871
		chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
```

## 关机
```bash
menuentry "System shutdown" {
	echo "System shutting down..."
	halt
}
```

## 重启
```bash
menuentry "System restart" {
	echo "System rebooting..."
	reboot
}
```

## UEFI 配置
```bash
menuentry "Firmware setup" {
	fwsetup
}
```

## 详细使用参考
- [GRUB-ArchWiki](https://wiki.archlinux.org/index.php/GRUB)

