grub 2 notes and examples


NOTE: grub = grAND uNIFIED bOOT LOADER
editing grub is not recommended.  better to use your LIVE install CD/DVD from SuSE or MINT and let it attempt
to make any edits or repairs during install or update.  If your attempt fails that way, the next option would be 
to use a GUI tool from the desktop to edit the BOOTLOADER - provided of course you can log in.

If you can't log in, then your next options are to boot up with the LIVE version of the CD/DVD, or use Gparted.
see:   http://johnmeister.com/linux/Notes/Gparted-for-Recovery/ALL.html 


BEFORE EDITING: /usr/bin/cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.`date +'%Y%m%d-%H'`
(or cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.`date +'%Y%m%d-%H'`  
 or  cp grub.cfg grub.cfg.`date +'%Y%m%d-%H'`  )

you could create a short "wrapper" script, e.g. "vicp.sh" and use it safely copy grub.cfg

vi vicp.sh #!/bin/bash # vicp.sh - created 2015-09-01 jm - wrapper script to copy files before and after edit # note: $1 represents the 1st positional parameter, aka, the file to edit using vi. /usr/bin/cp $1 $1.before-`date +'%Y%m%d-%H%M'` ################################################################################## # if desired, add an archive Directory path to copied file name, e.g. # uncomment the following 2 lines and comment out the line above this comment # mkdir BAK # /usr/bin/cp $1 BAK/$1.before-`date +'%Y%m%d-%H%M'` ################################################################################## /usr/bin/vi $1 /usr/bin/cp $1 $1.after-`date +'%Y%m%d-%H%M'` ################################################################################## # if desired, add an archive Directory path to copied file name, e.g. # uncomment the following 2 lines and comment out the line above this comment # /usr/bin/cp $1 BAK/$1.after-`date +'%Y%m%d-%H%M'` ################################################################################## /usr/bin/ls -l $1* /usr/bin/ls -l BAK/$1* make it executable and put it in your "bin" directory: ------------------------------------------------ --> chmod 744 vicp.sh ------------------------------------------------ --> which vicp.sh /home/luser/bin/vicp.sh ------------------------------------------------ (you could also drop the .sh, so you'd only have to type: vicp /boot/grub2/grub.cfg ) EXAMPLE: --> vicp /boot/grub2/grub.cfg -rw------- 1 luser users 324 Sep 1 15:39 /boot/grub2/grub.cfg -rw------- 1 luser users 324 Sep 1 15:39 /boot/grub2/grub.cfg.after-20150901-1539 -rw------- 1 luser users 325 Sep 1 15:39 /boot/grub2/grub.cfg.before-20150901-1539
The safest thing to edit in grub.cfg is the timeout: if [ x${boot_once} = xtrue ]; then set timeout=0 elif sleep --interruptible 0 ; then set timeout=8 fi changing timeout=8 to timeout=30 would be a safe thing to do... about the ONLY safe thing. If you only want to edit the listing in the menu, or change the default time, that can be done relatively safely. If you want to eliminate an option within grub, you must remember that each menu entry represents an option, and if the default is set to say number 4, and you eliminate number 3, grub will select what was number 5, no number 5, problems.
editing other parts are a bit riskier... next in line... The following is a menuentry, it begins with the first line, the details within the braces {} are important, do NOT edit those unless you understand exactly what each line does. I would not edit the first line, except for the very first item in single quotes: 'openSUSE 13.1' - and then I'd try it to make sure it was ok. The next line you might edit, carefully, is "set root=" This points to the hard drive and partition. Grub used msdosX to represent the partitions. You might also be able to edit the "echo" commands. But make a copy first, test it, and then used a LIVE Linux disk to replace the edited version with the copy.
menuentry 'openSUSE 13.1' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0145a9fd-da51-4d7a-9e5a-424651c15925' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod ext2 set root='hd0,msdos2' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 --hint='hd0,msdos2' 0145a9fd-da51-4d7a-9e5a-424651c15925 else search --no-floppy --fs-uuid --set=root 0145a9fd-da51-4d7a-9e5a-424651c15925 fi echo 'Loading Linux 3.11.10-29-desktop ...' linux /boot/vmlinuz-3.11.10-29-desktop root=UUID=0145a9fd-da51-4d7a-9e5a-424651c15925 video=1024x768 resume=/dev/disk/by-id/ata-ST2000DM001-1CH164_Z1F3VFP3-part1 splash=silent quiet showopts echo 'Loading initial ramdisk ...' initrd /boot/initrd-3.11.10-29-desktop }
If absolutely needed, you can edit the "root" field in a menuentry topoint to the correct partition. However, unless the technical details are the same you risk corruption of the sysetm on a boot. If the entry is correct except for the hard drive number, e.g. hd0 became hd1 because another disk was added, but nothing else changed you might be ok. YMMV. set root='hd0,msdos2' --> set root='hd1,msdos2' However, using grub-mkcfg would be safer from within the OS. This is one area where one really needs to RTM!

