manually updating a grub.cfg

I need to manually update grub (I’ve copied my btrfs / paritition caused it lacks space to new location ) and in the old grub I’ve definned that partition by UUID but right now I mount it by the label so how do I need to change my grub accordingly to that fact. I’ve already changed ( I’ve two system installed basic opensuse on ext4 parition /dev/sda9 and tumbleweed on /dev/sda11).

 #
# 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,msdos9'
if  x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9'  082369d2-95a9-4c8d-bc97-da82fa0cfc24
else
  search --no-floppy --fs-uuid --set=root 082369d2-95a9-4c8d-bc97-da82fa0cfc24
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=POSIX
  insmod gettext
fi
terminal_output gfxterm
insmod part_msdos
insmod ext2
set root='hd0,msdos9'
if  x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9'  082369d2-95a9-4c8d-bc97-da82fa0cfc24
else
  search --no-floppy --fs-uuid --set=root 082369d2-95a9-4c8d-bc97-da82fa0cfc24
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-082369d2-95a9-4c8d-bc97-da82fa0cfc24' {
    load_video
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos11'
    if  x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos11 --hint-efi=hd0,msdos11 --hint-baremetal=ahci0,msdos11 --hint='hd0,msdos11'  082369d2-95a9-4c8d-bc97-da82fa0cfc24
    else
      search --no-floppy --fs-uuid --set=root 082369d2-95a9-4c8d-bc97-da82fa0cfc24
    fi
    echo    'Loading Linux 3.14.0-23.gfa168d7-desktop ...'
    linux    /boot/vmlinuz-3.14.0-23.gfa168d7-desktop root=UUID=082369d2-95a9-4c8d-bc97-da82fa0cfc24   quiet quiet resume=/dev/disk/by-id/ata-WDC_WD7500BPKT-00PK4T0_WD-WXF1E32MVUC9-part5 splash=silent quiet showopts
    echo    'Loading initial ramdisk ...'
    initrd    /boot/initrd-3.14.0-23.gfa168d7-desktop
}
submenu 'Advanced options for openSUSE 13.1' $menuentry_id_option 'gnulinux-advanced-082369d2-95a9-4c8d-bc97-da82fa0cfc24' {
    menuentry 'openSUSE 13.1, with Linux 3.14.0-23.gfa168d7-desktop' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.14.0-23.gfa168d7-desktop-advanced-082369d2-95a9-4c8d-bc97-da82fa0cfc24' {
        load_video
        insmod gzio
        insmod part_msdos
        insmod btrfs
        set root='hd0,msdos11'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos11 --hint-efi=hd0,msdos11 --hint-baremetal=ahci0,msdos11 --hint='hd0,msdos11'  082369d2-95a9-4c8d-bc97-da82fa0cfc24
        else
          search --no-floppy --fs-uuid --set=root 082369d2-95a9-4c8d-bc97-da82fa0cfc24
        fi
        echo    'Loading Linux 3.14.0-23.gfa168d7-desktop ...'
        linux    /boot/vmlinuz-3.14.0-23.gfa168d7-desktop root=LABEL=suse1-copy   quiet quiet resume=/dev/disk/by-id/ata-WDC_WD7500BPKT-00PK4T0_WD-WXF1E32MVUC9-part5 splash=silent quiet showopts
        echo    'Loading initial ramdisk ...'
        initrd    /boot/initrd-3.14.0-23.gfa168d7-desktop
    }
    menuentry 'openSUSE 13.1, with Linux 3.14.0-23.gfa168d7-desktop (recovery mode)' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.14.0-23.gfa168d7-desktop-recovery-082369d2-95a9-4c8d-bc97-da82fa0cfc24' {
        load_video
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos11'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos11 --hint-efi=hd0,msdos11 --hint-baremetal=ahci0,msdos11 --hint='hd0,msdos11'  082369d2-95a9-4c8d-bc97-da82fa0cfc24
        else
          search --no-floppy --fs-uuid --set=root 082369d2-95a9-4c8d-bc97-da82fa0cfc24
        fi
        echo    'Loading Linux 3.14.0-23.gfa168d7-desktop ...'
        linux    /boot/vmlinuz-3.14.0-23.gfa168d7-desktop root=LABEL=suse1-copy  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.14.0-23.gfa168d7-desktop
    }
    menuentry 'openSUSE 13.1, with Linux 3.11.10-11-desktop' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.11.10-11-desktop-advanced-082369d2-95a9-4c8d-bc97-da82fa0cfc24' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos9'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9'  082369d2-95a9-4c8d-bc97-da82fa0cfc24
        else
          search --no-floppy --fs-uuid --set=root 082369d2-95a9-4c8d-bc97-da82fa0cfc24
        fi
        echo    'Loading Linux 3.11.10-11-desktop ...'
        linux    /boot/vmlinuz-3.11.10-11-desktop root=UUID=082369d2-95a9-4c8d-bc97-da82fa0cfc24   quiet quiet resume=/dev/disk/by-id/ata-WDC_WD7500BPKT-00PK4T0_WD-WXF1E32MVUC9-part5 splash=silent quiet showopts
        echo    'Loading initial ramdisk ...'
        initrd    /boot/initrd-3.11.10-11-desktop
    }
    menuentry 'openSUSE 13.1, with Linux 3.11.10-11-desktop (recovery mode)' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.11.10-11-desktop-recovery-082369d2-95a9-4c8d-bc97-da82fa0cfc24' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos9'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9'  082369d2-95a9-4c8d-bc97-da82fa0cfc24
        else
          search --no-floppy --fs-uuid --set=root 082369d2-95a9-4c8d-bc97-da82fa0cfc24
        fi
        echo    'Loading Linux 3.11.10-11-desktop ...'
        linux    /boot/vmlinuz-3.11.10-11-desktop root=UUID=082369d2-95a9-4c8d-bc97-da82fa0cfc24  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-11-desktop
    }
    menuentry 'openSUSE 13.1, with Linux 3.11.10-7-desktop' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.11.10-7-desktop-advanced-082369d2-95a9-4c8d-bc97-da82fa0cfc24' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos9'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9'  082369d2-95a9-4c8d-bc97-da82fa0cfc24
        else
          search --no-floppy --fs-uuid --set=root 082369d2-95a9-4c8d-bc97-da82fa0cfc24
        fi
        echo    'Loading Linux 3.11.10-7-desktop ...'
        linux    /boot/vmlinuz-3.11.10-7-desktop root=UUID=082369d2-95a9-4c8d-bc97-da82fa0cfc24   quiet quiet resume=/dev/disk/by-id/ata-WDC_WD7500BPKT-00PK4T0_WD-WXF1E32MVUC9-part5 splash=silent quiet showopts
        echo    'Loading initial ramdisk ...'
        initrd    /boot/initrd-3.11.10-7-desktop
    }
    menuentry 'openSUSE 13.1, with Linux 3.11.10-7-desktop (recovery mode)' --class 'opensuse-13-1' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.11.10-7-desktop-recovery-082369d2-95a9-4c8d-bc97-da82fa0cfc24' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos9'
        if  x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9'  082369d2-95a9-4c8d-bc97-da82fa0cfc24
        else
          search --no-floppy --fs-uuid --set=root 082369d2-95a9-4c8d-bc97-da82fa0cfc24
        fi
        echo    'Loading Linux 3.11.10-7-desktop ...'
        linux    /boot/vmlinuz-3.11.10-7-desktop root=UUID=082369d2-95a9-4c8d-bc97-da82fa0cfc24  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-7-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+ ###
