Results 1 to 6 of 6

Thread: Grub Problem

  1. #1
    Join Date
    Apr 2008
    Location
    New York
    Beans
    67
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Grub Problem

    I tried to modify grub to change the names of the menu entries, but seemed to have made a mess. Whenever I run grub-update, it always gives me an error

    Code:
    /etc/grub.d/40_custom: 22: /etc/grub.d/40_custom: function: not found
    /etc/grub.d/40_custom: 25: /etc/grub.d/40_custom: save_env: not found
    /etc/grub.d/40_custom: 27: /etc/grub.d/40_custom: Syntax error: "}" unexpected
    The 40_custom and /boot/grub/grub.cfg are now the same file. How do I restore the 40_custom to its original and change the boot entry string to whatever I want? Thanks for any help.

  2. #2
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Grub Problem

    Change the 40_custom file to contain on the following. Save the file and run update-grub as root.
    #!/bin/sh
    exec tail -n +3 $0
    # 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.
    I recommend you install Grub Customizer to make your changes. It is a GUI app that allows quite a few customizations. Click the "Customizer" link in my signature line.
    Back to Xorg...

    Retired.

  3. #3
    Join Date
    Jan 2011
    Beans
    1,151

    Re: Grub Problem

    Quote Originally Posted by Code9 View Post
    I tried to modify grub to change the names of the menu entries, but seemed to have made a mess. Whenever I run grub-update, it always gives me an error

    Code:
    /etc/grub.d/40_custom: 22: /etc/grub.d/40_custom: function: not found
    /etc/grub.d/40_custom: 25: /etc/grub.d/40_custom: save_env: not found
    /etc/grub.d/40_custom: 27: /etc/grub.d/40_custom: Syntax error: "}" unexpected
    The 40_custom and /boot/grub/grub.cfg are now the same file. How do I restore the 40_custom to its original and change the boot entry string to whatever I want? Thanks for any help.
    its orginal state should be disabled unless someone changed that

    Code:
    sudo chmod -x /etc/grub.d/40_custom
    just print the contents of the file for a forum member to debug that script

    or go to here for details

    https://help.ubuntu.com/community/Grub2/CustomMenus
    (\ /)
    (O.o)
    (> <)
    This is Bunny. Copy Bunny into your signature to help him on his way to world domination.

  4. #4
    Join Date
    Apr 2008
    Location
    New York
    Beans
    67
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Grub Problem

    Quote Originally Posted by drs305 View Post
    Change the 40_custom file to contain on the following. Save the file and run update-grub as root.


    I recommend you install Grub Customizer to make your changes. It is a GUI app that allows quite a few customizations. Click the "Customizer" link in my signature line.
    That did the trick. I appreciate the GUI solution, but I am trying my best to stick with purely CLI solutions. I haven't used Linux in a while.

    Quote Originally Posted by idoitprone View Post
    its orginal state should be disabled unless someone changed that

    Code:
    sudo chmod -x /etc/grub.d/40_custom
    just print the contents of the file for a forum member to debug that script

    or go to here for details

    https://help.ubuntu.com/community/Grub2/CustomMenus
    CHMOD changes the permissions of the file right? I did a cp and overwrote the original 40_custom, so that's why it was allowed. I will post the contents anyway, just in case it is not optimal. Thanks for looking at it

    Code:
    #
    # DO NOT EDIT THIS FILE
    #
    # It is automatically generated by grub-mkconfig using templates
    # from /etc/grub.d and settings from /etc/default/grub
    #
    
    
    
    #!/bin/sh
    exec tail -n +3 $0
    # 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.
    
    ### BEGIN /etc/grub.d/00_header ###
    if [ -s $prefix/grubenv ]; then
      set have_grubenv=true
      load_env
    fi
    set default="0"
    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 recordfail {
      set recordfail=1
      if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
    }
    
    function load_video {
      insmod vbe
      insmod vga
      insmod video_bochs
      insmod video_cirrus
    }
    
    insmod part_msdos
    insmod ext2
    set root='(hd1,msdos5)'
    search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
    if loadfont /usr/share/grub/unicode.pf2 ; then
      set gfxmode=auto
      load_video
      insmod gfxterm
      insmod part_msdos
      insmod ext2
      set root='(hd1,msdos5)'
      search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
      set locale_dir=($root)/boot/grub/locale
      set lang=en_US
      insmod gettext
    fi
    terminal_output gfxterm
    if [ "${recordfail}" = 1 ]; then
      set timeout=-1
    else
      set timeout=10
    fi
    ### END /etc/grub.d/00_header ###
    
    ### BEGIN /etc/grub.d/05_debian_theme ###
    set menu_color_normal=white/black
    set menu_color_highlight=black/light-gray
    if background_color 44,0,30; then
      clear
    fi
    ### END /etc/grub.d/05_debian_theme ###
    
    ### BEGIN /etc/grub.d/10_linux ###
    function gfxmode {
    	set gfxpayload="${1}"
    	if [ "${1}" = "keep" ]; then
    		set vt_handoff=vt.handoff=7
    	else
    		set vt_handoff=
    	fi
    }
    if [ "${recordfail}" != 1 ]; then
      if [ -e ${prefix}/gfxblacklist.txt ]; then
        if hwmatch ${prefix}/gfxblacklist.txt 3; then
          if [ ${match} = 0 ]; then
            set linux_gfx_mode=keep
          else
            set linux_gfx_mode=text
          fi
        else
          set linux_gfx_mode=text
        fi
      else
        set linux_gfx_mode=keep
      fi
    else
      set linux_gfx_mode=text
    fi
    export linux_gfx_mode
    if [ "${linux_gfx_mode}" != "text" ]; then load_video; fi
    menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os {
    	recordfail
    	gfxmode $linux_gfx_mode
    	insmod gzio
    	insmod part_msdos
    	insmod ext2
    	set root='(hd1,msdos5)'
    	search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
    	linux	/boot/vmlinuz-3.2.0-24-generic root=UUID=8bcdf389-deba-479e-a678-17fbfc7d6626 ro   quiet splash $vt_handoff
    	initrd	/boot/initrd.img-3.2.0-24-generic
    }
    menuentry 'Ubuntu (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
    	recordfail
    	insmod gzio
    	insmod part_msdos
    	insmod ext2
    	set root='(hd1,msdos5)'
    	search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
    	echo	'Loading Linux 3.2.0-24-generic ...'
    	linux	/boot/vmlinuz-3.2.0-24-generic root=UUID=8bcdf389-deba-479e-a678-17fbfc7d6626 ro recovery nomodeset 
    	echo	'Loading initial ramdisk ...'
    	initrd	/boot/initrd.img-3.2.0-24-generic
    }
    
    ### 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 "Memory test (memtest86+)" {
    	insmod part_msdos
    	insmod ext2
    	set root='(hd1,msdos5)'
    	search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
    	linux16	/boot/memtest86+.bin
    }
    menuentry "Memory test (memtest86+, serial console 115200)" {
    	insmod part_msdos
    	insmod ext2
    	set root='(hd1,msdos5)'
    	search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
    	linux16	/boot/memtest86+.bin console=ttyS0,115200n8
    }
    ### END /etc/grub.d/20_memtest86+ ###
    
    ### BEGIN /etc/grub.d/30_os-prober ###
    menuentry "Windows 7" --class windows --class os {
    	insmod part_msdos
    	insmod ntfs
    	set root='(hd0,msdos1)'
    	search --no-floppy --fs-uuid --set=root EC5A15F45A15BBF0
    	chainloader +1
    }
    menuentry "Gentoo Linux" --class gnu-linux --class gnu --class os {
    	insmod part_msdos
    	insmod ext2
    	set root='(hd0,msdos3)'
    	search --no-floppy --fs-uuid --set=root 43bcd58b-d7bd-4e01-b432-41dae537f1da
    	linux /boot/kernel-genkernel-x86-3.2.1-gentoo-r2 real_root=/dev/sda3
    	initrd /boot/initramfs-genkernel-x86-3.2.1-gentoo-r2
    }
    menuentry "Windows 7" --class windows --class os {
    	insmod part_msdos
    	insmod ntfs
    	set root='(hd1,msdos1)'
    	search --no-floppy --fs-uuid --set=root 705269035268CF80
    	chainloader +1
    }
    ### 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  $prefix/custom.cfg ]; then
      source $prefix/custom.cfg;
    fi
    ### END /etc/grub.d/41_custom ###

  5. #5
    Join Date
    Jan 2011
    Beans
    1,151

    Re: Grub Problem

    Quote Originally Posted by Code9 View Post
    That did the trick. I appreciate the GUI solution, but I am trying my best to stick with purely CLI solutions. I haven't used Linux in a while.



    CHMOD changes the permissions of the file right? I did a cp and overwrote the original 40_custom, so that's why it was allowed. I will post the contents anyway, just in case it is not optimal. Thanks for looking at it

    Code:
    #
    # DO NOT EDIT THIS FILE
    #
    # It is automatically generated by grub-mkconfig using templates
    # from /etc/grub.d and settings from /etc/default/grub
    #
    
    
    
    #!/bin/sh
    exec tail -n +3 $0
    # 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.
    
    ### BEGIN /etc/grub.d/00_header ###
    if [ -s $prefix/grubenv ]; then
      set have_grubenv=true
      load_env
    fi
    set default="0"
    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 recordfail {
      set recordfail=1
      if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
    }
    
    function load_video {
      insmod vbe
      insmod vga
      insmod video_bochs
      insmod video_cirrus
    }
    
    insmod part_msdos
    insmod ext2
    set root='(hd1,msdos5)'
    search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
    if loadfont /usr/share/grub/unicode.pf2 ; then
      set gfxmode=auto
      load_video
      insmod gfxterm
      insmod part_msdos
      insmod ext2
      set root='(hd1,msdos5)'
      search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
      set locale_dir=($root)/boot/grub/locale
      set lang=en_US
      insmod gettext
    fi
    terminal_output gfxterm
    if [ "${recordfail}" = 1 ]; then
      set timeout=-1
    else
      set timeout=10
    fi
    ### END /etc/grub.d/00_header ###
    
    ### BEGIN /etc/grub.d/05_debian_theme ###
    set menu_color_normal=white/black
    set menu_color_highlight=black/light-gray
    if background_color 44,0,30; then
      clear
    fi
    ### END /etc/grub.d/05_debian_theme ###
    
    ### BEGIN /etc/grub.d/10_linux ###
    function gfxmode {
        set gfxpayload="${1}"
        if [ "${1}" = "keep" ]; then
            set vt_handoff=vt.handoff=7
        else
            set vt_handoff=
        fi
    }
    if [ "${recordfail}" != 1 ]; then
      if [ -e ${prefix}/gfxblacklist.txt ]; then
        if hwmatch ${prefix}/gfxblacklist.txt 3; then
          if [ ${match} = 0 ]; then
            set linux_gfx_mode=keep
          else
            set linux_gfx_mode=text
          fi
        else
          set linux_gfx_mode=text
        fi
      else
        set linux_gfx_mode=keep
      fi
    else
      set linux_gfx_mode=text
    fi
    export linux_gfx_mode
    if [ "${linux_gfx_mode}" != "text" ]; then load_video; fi
    menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os {
        recordfail
        gfxmode $linux_gfx_mode
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd1,msdos5)'
        search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
        linux    /boot/vmlinuz-3.2.0-24-generic root=UUID=8bcdf389-deba-479e-a678-17fbfc7d6626 ro   quiet splash $vt_handoff
        initrd    /boot/initrd.img-3.2.0-24-generic
    }
    menuentry 'Ubuntu (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
        recordfail
        insmod gzio
        insmod part_msdos
        insmod ext2
        set root='(hd1,msdos5)'
        search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
        echo    'Loading Linux 3.2.0-24-generic ...'
        linux    /boot/vmlinuz-3.2.0-24-generic root=UUID=8bcdf389-deba-479e-a678-17fbfc7d6626 ro recovery nomodeset 
        echo    'Loading initial ramdisk ...'
        initrd    /boot/initrd.img-3.2.0-24-generic
    }
    
    ### 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 "Memory test (memtest86+)" {
        insmod part_msdos
        insmod ext2
        set root='(hd1,msdos5)'
        search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
        linux16    /boot/memtest86+.bin
    }
    menuentry "Memory test (memtest86+, serial console 115200)" {
        insmod part_msdos
        insmod ext2
        set root='(hd1,msdos5)'
        search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
        linux16    /boot/memtest86+.bin console=ttyS0,115200n8
    }
    ### END /etc/grub.d/20_memtest86+ ###
    
    ### BEGIN /etc/grub.d/30_os-prober ###
    menuentry "Windows 7" --class windows --class os {
        insmod part_msdos
        insmod ntfs
        set root='(hd0,msdos1)'
        search --no-floppy --fs-uuid --set=root EC5A15F45A15BBF0
        chainloader +1
    }
    menuentry "Gentoo Linux" --class gnu-linux --class gnu --class os {
        insmod part_msdos
        insmod ext2
        set root='(hd0,msdos3)'
        search --no-floppy --fs-uuid --set=root 43bcd58b-d7bd-4e01-b432-41dae537f1da
        linux /boot/kernel-genkernel-x86-3.2.1-gentoo-r2 real_root=/dev/sda3
        initrd /boot/initramfs-genkernel-x86-3.2.1-gentoo-r2
    }
    menuentry "Windows 7" --class windows --class os {
        insmod part_msdos
        insmod ntfs
        set root='(hd1,msdos1)'
        search --no-floppy --fs-uuid --set=root 705269035268CF80
        chainloader +1
    }
    ### 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  $prefix/custom.cfg ]; then
      source $prefix/custom.cfg;
    fi
    ### END /etc/grub.d/41_custom ###
    do what drs305 say to do

    what he said is basically the fix since you saved over 40_custom
    gksudo gedit /etc/grub.d/40_custom
    (\ /)
    (O.o)
    (> <)
    This is Bunny. Copy Bunny into your signature to help him on his way to world domination.

  6. #6
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Grub Problem

    #!/bin/sh
    exec tail -n +3 $0
    # 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.

    menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    gfxmode $linux_gfx_mode
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd1,msdos5)'
    search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
    linux /boot/vmlinuz-3.2.0-24-generic root=UUID=8bcdf389-deba-479e-a678-17fbfc7d6626 ro quiet splash $vt_handoff
    initrd /boot/initrd.img-3.2.0-24-generic
    }
    menuentry 'Ubuntu (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd1,msdos5)'
    search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
    echo 'Loading Linux 3.2.0-24-generic ...'
    linux /boot/vmlinuz-3.2.0-24-generic root=UUID=8bcdf389-deba-479e-a678-17fbfc7d6626 ro recovery nomodeset
    echo 'Loading initial ramdisk ...'
    initrd /boot/initrd.img-3.2.0-24-generic
    }

    menuentry "Windows 7" --class windows --class os {
    insmod part_msdos
    insmod ntfs
    set root='(hd0,msdos1)'
    search --no-floppy --fs-uuid --set=root EC5A15F45A15BBF0
    chainloader +1
    }
    menuentry "Gentoo Linux" --class gnu-linux --class gnu --class os {
    insmod part_msdos
    insmod ext2
    set root='(hd0,msdos3)'
    search --no-floppy --fs-uuid --set=root 43bcd58b-d7bd-4e01-b432-41dae537f1da
    linux /boot/kernel-genkernel-x86-3.2.1-gentoo-r2 real_root=/dev/sda3
    initrd /boot/initramfs-genkernel-x86-3.2.1-gentoo-r2
    }
    menuentry "Windows 7" --class windows --class os {
    insmod part_msdos
    insmod ntfs
    set root='(hd1,msdos1)'
    search --no-floppy --fs-uuid --set=root 705269035268CF80
    chainloader +1
    }
    The above is what you could have 40_custom look like. You can edit the items in bold without impacting anything but the title.

    If you want these items to appear first, rename the file 06_custom and make it executable.

    You can remove any of the items you don't want.

    For the Ubuntu items, if you always want it to boot the most current kernel, change the menuentry to:
    menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    gfxmode $linux_gfx_mode
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd1,msdos5)'
    search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
    linux /vmlinuz root=UUID=8bcdf389-deba-479e-a678-17fbfc7d6626 ro quiet splash $vt_handoff
    initrd /initrd.img
    }
    menuentry 'Ubuntu (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd1,msdos5)'
    search --no-floppy --fs-uuid --set=root 8bcdf389-deba-479e-a678-17fbfc7d6626
    echo 'Loading Linux 3.2.0-24-generic ...'
    linux /vmlinuz root=UUID=8bcdf389-deba-479e-a678-17fbfc7d6626 ro recovery nomodeset
    echo 'Loading initial ramdisk ...'
    initrd /initrd.img
    }
    It replaces the specific kernel/initrd references in /boot with the symlinks located in /.

    If you don't want the original items to appear you can make 10_linux unexecutable. For 30_os-prober, I'd turn if off in /etc/default/grub with GRUB_DISABLE_OS-PROBER="true" it you don't want duplicates.

    Another way to tweak the titles other than custom menus or Grub Customizer is to view my Tweaks link - but it's guaranteed to make your head hurt.
    Last edited by drs305; June 3rd, 2012 at 07:41 PM.
    Back to Xorg...

    Retired.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •