Page 1 of 4 123 ... LastLast
Results 1 to 10 of 32

Thread: How do grub/ Ubuntu/ grub.cfg interact during boot ?

  1. #1
    Join Date
    Oct 2020
    Beans
    114

    How do grub/ Ubuntu/ grub.cfg interact during boot ?

    Please help me understand the relationship of files run during boot process.
    I do have SOME notion how each INDIVIDUAL file is configured and how it works.
    I do not need references to manuals.

    One of the "issues" is - how do you configure "grub2" - most tutorials are for plain "grub".



    I am trying to implement a simple change in "grub".


    Code:
    # GRUB_DEFAULT=3
    # use last menu selection
    GRUB_DEFAULT=saved
    GRUB_SAVEDEFAULT=true
    That did not work, so I did change the "timeout" to verify my method.


    Code:
    GRUB_HIDDEN_TIMEOUT=0
    GRUB_HIDDEN_TIMEOUT_QUIET=true
    GRUB_TIMEOUT=5[/SIZE]

    No go, the timeout actually changed to what appears some kind of default - 30 seconds.
    I must be changing wrong /etc/default/grub - how do I verify this?


    PS
    I do run

    update-grub after I make changes in /etc/default/grub
    and I see the changes





    Ubuntu 16.04.7
    Last edited by sisco311; October 23rd, 2020 at 11:27 PM. Reason: font size

  2. #2
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: How do grub/ Ubuntu/ grub.cfg interact during boot ?

    There is the manual and online resources.
    https://www.gnu.org/software/grub/index.html
    When I click on this in my new Firefox, it does not open, but just downloads it.
    Manual 2.04
    https://www.gnu.org/software/grub/manual/grub/grub.pdf

    What are you trying to do.
    In one case you are changing default boot order.
    And in other changing timeout.

    I tend to turn off a lot of grub and use 40_custom for my boot entries.

    Discussion of timeouts issue & recordfail:
    http://ubuntuforums.org/showthread.php?t=1717700
    Stop 30_custom from resetting timeout & style
    https://gist.github.com/LeahCim/9332432
    Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.

    How to: Create a Customized GRUB2 Screen that is Maintenance Free.- Cavsfan
    https://help.ubuntu.com/community/Ma...tomGrub2Screen
    https://www.gnu.org/software/grub/ma...-manual-config
    https://help.ubuntu.com/community/Grub2/CustomMenus
    http://ubuntuforums.org/showthread.php?t=2076205
    https://ubuntuforums.org/showthread....5#post13787835
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

  3. #3
    Join Date
    Jun 2010
    Location
    London, England
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: How do grub/ Ubuntu/ grub.cfg interact during boot ?

    As far as Ubuntu is concerned there is little difference between Grub and Grub2. Ubuntu used to use Grub 1.99 and then slowly switched over to Grub2 which was labelled as beta code for several releases. You will find duplicate files in Grub and Grub2 folders.

    update-grub is a Ubuntu shell script that runs grub-mkconfig. We find it at /usr/sbin/update-grub

    This is what the script reads on my machine

    #!/bin/sh
    set -e
    exec grub-mkconfig -o /boot/grub/grub.cfg "$@"
    It is exactly the same as the update-grub2 script. There is even a script called upgrade-from-grub-legacy. We find grub-mkconfig at /usr/sbin/grub-mkconfig. In the same folder there is grub-install which is a program not a script. In my notes from past attempts at getting a Ubuntu education I have written this: "grub-install copies Grub images into /boot/grub, and uses grub-setup to install Grub into the boot sector."

    I have a BIOS motherboard so I do not know of the changes (if any) made to install Grub on a UEFI motherboard. I know about boot partition and efi partition. The ability to install Grub code/images into either a boot partition (MBR) or an efi boot partition must come from how grub-install is programed

    Regards
    Last edited by grahammechanical; October 23rd, 2020 at 09:50 PM.
    It is a machine. It is more stupid than we are. It will not stop us from doing stupid things.
    Ubuntu user #33,200. Linux user #530,530


  4. #4
    Join Date
    Oct 2020
    Beans
    114

    Re: How do grub/ Ubuntu/ grub.cfg interact during boot ?

    Quote Originally Posted by grahammechanical View Post
    As far as Ubuntu is concerned there is little difference between Grub and Grub2. Ubuntu used to use Grub 1.99 and then slowly switched over to Grub2 which was labelled as beta code for several releases. You will find duplicate files in Grub and Grub2 folders.

    If you do not mind , let' settle this first.

    there is little difference between Grub and Grub2

    1. there is -
    /etc/default/grub exists but there is NO /etc/default/grub2

    a@a-desktop:~$ cat /etc/default/grub
    # If you change this file, run 'update-grub' afterwards to update
    # /boot/grub/grub.cfg.
    # For full documentation of the options in this file, see:
    # info -f grub -n 'Simple configuration'
    # temorary from default = 0

    GRUB_DEFAULT=3

    #GRUB_DEFAULT=saved # use last menu
    #GRUB_SAVEDEFAULT=true # save as default
    GRUB_HIDDEN_TIMEOUT=0
    GRUB_HIDDEN_TIMEOUT_QUIET=true
    GRUB_TIMEOUT=5
    GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
    #####GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
    GRUB_CMDLINE_LINUX=""

    # Uncomment to enable BadRAM filtering, modify to suit your needs
    # This works with Linux (no patch required) and with any kernel that obtains
    # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
    #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xe fefefef"

    # Uncomment to disable graphical terminal (grub-pc only)
    #GRUB_TERMINAL=console

    # The resolution used on graphical terminal
    # note that you can use only modes which your graphic card supports via VBE
    # you can see them in real GRUB with the command `vbeinfo'
    GRUB_GFXMODE=text ### 640x480

    # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
    #GRUB_DISABLE_LINUX_UUID=true

    # Uncomment to disable generation of recovery mode menu entries
    #GRUB_DISABLE_RECOVERY="true"

    # Uncomment to get a beep at grub start
    #GRUB_INIT_TUNE="480 440 1"


    a@a-desktop:~$ cat /etc/default/grub2
    cat: /etc/default/grub2: No such file or directory
    a@a-desktop:~$

    2. /etc/default/grub entries are used by /boot/grub/grub.cfg





    update-grub is a Ubuntu shell script that runs grub-mkconfig. We find it at /usr/sbin/update-grub

    This is what the script reads on my machine



    It is exactly the same as the update-grub2 script. There is even a script called upgrade-from-grub-legacy. We find grub-mkconfig at /usr/sbin/grub-mkconfig. In the same folder there is grub-install which is a program not a script. In my notes from past attempts at getting a Ubuntu education I have written this: "grub-install copies Grub images into /boot/grub, and uses grub-setup to install Grub into the boot sector."

    I have a BIOS motherboard so I do not know of the changes (if any) made to install Grub on a UEFI motherboard. I know about boot partition and efi partition. The ability to install Grub code/images into either a boot partition (MBR) or an efi boot partition must come from how grub-install is programed

    Regards
    To follow-up on original post

    The objective is to VERIFY that changing /etc/default/grub indeed changes "Ubuntu" file during boot. .
    I picked TWO options and neither one resulted in expected changes in boot process.

    The "question" is not WHAT options I used and why , but WHY it did not work.
    Simply repeated - I set the timeout to 5 seconds and my boot file runs "timeout of 30 seconds"

    Therefore the question is - WHERE is timeout of 30 second set - it is NOT in /etc/default/grub.

    In order to make an intelligent guess, I should know THE SEQUENCE of boot process files execution.

    Unfortunately I have not discover HOW grub, grub.cfg, UEFI etc interact - HENCE I ASKED.
    From past - this reply is pretty much in line with others - "I have no UEFI, so I dont not know..." is pretty much norm here.

    Hopefully my expectations from this forum are not to high,

    however, is it too much to ask to read the original post before answering / posting replies?
    If so - I have no choise but to repeat - please no more references to manuals.

  5. #5
    Join Date
    May 2014
    Location
    /home
    Beans
    10,943
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: How do grub/ Ubuntu/ grub.cfg interact during boot ?

    It must be set in one of the scripts in /etc/grub.d/ as there are some conditions that will cause a 30 second wait

  6. #6
    Join Date
    Jun 2010
    Location
    London, England
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: How do grub/ Ubuntu/ grub.cfg interact during boot ?

    Hopefully my expectations from this forum are not to high,
    If I tell you the answer your expectation might increase. That would lead to further disappointment. The answer is on page 18 of the Grub 2 manual under GRUB_TIMEOUT.

    ‘GRUB_TIMEOUT’
    Boot the default entry this many seconds after the menu is displayed, unless a key is pressed. The default is ‘5’. Set to ‘0’ to boot immediately without displaying the menu, or to ‘-1’ to wait indefinitely.
    I will not be replying to any further posts from you.
    It is a machine. It is more stupid than we are. It will not stop us from doing stupid things.
    Ubuntu user #33,200. Linux user #530,530


  7. #7
    Join Date
    Oct 2020
    Beans
    114

    Re: How do grub/ Ubuntu/ grub.cfg interact during boot ?

    Quote Originally Posted by jeremy31 View Post
    It must be set in one of the scripts in /etc/grub.d/ as there are some conditions that will cause a 30 second wait
    Yes, it "could" be in one of those scripts, BUT - since everybody likes manuals here - it is an option mentioned in "grub" manual.
    Unless these "helper scripts" are overriding the grub setting.
    Looks as there are about half a dozen of them. I'll check them.

    I am currently trying to answer myself - how does UEFI and grub relate.

  8. #8
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: How do grub/ Ubuntu/ grub.cfg interact during boot ?

    If you do not want to read the manual, you can read the output of the sudo update-grub or your grub.cfg.
    it is built from all the scripts which you do not normally edit and the settings that you normally can change in /etc/default/grub configuration file.

    On mine it is line 106, may vary based on version or settings:

    Code:
    if [ "${recordfail}" = 1 ] ; then
      set timeout=30
    That says if grub has any issues recordfail then it defaults to 30 seconds.

    And if you really want to understand grub, this now very long thread deals with many issues and how grub works.
    Posted above, but obviously not reviewed.
    https://ubuntuforums.org/showthread.php?t=2076205

    https://www.happyassassin.net/posts/...lly-work-then/
    https://superuser.com/questions/4960...boot-with-uefi
    https://www.zdnet.com/article/linux-on-your-laptop-heres-what-you-need-to-know-about-uefi-firmware/

    GRUB 2 - GRand Unified Bootloader has three main parts plus a boot loader installed to the MBR:

    1. /etc/default/grub - the file containing GRUB 2 menu settings.
    2. /etc/grub.d/ - the directory containing GRUB 2 menu creating scripts.And a place for totally custom entries 40_custom.
    3. /boot/grub/grub.cfg - the GRUB 2 configuration file, not editable.
    Original grub or now grub legacy used menu.lst for all of above in major sections. And you directly edited it, often leading to errors in booting.
    Last edited by oldfred; October 24th, 2020 at 04:08 AM.
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

  9. #9
    Join Date
    Oct 2020
    Beans
    114

    Re: How do grub/ Ubuntu/ grub.cfg interact during boot ?

    Quote Originally Posted by oldfred View Post
    If you do not want to read the manual, you can read the output of the sudo update-grub or your grub.cfg.
    it is built from all the scripts which you do not normally edit and the settings that you normally can change in /etc/default/grub configuration file.

    On mine it is line 106, may vary based on version or settings:

    Code:
    if [ "${recordfail}" = 1 ] ; then
      set timeout=30



    That says if grub has any issues recordfail then it defaults to 30 seconds.

    And if you really want to understand grub, this now very long thread deals with many issues and how grub works.
    Posted above, but obviously not reviewed.
    https://ubuntuforums.org/showthread.php?t=2076205

    https://www.happyassassin.net/posts/...lly-work-then/
    https://superuser.com/questions/4960...boot-with-uefi
    https://www.zdnet.com/article/linux-on-your-laptop-heres-what-you-need-to-know-about-uefi-firmware/



    Original grub or now grub legacy used menu.lst for all of above in major sections. And you directly edited it, often leading to errors in booting.
    I guess you and I have "failure to communicate " . You keep making refernces AFTER I asked not to.
    I am not sure why you cannot follow such simple request.


    Let me ask AGAIN and hopefully YOU will finally answer such simple question.

    Per your favorite , GNU grub manual, the timeout is set in "grub" .

    Please - just say YES or NO.


    If you manage that, MAYBE you and I can finally find out WHY my timeout is 30 seconds by analyzing OTHER files.

    AND in the process answering my original post too. Re: How do grub/ Ubuntu/ grub.cfg interact during boot ?-
    That would be very nice and productive since I have not found a "manual" on that - hence I posted my question here.

    Here is what I know so far

    1. During Ubuntu ISO install use GPT partition
    2. Install will create EFI boot partition etc.
    3. UEFI firmware reads such EFI partition

    ??????????????????


    Code:
    a@a-desktop:~$ cat /etc/default/grub
    # If you change this file, run 'update-grub' afterwards to update
    # /boot/grub/grub.cfg.
    # For full documentation of the options in this file, see:
    #   info -f grub -n 'Simple configuration'
    #  temporary from default = 0 
    
    GRUB_DEFAULT=3  
    
    #GRUB_DEFAULT=saved         # use last menu 
    #GRUB_SAVEDEFAULT=true      # save as default 
    GRUB_HIDDEN_TIMEOUT=0
    GRUB_HIDDEN_TIMEOUT_QUIET=true
    GRUB_TIMEOUT=5
    GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
    #####GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
    GRUB_CMDLINE_LINUX=""
    
    # Uncomment to enable BadRAM filtering, modify to suit your needs
    # This works with Linux (no patch required) and with any kernel that obtains
    # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
    #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
    
    # Uncomment to disable graphical terminal (grub-pc only)
    #GRUB_TERMINAL=console
    
    # The resolution used on graphical terminal
    # note that you can use only modes which your graphic card supports via VBE
    # you can see them in real GRUB with the command `vbeinfo'
    GRUB_GFXMODE=text   ###  640x480
    
    # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
    #GRUB_DISABLE_LINUX_UUID=true
    
    # Uncomment to disable generation of recovery mode menu entries
    #GRUB_DISABLE_RECOVERY="true"
    
    # Uncomment to get a beep at grub start
    #GRUB_INIT_TUNE="480 440 1"
    a@a-desktop:~$

  10. #10
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: How do grub/ Ubuntu/ grub.cfg interact during boot ?

    I have this in my old notes:
    Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
    And one user a long time ago posted this:
    Solved by editing the grub file. GRUB_HIDDEN_TIMEOUT_QUIET was =true. Setting it to =false gave me the boot options at startup and can now freely boot into windows or ubuntu.

    My grub.cfg, I typically run a small script to edit it with a new install to my preferred settings.
    And timeout is 3 seconds, I have to be quick if I want to change to a different grub entry.
    Code:
    fred@z170-focal-k:~$ cat /etc/default/grub 
    # If you change this file, run 'update-grub' afterwards to update 
    # /boot/grub/grub.cfg. 
    # For full documentation of the options in this file, see: 
    #   info -f grub -n 'Simple configuration' 
    
    GRUB_DEFAULT=0 
    GRUB_TIMEOUT_STYLE=menu 
    GRUB_TIMEOUT=3 
    #GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` 
    GRUB_CMDLINE_LINUX_DEFAULT="noplymouth" 
    GRUB_CMDLINE_LINUX="" 
    
    # Uncomment to enable BadRAM filtering, modify to suit your needs 
    # This works with Linux (no patch required) and with any kernel that obtains 
    # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) 
    #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" 
    
    # Uncomment to disable graphical terminal (grub-pc only) 
    #GRUB_TERMINAL=console 
    
    # The resolution used on graphical terminal 
    # note that you can use only modes which your graphic card supports via VBE 
    # you can see them in real GRUB with the command `vbeinfo' 
    #GRUB_GFXMODE=640x480 
    
    # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux 
    #GRUB_DISABLE_LINUX_UUID=true 
    
    # Uncomment to disable generation of recovery mode menu entries 
    #GRUB_DISABLE_RECOVERY="true" 
    
    # Uncomment to get a beep at grub start 
    #GRUB_INIT_TUNE="480 440 1" 
    GRUB_DISABLE_OS_PROBER=true 
    GRUB_DISTRIBUTOR=kubuntu
    
    
    With old BIOS, system powered on and read the code on the chip. Your basic choices were to choose a hard drive (if newer BIOS and drives with cable select) or jumper pins to choose which drive.
    With UEFI, you have both old BIOS as CSM and newer UEFI. It has more graphics and choices, but still loads from EEROM and using choices you have selected loads boot files from the ESP. You can have on each drive an ESP, so it uses the GUID of the partition to know which ESP to use. And then find file to load. That is end of UEFI and start of grub2 or any other boot loader you may use.

    I have set in UEFI to boot entry 0002 as default. Using the GUID/partUUID to find shimx64.efi
    Code:
    fred@z170-focal-k:~$ sudo efibootmgr -v 
    [sudo] password for fred:  
    BootCurrent: 0002 
    Timeout: 1 seconds 
    BootOrder: 0002,0000,0012,0013,0014,0005,0010,0001 
    Boot0000* ubuntu        HD(1,GPT,e58602b1-8fc4-46d1-991f-1d6511d9cdf4,0x800,0xff1b9)/File(\EFI\UBUNTU\SHIMX64.EFI) 
    Boot0001* bionic_18_04  VenHw(99e275e7-75a0-4b37-a2e6-c5385e6c00cb) 
    Boot0002* focal HD(1,GPT,c90a60b4-dbf4-4ab4-af2c-e2c7c03eeed1,0x800,0x100000)/File(\EFI\FOCAL\SHIMX64.EFI) 
    B
    
    Code:
    nvme0n1                          465.8G                                              
    ├─nvme0n1p1 /boot/efi  ESP_NVME    512M vfat   4954-C122                            c90a60b4-dbf4-4ab4-af2c-e2c7c03eeed1 
    ├─nvme0n1p2            focal_0    29.3G ext4   b913e1bc-6f08-4984-b653-9a604d95470a 043d0f2a-48f1-4bcd-8d8b-df02a242436c 
    ├─nvme0n1p3 /          focal_k    29.3G ext4   54029c4f-0cbe-413e-80ce-78a4995b0551 c4d96c9e-eebb-43e6-b1b0-7ece2306cfee 
    ├─nvme0n1p4                       29.3G ext4   dd5925b4-0250-4f6d-b59e-165f85365721 a4d9289a-6beb-4e64-b11e-65aba5ddb884 
    └─nvme0n1p5 /mnt/data  nvme_data 195.3G ext4   1a44f4af-6780-4bbd-ad0b-6385ed30830b dfd49ef3-46a6-4cad-8f64-7b1696fba6fb
    
    
    
    Shimx64.efi requires /EFI/ubuntu/grub.cfg which is a configfile into the full grub.cfg in your install.

    Code:
    fred@z170-focal-k:~$ sudo cat /boot/efi/EFI/ubuntu/grub.cfg 
    search.fs_uuid 54029c4f-0cbe-413e-80ce-78a4995b0551 root  
    set prefix=($root)'/boot/grub' 
    configfile $prefix/grub.cfg
    And that finds my full grub.cfg in my Ubuntu install.
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

Page 1 of 4 123 ... LastLast

Tags for this Thread

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
  •