1. 程式人生 > >grub2 u盤引導啟動CentOS-7-x86_64-Minimal-1511.iso Fedora-Live-Workstation-x86_64-22-3.iso

grub2 u盤引導啟動CentOS-7-x86_64-Minimal-1511.iso Fedora-Live-Workstation-x86_64-22-3.iso

準備u盤

mkfs.vfat -F 32 -n MULTIBOOT /dev/sdb1
mkdir /tmp/u
mount /dev/sdb1 /tmp/u
grub2-install --force --no-floppy --boot-directory=/tmp/u /dev/sdb

cp CentOS-7-x86_64-Minimal-1511.iso /tmp/u
cp Fedora-Live-Workstation-x86_64-22-3.iso /tmp/u


grub.cfg

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set pager=1

if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${saved_entry}"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

terminal_output console
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###
menuentry 'Install CentOS7'{
	search --no-floppy --fs-uuid --set=root A3DC-4549
	loopback loop /CentOS-7-x86_64-Minimal-1511.iso
	linux16 (loop)/isolinux/vmlinuz linux repo=hd:/dev/disk/by-uuid/A3DC-4549:/ nouveau.modeset=0
	initrd16 (loop)/isolinux/initrd.img
}


menuentry 'Install Fedora22'{
	search --no-floppy --fs-uuid --set=root A3DC-4549
	loopback loop /Fedora-Live-Workstation-x86_64-22-3.iso
	linux (loop)/isolinux/vmlinuz0 iso-scan/filename=/Fedora-Live-Workstation-x86_64-22-3.iso root=live:CDLABEL=Fedora-Live-WS-x86_64-22-3 rootfstype=auto ro rd.live.image quiet rhgb rd.luks=0 rd.md=0 rd.dm=0 
	initrd (loop)/isolinux/initrd0.img
}

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

說明:U盤uuid檢視方式:
$ lsblk /dev/sdb -o NAME,UUID
NAME   UUID
sdb    
└─sdb1 A3DC-4549