menuentry 'openSUSE 13.1 Memtest' --class opensuse --class memtest86 --class gnu --class tools $menuentry_id_option 'memtest-082369d2-95a9-4c8d-bc97-da82fa0cfc24' {
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos9'
    if  x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9'  082369d2-95a9-4c8d-bc97-da82fa0cfc24
    else
      search --no-floppy --fs-uuid --set=root 082369d2-95a9-4c8d-bc97-da82fa0cfc24
    fi
    echo    'Loading memtest ...'
    linux16    /boot/memtest.bin
}
### 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 ###
# 

and there’s another “side” question I don’t copy the the tumbleweed part I just tar it as backup ( but without .snapshots directory) and then untar it to hte new partition, COuld it be any problem ??

Hm, it is not clear to me what you did, but the first lines of the file you show do convey a serious message IMHO.

short brief : I need to create entry for the new btrfs parition definned by label ( I tried to edit the old one ) but maybe it’d be better to create a new one. initrd and vmlinuz are on that partition

<delete>

Made a mistake with my post…

TSU

so I get to resuce mode of that tumbleweed install and did update and it went well, it updated kernel to 3.14-30somethin…then I get back to 13.1 did

 grub2-mkconfig -o /boot/grub2/grub.cfg

 

but it didn’t somehow noticed that new kernel, what can be the problem??

and I’ve checked it I’ve the tumbleweed root parititon mounted (it’s on /dev/sda11 )

 /run/media/root/suse1-copy/boot # ls
