1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
\input texinfo
@documentencoding UTF-8
@ifnottex
@paragraphindent 0
@end ifnottex
@titlepage
@title How to replace the default GRUB configuration file on a libreboot system
@end titlepage
@node Top
@top How to replace the default GRUB configuration file on a libreboot system
@menu
* How to replace the default GRUB configuration file on a libreboot system::
* Table of Contents::
@end menu
@node How to replace the default GRUB configuration file on a libreboot system
@chapter How to replace the default GRUB configuration file on a libreboot system
@anchor{#how-to-replace-the-default-grub-configuration-file-on-a-libreboot-system}
Libreboot on x86 uses the GRUB @uref{http://www.coreboot.org/Payloads#GRUB_2,payload} by default, which means that the GRUB configuration file (where your GRUB menu comes from) is stored directly alongside libreboot and its GRUB payload executable, inside the flash chip. In context, this means that installing distributions and managing them is handled slightly differently compared to traditional BIOS systems.
A libreboot (or coreboot) ROM image is not simply "flat"; there is an actual filesystem inside called CBFS (coreboot filesystem). A utility called 'cbfstool' allows you to change the contents of the ROM image. In this case, libreboot is configured such that the 'grub.cfg' and 'grubtest.cfg' files exist directly inside CBFS instead of inside the GRUB payload 'memdisk' (which is itself stored in CBFS).
You can either modify the GRUB configuration stored in the flash chip, or you can modify a GRUB configuration file on the main storage which the libreboot GRUB payload will automatically search for.
Here is an excellent writeup about CBFS (coreboot filesystem): @uref{http://lennartb.home.xs4all.nl/coreboot/col5.html,http://lennartb.home.xs4all.nl/coreboot/col5.html}.
@strong{This guide is *only* for the GRUB payload. If you use the depthcharge payload, ignore this section entirely.}
@uref{index.html,Back to previous index}
@node Table of Contents
@chapter Table of Contents
@anchor{#table-of-contents}
@itemize
@item
@ref{#introduction,Introduction}
@item
@ref{#option1_dont_reflash,1st option: don't re-flash}
@item
@ref{#option2_reflash,2nd option: re-flash}
@itemize
@item
@ref{#tools,Acquire the necessary utilities}
@item
@ref{#rom,Acquiring the correct ROM image}
@item
@ref{#extract_testconfig,Extract grubtest from the ROM image}
@item
@ref{#reinsert_modified_testconfig,Re-insert the modified grubtest.cfg into the ROM image}
@item
@ref{#testing,Testing}
@item
@ref{#final_steps,Final steps}
@end itemize
@end itemize
@menu
* Introduction::
* 1st option don't re-flash::
* 2nd option re-flash::
* Acquire the necessary utilities::
* Acquiring the correct ROM image::
* Extract grubtestcfg from the ROM image::
* Re-insert the modified grubtestcfg into the ROM image::
* Testing::
* Final steps::
@end menu
@node Introduction
@section Introduction
@anchor{#introduction}
Download the latest release from @uref{http://libreboot.org/,http://libreboot.org/} @*@strong{If you downloaded from git, refer to @uref{../git/index.html#build_meta,../git/index.html#build_meta} before continuing.}
@ref{#pagetop,Back to top of page.}
There are several advantages to modifying the GRUB configuration stored in CBFS, but this also means that you have to flash a new libreboot ROM image on your system (some users feel intimidated by this, to say the least). Doing so can be risky if not handled correctly, because it can result in a bricked system (recovery is easy if you have the @uref{../install/bbb_setup.html,equipment} for it, but most people don't). If you aren't up to that then don't worry; it is possible to use a custom GRUB menu without flashing a new image, by loading a GRUB configuration from a partition on the main storage instead.
@node 1st option don't re-flash
@section 1st option: don't re-flash
@anchor{#st-option-dont-re-flash}
By default, GRUB in libreboot is configured to scan all partitions on the main storage for /boot/grub/coreboot_grub.cfg or /grub/coreboot_grub.cfg(for systems where /boot is on a dedicated partition), and then use it automatically.
Simply create your custom GRUB configuration and save it to @strong{/boot/grub/coreboot_grub.cfg} on the running system. The next time you boot, GRUB (in libreboot) will automatically switch to this configuration file. @strong{This means that you do not have to re-flash, recompile or otherwise modify libreboot at all!}
Ideally, your distribution should automatically generate a coreboot_grub.cfg file that is written specifically under the assumption that it will be read and used on a libreboot system that uses GRUB as a payload. If your distribution does not do this, then you can try to add that feature yourself or politely ask someone involved with or otherwise knowledgeable about the distribution to do it for you. The coreboot_grub.cfg could either contain the full configuration, or it could chainload another GRUB ELF executable (built to be used as a coreboot payload) that is located in a partition on the main storage.
If you want to adapt a copy of the existing @emph{libreboot} GRUB configuration and use that for the coreboot_grub.cfg file, then follow @ref{#tools,#tools}, @ref{#rom,#rom} and @ref{#extract_testconfig,#extract_testconfig} to get the @strong{@emph{grubtest.cfg}}. Rename @strong{@emph{grubtest.cfg}} to @strong{@emph{coreboot_grub.cfg}} and save it to @strong{@emph{/boot/grub/}} on the running system where it is intended to be used. Modify the file at that location however you see fit, and then stop reading this guide (the rest of this page is irrelevant to you); @strong{in coreboot_grub.cfg on disk, if you are adapting it based on grub.cfg from CBFS then remove the check for coreboot_grub.cfg otherwise it will loop.}.
This is all well and good, but what should you actually put in your GRUB configuration file? Read @uref{grub_config.html,grub_config.html} for more information.
@ref{#pagetop,Back to top of page.}
@node 2nd option re-flash
@section 2nd option: re-flash
@anchor{#nd-option-re-flash}
You can modify what is stored inside the flash chip quite easily. Read on to find out how.
@ref{#pagetop,Back to top of page.}
@node Acquire the necessary utilities
@section Acquire the necessary utilities
@anchor{#acquire-the-necessary-utilities}
Use @strong{@emph{cbfstool}} and @strong{@emph{flashrom}}. There are available in the @emph{libreboot_util} release archive, or they can be compiled (see @uref{../git/index.html#build_flashrom,../git/index.html#build_flashrom}). Flashrom is also available from the repositories:@* # @strong{pacman -S flashrom}
@ref{#pagetop,Back to top of page.}
@node Acquiring the correct ROM image
@section Acquiring the correct ROM image
@anchor{#acquiring-the-correct-rom-image}
You can either work directly with one of the ROM images already included in the libreboot ROM archives, or re-use the ROM that you have currently flashed. For the purpose of this tutorial it is assumed that your ROM image file is named @emph{libreboot.rom}, so please make sure to adapt.
ROM images are included pre-compiled in libreboot. You can also dump your current firmware, using flashrom:@* $ @strong{sudo flashrom -p internal -r libreboot.rom}@* # @strong{flashrom -p internal -r libreboot.rom}@* If you are told to specify the chip, add the option @strong{-c @{your chip@}} to the command, for example:@* # @strong{flashrom -c MX25L6405 -p internal -r libreboot.rom}
@ref{#pagetop,Back to top of page.}
@node Extract grubtestcfg from the ROM image
@section Extract grubtest.cfg from the ROM image
@anchor{#extract-grubtest.cfg-from-the-rom-image}
You can check the contents of the ROM image, inside CBFS:@* @strong{$ cd .../libreboot_util/cbfstool} @strong{$ ./cbfstool libreboot.rom print}
The files @emph{grub.cfg} and @emph{grubtest.cfg} should be present. grub.cfg is loaded by default, with a menuentry for switching to grubtest.cfg. In this tutorial, you will first modify and test @emph{grubtest.cfg}. This is to reduce the possibility of bricking your device, so DO NOT SKIP THIS!
Extract grubtest.cfg from the ROM image:@* @strong{$ ./cbfstool libreboot.rom extract -n grubtest.cfg -f grubtest.cfg}
Modify the grubtest.cfg accordingly.
This is all well and good, but what should you actually put in your GRUB configuration file? Read @uref{grub_config.html,grub_config.html} for more information.
@ref{#pagetop,Back to top of page.}
@node Re-insert the modified grubtestcfg into the ROM image
@section Re-insert the modified grubtest.cfg into the ROM image
@anchor{#re-insert-the-modified-grubtest.cfg-into-the-rom-image}
Once your grubtest.cfg is modified and saved, delete the unmodified config from the ROM image:@* @strong{$ ./cbfstool libreboot.rom remove -n grubtest.cfg}
Next, insert the modified version:@* @strong{$ ./cbfstool libreboot.rom add -n grubtest.cfg -f grubtest.cfg -t raw}
@ref{#pagetop,Back to top of page.}
@node Testing
@section Testing
@anchor{#testing}
@strong{Now you have a modified ROM. Refer back to @uref{../install/index.html#flashrom,../install/index.html#flashrom} for information on how to flash it.@* $ @strong{cd /libreboot_util} # @strong{./flash update libreboot.rom}@* Ocassionally, coreboot changes the name of a given board. If flashrom complains about a board mismatch, but you are sure that you chose the correct ROM image, then run this alternative command:@* # @strong{./flash forceupdate libreboot.rom}@* You should see @strong{"Verifying flash... VERIFIED."} written at the end of the flashrom output. Once you have done that, shut down and then boot up with your new test configuration.}
Choose (in GRUB) the menu entry that switches to grubtest.cfg. If it works, then your config is safe and you can continue below.
@strong{If it does not work like you want it to, if you are unsure or sceptical in any way, then re-do the steps above until you get it right! Do *not* proceed past this point unless you are 100% sure that your new configuration is safe (or desirable) to use.}
@ref{#pagetop,Back to top of page.}
@node Final steps
@section Final steps
@anchor{#final-steps}
When you are satisfied booting from grubtest.cfg, you can create a copy of grubtest.cfg, called grub.cfg. This is the same except for one difference: the menuentry 'Switch to grub.cfg' will be changed to 'Switch to grubtest.cfg' and inside it, all instances of grub.cfg to grubtest.cfg. This is so that the main config still links (in the menu) to grubtest.cfg, so that you don't have to manually switch to it, in case you ever want to follow this guide again in the future (modifying the already modified config). From /libreboot_util/cbfstool, do:@* $ @strong{sed -e 's:(cbfsdisk)/grub.cfg:(cbfsdisk)/grubtest.cfg:g' -e 's:Switch to grub.cfg:Switch to grubtest.cfg:g' < grubtest.cfg > grub.cfg}@*
Delete the grub.cfg that remained inside the ROM:@* @strong{$ ./cbfstool libreboot.rom remove -n grub.cfg}
Add the modified version that you just made:@* @strong{$ ./cbfstool libreboot.rom add -n grub.cfg -f grub.cfg -t raw}
@strong{Now you have a modified ROM. Again, refer back to @uref{../install/index.html#flashrom,../install/index.html#flashrom} for information on how to flash it. It's the same method as you used before. Shut down and then boot up with your new configuration.}
@ref{#pagetop,Back to top of page.}
Copyright © 2014, 2015 Francis Rowe <info@@gluglug.org.uk>@* Copyright © 2015 Jeroen Quint <jezza@@diplomail.ch>@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be found at @uref{../resources/licenses/gfdl-1.3.txt,gfdl-1.3.txt}
Updated versions of the license (when available) can be found at @uref{https://www.gnu.org/licenses/licenses.html,https://www.gnu.org/licenses/licenses.html}
UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
@bye
|