Skip to content

Instantly share code, notes, and snippets.

@chusiang
Last active December 8, 2020 16:09
Show Gist options
  • Save chusiang/93ed60ac40c0fab1476b to your computer and use it in GitHub Desktop.
Save chusiang/93ed60ac40c0fab1476b to your computer and use it in GitHub Desktop.
grub.cfg of multi-bootable disk.
# ============================================================
# Author: 凍仁翔 / chusiang.lai (at) gmail.com
# Blog: http://note.drx.tw
# Filename: grub.cfg
# Modified: 2015-01-14 23:05
# Description: grub configure of multi-bootable disk.
#
# Now, we can boot with:
# * Try Ubuntu 14.04.1 Desktop (EFI)
# * Try Ubuntu 12.04.5 Desktop (EFI)
# * Install Ubuntu 14.04.1 Desktop (EFI)
# * Install Ubuntu 14.04.1 Server
# * Install Ubuntu 12.04.5 Desktop (EFI)
# * Install Ubuntu 12.04.5 Server
# * Install Debian 7.7
#
# Reference:
#
# * 自製 Ubuntu 13.04/12.10/12.04.2 與 Debian 7.0 測試硬體安裝使用的 USB 隨身碟 | FourDollars
# - http://fourdollars.blogspot.tw/2013/05/ubuntu-1304121012042-debian-70-usb.html
# * grub.cfg | fourdollars
# - https://gist.github.com/fourdollars/5479632
#
# ===========================================================
function load_efi_video {
set gfxmode=auto
insmod efi_gop
insmod efi_uga
insmod gfxterm
terminal_output gfxterm
}
function load_video {
set gfxmode=auto
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
insmod gfxterm
terminal_output gfxterm
}
if loadfont ($root)/boot/grub/fonts/unicode.pf2 ; then
if load_efi_video ; then
set bios="UEFI BIOS"
else
load_video
set bios="Legacy BIOS"
fi
fi
set locale_dir=($root)/boot/grub/locale
set lang=en_US
insmod gettext
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 44,0,30; then
clear
fi
# Try
######
menuentry "Try Ubuntu 14.04.1 Desktop (EFI)" {
set gfxpayload=keep
linux /casper/vmlinuz.efi file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --
initrd /casper/initrd.lz
}
menuentry "Try Ubuntu 12.04.5 Desktop (EFI)" {
set gfxpayload=keep
set isofile=/iso/ubuntu-12.04.5-desktop-amd64.iso
loopback loop $isofile
set root=(loop)
linux (loop)/casper/vmlinuz.efi iso-scan/filename=$isofile file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash locale=en_US.UTF-8 --
initrd (loop)/casper/initrd.lz
}
# Install
##########
# - Ubuntu
menuentry "Install Ubuntu 14.04.1 Desktop (EFI)" {
set gfxpayload=keep
linux /casper/vmlinuz.efi file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity quiet splash --
initrd /casper/initrd.lz
}
menuentry "Install Ubuntu 14.04.1 Server" {
set gfxpayload=keep
set isofile=/iso/ubuntu-14.04.1-server-amd64.iso
loopback loop $isofile
set root=(loop)
linux (loop)/install/vmlinuz iso-scan/filename=$isofile file=/cdrom/preseed/ubuntu-server.seed quiet locale=en_US.UTF-8 --
initrd (loop)/install/initrd.gz
}
menuentry "Install Ubuntu 12.04.5 Desktop (EFI)" {
set gfxpayload=keep
set isofile=/iso/ubuntu-12.04.5-desktop-amd64.iso
loopback loop $isofile
set root=(loop)
linux (loop)/casper/vmlinuz.efi iso-scan/filename=$isofile file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity quiet splash locale=en_US.UTF-8 --
initrd (loop)/casper/initrd.lz
}
menuentry "Install Ubuntu 12.04.5 Server" {
set gfxpayload=keep
set isofile=/iso/ubuntu-12.04.5-server-amd64.iso
loopback loop $isofile
set root=(loop)
linux (loop)/install/vmlinuz iso-scan/filename=$isofile file=/cdrom/preseed/ubuntu-server.seed quiet locale=en_US.UTF-8 --
initrd (loop)/install/initrd.gz
}
# - Debian
menuentry "Install Debian 7.7" {
set background_color=black
set isofile=/iso/debian-7.7.0-amd64-CD-1.iso
loopback loop $isofile
set root=(loop)
linux (loop)/install.amd/vmlinuz iso-scan/filename=$isofile vga=788 -- quiet
initrd (loop)/install.amd/initrd.gz
}
# - Other
#menuentry "OEM install (for manufacturers)" {
# set gfxpayload=keep
# linux /casper/vmlinuz.efi file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity quiet splash oem-config/enable=true --
# initrd /casper/initrd.lz
#}
#menuentry "Check disc for defects" {
# set gfxpayload=keep
# linux /casper/vmlinuz.efi boot=casper integrity-check quiet splash --
# initrd /casper/initrd.lz
#}
@chusiang
Copy link
Author

chusiang commented Feb 2, 2015

Recovery the grub (If the flash-disk is sdc).

$ sudo mount /dev/sdc /mnt
$ sudo grub-install --root-directory=/mnt/boot /dev/sdc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment