Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Editing tools for /boot/grub2/grub.cfg

  1. #1
    Join Date
    Jan 2010
    Location
    New Jersey, USA
    Posts
    84

    Default Editing tools for /boot/grub2/grub.cfg

    Most postings advise against editing grub.cfg
    I'd like to remove a couple options from the menu.

    Are there any good tools to do this instead of vi ??

    I see that line 185 is "menuentry 'openSUSE"
    and line 206 is "menuentry 'openSUSE"

    Could I just use vi to delete lines 185-205 ??

  2. #2
    Join Date
    Mar 2008
    Location
    Oz
    Posts
    11,731
    Blog Entries
    2

    Default Re: Editing tools for /boot/grub2/grub.cfg

    Quote Originally Posted by qawtbh View Post
    Most postings advise against editing grub.cfg
    I'd like to remove a couple options from the menu.

    Are there any good tools to do this instead of vi ??

    I see that line 185 is "menuentry 'openSUSE"
    and line 206 is "menuentry 'openSUSE"

    Could I just use vi to delete lines 185-205 ??
    That is not universal, for example mine has different code at those lines you quoted because I have added an entry via 40_custom. Have a look at the first six lines of the file. They indicate that mkconfig generates the file. So if you edit that bit out, it will be regenerated sooner or later. If you want to remove an entry, have a look in Yast Bootloader Tab = Options. But I don't know much about Grub, so other advice might arrive here (I hope).
    Leap 42.3 & 15.1 &KDE
    FYIs from the days of yore

  3. #3
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    15,589
    Blog Entries
    3

    Default Re: Editing tools for /boot/grub2/grub.cfg

    Quote Originally Posted by qawtbh View Post
    Most postings advise against editing grub.cfg
    I'd like to remove a couple options from the menu.
    The advice to not edit the file, is because it is automatically generated, and is regenerated on various events (such as a kernel update).

    Yes, you can remove options. But they will come back.

    The real trick would be for you to write a suitable "sed" script. Then, when needed, you can do:
    Code:
    cd /boot/grub2
    sed -f /path/to/sed/script grub.cfg > grub.cfg.new
    cp grub.cfg grub.cfg.old
    mv grub.cfg.new grub.cfg
    That's because you will have to do this edit frequently enough that you will want to automate it.

    Personally -- I put up with the lines that I don't need. I occasionally edit "grub.cfg" (using "vi") to make temporary changes. And, if I like the temporary changes, then I edit "/etc/default/grub" or "/etc/grub.d/40_custom" so that the changes I want will show up automatically.

    On a box without Windows, I turn off "probe for foreign OSs" (or whatever the option is), so that less menu entries are generated.
    openSUSE Leap 15.3; KDE Plasma 5.18.6;

  4. #4
    Join Date
    Jun 2008
    Location
    Yorkshire
    Posts
    390

    Default Re: Editing tools for /boot/grub2/grub.cfg

    I make all the files in /etc/grub.d/ non-executable except 00_header and 90_consistent. I then edit the entries in 90_consistent when I need to. It's a bit like the grub legacy menu.lst.
    I think most people here would disagree with me but I find it easier than wading through loads of lines when I've changed a kernel on one of the partitions. I find grub will often apply the wrong kernel entry to the wrong partition.
    Pete

  5. #5
    Join Date
    Sep 2012
    Posts
    6,960

    Default Re: Editing tools for /boot/grub2/grub.cfg

    Quote Originally Posted by peteh100 View Post
    I make all the files in /etc/grub.d/ non-executable
    Make sure to clean up after next grub2 update, those files reappear.

  6. #6
    Join Date
    Jun 2008
    Location
    Yorkshire
    Posts
    390

    Default Re: Editing tools for /boot/grub2/grub.cfg

    I have a short script I run every time I get a grub update.
    Pete

  7. #7
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    4,455

    Default Re: Editing tools for /boot/grub2/grub.cfg

    Quote Originally Posted by qawtbh View Post
    I see that line 185 is "menuentry 'openSUSE"
    and line 206 is "menuentry 'openSUSE"

    Could I just use vi to delete lines 185-205 ??
    Are you absolutely certain that, in /etc/grub.d/ there's absolutely only one definition which leads to the "menuentry" text "openSUSE"?
    Or, have you defined such a "menuentry" which the automatic scripts ignore and blithely generate a 2nd (default) "openSUSE" "menuentry" text?
    Maybe, given the current automation status, you should change your "openSUSE" "menuentry" text to something different: "my openSUSE" for example.

  8. #8
    Join Date
    Mar 2011
    Location
    suffolk, uk
    Posts
    41

    Default Re: Editing tools for /boot/grub2/grub.cfg

    I had a similar problem: grub listed openSuSE13.2 1st, then Leap42.1 2nd. I now wanted 42.2 1st.

    I read thru' a huge amount of documentation (most of it for Ubuntu which is inapplicable) but got totally stuck with:

    /etc/default/grub
    # If you change this file, run 'grub2-mkconfig -o /boot/grub2/grub.cfg' afterwards to update
    # /boot/grub2/grub.cfg.
    # Bash - 4.3.42 : wi grub2-mkconfig/grub2-mkconfig: usr/sbin/grub2-mkconfig /usr/share/man/man8/grub2-mkconfig.8.gz

    and the contents of:

    Bash - 4.3.42 : ls /etc/grub.d
    00_header* 20_linux_xen* 40_custom* 90_persistent*
    00_tuned* 20_memtest86+* 41_custom* 95_textmode*
    10_linux* 30_os-prober* 80_suse_btrfs_snapshot* README

    or the README file:

    "All executable files in this directory are processed in shell expansion order.

    00_*: Reserved for 00_header.
    10_*: Native boot entries.
    20_*: Third party apps (e.g. memtest86+).

    The number namespace in-between is configurable by system installer and/or
    administrator. For example, you can add an entry to boot another OS as
    01_otheros, 11_otheros, etc, depending on the position you want it to occupy in
    the menu; and then adjust the default setting via /etc/default/grub."

    Durr!

    Then I found nrickert's post:

    "If you want to remove an entry, have a look in Yast Bootloader Tab = Options. But I don't know much about Grub, so other advice might arrive here (I hope)".

    OK! Without much faith, I called up Yast, selected "Boot Loader" & "Edit Boot Disk Order". The existing choice was /dev/sda so I added /dev/sda11 (the partition for Leap42) underneath and, what do you know, I got what I wanted - Leap42 1st, SuSE 13.2 2nd.

    I haven't got round to it, but when I install Tumbleweed, I hope to make it 2nd & 13.2 3rd.

    Thanks nrickert!

    dmk
    From: dmk

    Running: Samsung RV511 - HD=596Gb / Mem=5.7Gb

  9. #9
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    29,469

    Default Re: Editing tools for /boot/grub2/grub.cfg

    @thebigming

    As you say, you have similar problem. Thus your post is NOT an additional remark to the problem here as mentioned in the title.

    This is really not a good way to advertize your problem to those that browse the forums for new problems/questions. They will miss your request and thus you will miss potential helpers.

    Please start a thread of your own with a title with keywords that will draw the attention of people that might be able to help you.

    Oh yes, and please in the future use CODE tags around copied/pasted computer text in a post. It is the # button in the tool bar of the post editor. When applicable copy/paste complete, that is including the prompt, the command, the output and the next prompt.

    Regards,
    Last edited by hcvv; 27-Apr-2017 at 01:59.
    Henk van Velden

  10. #10
    Join Date
    Mar 2008
    Location
    Phuket, Thailand
    Posts
    26,993
    Blog Entries
    40

    Default Re: Editing tools for /boot/grub2/grub.cfg

    As a generic response to the title in this thread and not to any specific user's problem, for editing grub2 I like to use the tool grub-customizer

    It is a graphical grub2 settings manager and I find it works well for me. No need with this GUI front end to dive into detailed configuration files.

    At this point in time user 'ecos' offers (ie packaged for openSUSE) version-4.0.6 for LEAP-42.1 and LEAP-42.2 (and also for Tumbleweed).

    I note for Tumbleweed a user "KAMiKAZOW" offers a version-5.0.6. I have not tried that version.
    .

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

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