sample copy of /boot/grub2/grub.cfg file (owned completely by root)

# # 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 ### 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 } if [ x$feature_default_font_path = xy ] ; then font=unicode else insmod part_msdos insmod ext2 set root='hd0,msdos2' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 --hint='hd0,msdos2' 0145a9fd-da51-4d7a-9e5a-424651c15925 else search --no-floppy --fs-uuid --set=root 0145a9fd-da51-4d7a-9e5a-424651c15925 fi font="/usr/share/grub2/unicode.pf2" fi if loadfont $font ; then set gfxmode=auto load_video insmod gfxterm set locale_dir=$prefix/locale set lang=en_US insmod gettext fi terminal_output gfxterm insmod part_msdos insmod ext2 set root='hd0,msdos2' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 --hint='hd0,msdos2' 0145a9fd-da51-4d7a-9e5a-424651c15925 else search --no-floppy --fs-uuid --set=root 0145a9fd-da51-4d7a-9e5a-424651c15925 fi insmod gfxmenu loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans-Bold14.pf2 loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans10.pf2 loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans12.pf2 loadfont ($root)/boot/grub2/themes/openSUSE/ascii.pf2 insmod png set theme=($root)/boot/grub2/themes/openSUSE/theme.txt export theme if [ x${boot_once} = xtrue ]; then set timeout=0 elif sleep --interruptible 0 ; then set timeout=8 fi ### END /etc/grub.d/00_header ### ### BEGIN /etc/grub.d/10_linux ### menuentry 'openSUSE 13.1' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-0145a9fd-da51-4d7a-9e5a-424651c15925' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod ext2 set root='hd0,msdos2' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 --hint='hd0,msdos2' 0145a9fd-da51-4d7a-9e5a-424651c15925 else search --no-floppy --fs-uuid --set=root 0145a9fd-da51-4d7a-9e5a-424651c15925 fi echo 'Loading Linux 3.11.10-29-desktop ...' linux /boot/vmlinuz-3.11.10-29-desktop root=UUID=0145a9fd-da51-4d7a-9e5a-424651c15925 video=1024x768 resume=/dev/disk/by-id/ata-ST2000DM001-1CH164_Z1F3VFP3-part1 splash=silent quiet showopts echo 'Loading initial ramdisk ...' initrd /boot/initrd-3.11.10-29-desktop } submenu 'Advanced options for openSUSE 13.1' $menuentry_id_option 'gnulinux-advanced-0145a9fd-da51-4d7a-9e5a-424651c15925' { menuentry 'openSUSE 13.1, with Linux 3.11.10-29-desktop' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.11.10-29-desktop-advanced-0145a9fd-da51-4d7a-9e5a-424651c15925' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod ext2 set root='hd0,msdos2' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 --hint='hd0,msdos2' 0145a9fd-da51-4d7a-9e5a-424651c15925 else search --no-floppy --fs-uuid --set=root 0145a9fd-da51-4d7a-9e5a-424651c15925 fi echo 'Loading Linux 3.11.10-29-desktop ...' linux /boot/vmlinuz-3.11.10-29-desktop root=UUID=0145a9fd-da51-4d7a-9e5a-424651c15925 video=1024x768 resume=/dev/disk/by-id/ata-ST2000DM001-1CH164_Z1F3VFP3-part1 splash=silent quiet showopts echo 'Loading initial ramdisk ...' initrd /boot/initrd-3.11.10-29-desktop } menuentry 'openSUSE 13.1, with Linux 3.11.10-29-desktop (recovery mode)' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.11.10-29-desktop-recovery-0145a9fd-da51-4d7a-9e5a-424651c15925' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod ext2 set root='hd0,msdos2' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 --hint='hd0,msdos2' 0145a9fd-da51-4d7a-9e5a-424651c15925 else search --no-floppy --fs-uuid --set=root 0145a9fd-da51-4d7a-9e5a-424651c15925 fi echo 'Loading Linux 3.11.10-29-desktop ...' linux /boot/vmlinuz-3.11.10-29-desktop root=UUID=0145a9fd-da51-4d7a-9e5a-424651c15925 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe echo 'Loading initial ramdisk ...' initrd /boot/initrd-3.11.10-29-desktop } menuentry 'openSUSE 13.1, with Linux 3.11.10-25-desktop' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.11.10-25-desktop-advanced-0145a9fd-da51-4d7a-9e5a-424651c15925' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod ext2 set root='hd0,msdos2' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 --hint='hd0,msdos2' 0145a9fd-da51-4d7a-9e5a-424651c15925 else search --no-floppy --fs-uuid --set=root 0145a9fd-da51-4d7a-9e5a-424651c15925 fi echo 'Loading Linux 3.11.10-25-desktop ...' linux /boot/vmlinuz-3.11.10-25-desktop root=UUID=0145a9fd-da51-4d7a-9e5a-424651c15925 video=1024x768 resume=/dev/disk/by-id/ata-ST2000DM001-1CH164_Z1F3VFP3-part1 splash=silent quiet showopts echo 'Loading initial ramdisk ...' initrd /boot/initrd-3.11.10-25-desktop } menuentry 'openSUSE 13.1, with Linux 3.11.10-25-desktop (recovery mode)' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.11.10-25-desktop-recovery-0145a9fd-da51-4d7a-9e5a-424651c15925' { load_video set gfxpayload=keep insmod gzio insmod part_msdos insmod ext2 set root='hd0,msdos2' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 --hint='hd0,msdos2' 0145a9fd-da51-4d7a-9e5a-424651c15925 else search --no-floppy --fs-uuid --set=root 0145a9fd-da51-4d7a-9e5a-424651c15925 fi echo 'Loading Linux 3.11.10-25-desktop ...' linux /boot/vmlinuz-3.11.10-25-desktop root=UUID=0145a9fd-da51-4d7a-9e5a-424651c15925 showopts apm=off noresume edd=off powersaved=off nohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe echo 'Loading initial ramdisk ...' initrd /boot/initrd-3.11.10-25-desktop } } ### END /etc/grub.d/10_linux ### ### BEGIN /etc/grub.d/20_linux_xen ### ### END /etc/grub.d/20_linux_xen ### ### BEGIN /etc/grub.d/20_memtest86+ ### ### END /etc/grub.d/20_memtest86+ ### ### BEGIN /etc/grub.d/20_ppc_terminfo ### ### END /etc/grub.d/20_ppc_terminfo ### ### BEGIN /etc/grub.d/30_os-prober ### ### END /etc/grub.d/30_os-prober ### ### 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 ### ### BEGIN /etc/grub.d/90_persistent ### ### END /etc/grub.d/90_persistent ###