System.map-3.11.10-11-desktop          grub2                              symvers-3.11.10-11-desktop.gz           vmlinux-3.14.4-30.gbebeb6f-desktop.gz
System.map-3.14.4-30.gbebeb6f-desktop  initrd                             symvers-3.14.4-30.gbebeb6f-desktop.gz   vmlinuz
config-3.11.10-11-desktop              initrd-3.11.10-11-desktop          sysctl.conf-3.11.10-11-desktop          vmlinuz-3.11.10-11-desktop
config-3.14.4-30.gbebeb6f-desktop      initrd-3.14.0-23.gfa168d7-desktop  sysctl.conf-3.14.4-30.gbebeb6f-desktop  vmlinuz-3.14.0-23.gfa168d7-desktop
do_purge_kernels                       initrd-3.14.4-30.gbebeb6f-desktop  vmlinux-3.11.10-11-desktop.gz           vmlinuz-3.14.4-30.gbebeb6f-desktop

  

so why won’t grub2-mkconfig updated that grub accordingly ??

Skimming the code in /etc/grub.d/10_linux (which is referenced indirectly in grub.cfg), it looks like it doesn’t provide any options for describing paths, only one method is implemented.

AFAIK and based on my own experience implementing changes to how the grub menu displays, you can implement changes manually to grub.cfg (carefully and at your peril) and of course then run grub2-mkconfig as you described to implement, but those changes will be lost whenever there is a kernel update.

My current solution has been to simply script the changes to grub.cfg and re-run the script after any kernel update.
AFAICSee the alternative is to understand how to do major surgery in /etct/grub.d/10_linux

I suppose in your case the question might be if you need your custom path more than once. I assume that the 10_linux code should be able to detect and create a menu item automatically using its default method to describe the path.

If you want to see what I’ve done you can install the script I created for your distro version
http://en.opensuse.org/User:Tsu2/12.3/Modified_GRUB_Menu

TSU

No.
Running grub2-mkconfig will in fact overwrite your changes to grub.cfg.
So DON’T run it when making manual changes to grub.cfg. But it will be run on kernel updates automatically as you mention, and overwriting your changes.

Btw, you can add your own entries to /boot/grub2/custom.cfg (create the file if it doesn’t exist), this will never get overwritten by the system.

You’re right, Don’t know what I could have been thinking, the command switch “-o” clearly outputs to grub.cfg which overwrites.

:\

TSU

What is wrong with standard grub menu? Why using UUID does not work?

In any case - you can always create /boot/grub2/custom.cfg and put any contents there. So just edit this file and place any menu entry you need there. This file is automatically sourced at startup and any menu entry defined there will be displayed.

I’ve some new issue, it’s rather theoretical question : I’ve recovered my tumbleweed filesystem on btrfs ( the snaphsots we’re to large). I’ve created new partition and untar the copy of that system there ( obviously /.snapshots wasn’t in that tar file). And as I updated that system it created grub.cfg (before it wasn’t on /root partition but on separate /boot partition). Simply I didn’t install it I just untar it and updated. But grub that is currently used was populated by clean install of 13.1 (ext4) and my question is how to override that grub by that “new” one.(cause for some reason although when I update grub2 on that 13.1 clean install, it didn’t detect that tumbleweed kernel). And in general what’s the rule of overriding cerating new grub files ( different distros, mutiple installs…) Should I care someway or just type

          grub2-mkconfig -o /boot/grub2/grub.cfg       

 

and it should be all done ??

Lets just imagine someone had an even more complicated and contrived setup than you, with say 6 different distros in different partitions. (maybe 2 different openSUSE, 2 Ubuntu and 2 Mint)

If say Mint 17 was the last installed, it will be your bootloader.
You should be able to boot to one of your openSUSE installs and then run:

grub2-mkconfig -o /boot/grub2/grub.cfg

then

grub2-install /dev/sda

Now openSUSE will be in control
And you should be able to boot Mint or Ubuntu from the openSUSE grub menu too

This assumes you are not using a EFI machine. If you are then the target for the grub2-install will be your boot efi partition

Mint and Ubuntu use an alias to write the grub config and install, you will probably be familiar with them. I quite like them because they are easier to remember.

sudo update-grub
sudo grub-install /dev/sda

and if grub is installed/updated so I don’t need to do that

 grub2-install /dev/sda

will it matter?? And install grub on dev/sda2 (my extened part where I’ve all the /linux paritions, on /dev/sda1 there’s data part)
So now should I do

 grub2-install /dev/sda2 

, or just on /dev/sda and it’ll be alright ?

You might need to make that:


# grub2-install --force /dev/sda2

You will probably get an error message without the “–force”.