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
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
@import url('../css/main.css');
</style>
<title>Writing a GRUB configuration file</title>
</head>
<body>
<div class="section">
<h1 id="pagetop">Writing a GRUB configuration file</h1>
<p>
<a href="index.html">Back to index</a>
</p>
</div>
<div class="section">
<h1>Table of Contents</h1>
<li>
<a href="#example_modifications">Example modifications for <i>grubtest.cfg</i></a>
<ul>
<li><a href="#example_modifications_trisquel">Trisquel GNU/Linux-libre</a></li>
<li><a href="#example_modifications_parabola">Parabola GNU/Linux-libre</a></li>
</ul>
</li>
</div>
<div class="section">
<h2 id="example_modifications">Example modifications for <i>grubtest.cfg</i></h2>
<p>
These are some common examples of ways in which the grubtest.cfg file can be modified.
</p>
<div class="subsection">
<h3 id="example_modifications_trisquel">Trisquel GNU/Linux-libre</h3>
<p>
As an example, on my test system in /boot/grub/grub.cfg (on the HDD/SSD) I see for the main menu entry:
</p>
<ul>
<li><b>linux /boot/vmlinuz-3.15.1-gnu.nonpae root=UUID=3a008e14-4871-497b-95e5-fb180f277951 ro crashkernel=384M-2G:64M,2G-:128M quiet splash $vt_handoff</b></li>
<li><b>initrd /boot/initrd.img-3.15.1-gnu.nonpae</b></li>
</ul>
<p>
<b>ro</b>, <b>quiet</b>, <b>splash</b>, <b>crashkernel=384M-2G:64M,2G-:128M</b> and
<b>$vt_handoff</b> can be safely ignored.
</p>
<p>
I use this to get my partition layout:<br/>
$ <b>lsblk</b>
</p>
<p>
In my case, I have no /boot partition, instead /boot is on the same partition as / on sda1.
Yours might be different. In GRUB terms, sda means ahci0. 1 means msdos1, or gpt1, depending
on whether I am using MBR or GPT partitioning. Thus, /dev/sda1 is GRUB is (ahci0,msdos1) or
(ahci0,gpt1). In my case, I use MBR partitioning so it's (ahci0,msdos1).
'msdos' is a GRUB name simply because this partitioning type is traditionally used by MS-DOS.
It doesn't mean that you have a proprietary OS.
</p>
<p>
Trisquel doesn't keep the filenames of kernels consistent, instead it keeps old kernels and
new kernel updates are provided with the version in the filename. This can make GRUB payload
a bit tricky. Fortunately, there are symlinks /vmlinuz and /initrd.img
so if your /boot and / are on the same partition, you can set GRUB to boot from that.
These are also updated automatically when installing kernel updates from your distributions
apt-get repositories.
<b>
Note: when using <a href="http://jxself.org/linux-libre">jxself kernel releases</a>,
these are not updated at all and you have to update them manually.
</b>
</p>
<p>
For the GRUB payload grubtest.cfg (in the 'Load Operating System' menu entry), we therefore have (in this example):<br/>
<b>set root='ahci0,msdos1'</b><br/>
<b>linux /vmlinuz root=UUID=3a008e14-4871-497b-95e5-fb180f277951</b><br/>
<b>initrd /initrd.img</b>
</p>
<p>
Optionally, you can convert the UUID to its real device name, for example /dev/sda1 in this case.
sdX naming isn't very reliable, though, which is why UUID is used for most distributions.
</p>
<p>
Alternatively, if your /boot is on a separate partition then you cannot rely on the /vmlinuz and /initrd.img symlinks.
Instead, go into /boot and create your own symlinks (update them manually when you install a new kernel update).<br/>
$ <b>sudo -s</b><br/>
# <b>cd /boot/</b><br/>
# <b>rm -Rf vmlinuz initrd.img</b><br/>
# <b>ln -s <u>kernel</u> ksym</b><br/>
# <b>ln -s <u>initrd</u> isym</b><br/>
# <b>exit</b>
</p>
<p>
Replace the underlined <b>kernel</b> and <b>initrd</b> filenames above with the actual filenames, of course.
</p>
<p>
Then your grubtest.cfg menu entry (for payload) becomes like that, for example if / was on sda2 and /boot was on sda1:<br/>
<b>set root='ahci0,msdos1'</b><br/>
<b>linux /ksym root=/dev/sda2</b><br/>
<b>initrd /isym</b>
</p>
<p>
There are lots of possible variations so please try to adapt.
</p>
</div>
<div class="subsection">
<h3 id="example_modifications_parabola">Parabola GNU/Linux-libre</h3>
<p>
You can basically adapt the above. Note however that Parabola does not keep old kernels still installed, and the file names
are always consistent, so you don't need to boot from symlinks, you can just use the real thing directly.
</p>
</div>
<p>
<a href="#pagetop">Back to top of page.</a>
</p>
</div>
<div class="section">
<p>
Copyright © 2014, 2015 Francis Rowe <info@gluglug.org.uk><br/>
This document is released under the Creative Commons Attribution-ShareAlike 4.0 International Public License and all future versions.
A copy of the license can be found at <a href="../cc-by-sa-4.txt">../cc-by-sa-4.txt</a>.
</p>
<p>
This document is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See <a href="../cc-by-sa-4.txt">../cc-by-sa-4.txt</a> for more information.
</p>
</div>
</body>
</html>
|