SEARCH and Navigation TOOL
Google     select a domain to search or visit.
(use back key to return )

johnmeister.com/jeep/sj

FULL SIZE JEEPS
JeepMeister
"Jeep is America's
only real sports car."
-Enzo Ferrari
JohnMeister.com- fotos LinuxMeister- CS
MeisterTech- Diesels FotoMeister.us- fotos
BibleTech- Bible Overview search the the internet
Everett weather - Seattle traffic - pollen count -
NEWS: BBC: Middle East - Israel - Spiegel
NASB/KJV/ES/D - SE Asian Missions - jihad - persecution info
e-books by john:

AMSOIL product guide,
AMSOIL web, or 1-800-956-5695
use customer #283461

Amsoil dealer since 1983

CAMERAS: Nikon Lumix Canon DSLRs Lenses
Computers: Toshiba Toughbook Apple Dell
BOOKS: Auto Repair Diesels BioDiesel
PARTS: Wagoneer J-truck Benz VW
books and computers


SJ - 1962-1991

XJ - 1984-2001

WJ - 1999-2004

KJ - 2002-2007

WK - 2005-2010

Find the recommended
AMSOIL synthetics
for your Jeep

CJ-10A - 1984-1986

Jeepsters

MJ - 1984-1992

Willys - 1946-1965

Other Jeeps (FC)