-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
199 lines (131 loc) · 12 KB
/
README
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
1. 下载及相关文档:
https://sourceforge.net/projects/refind/files/
https://www.rodsbooks.com/refind/
https://versaweb.dl.sourceforge.net/project/refind/0.14.0.2/refind-cd-0.14.0.2.zip
下面的步骤可以重点参考:
https://www.rodsbooks.com/refind/installing.html#linux
https://askubuntu.com/questions/743095/how-to-prepare-a-disk-on-an-efi-based-pc-for-ubuntu
http://www.rodsbooks.com/refind/getting.html
https://sourceforge.net/projects/refind/files/
2.
Based on the discussion with the author of refind, I deduced the following method which
combining the usage of grub2 and refind-cd:
1). Make the following stuff according the notes there:
EFI/grub-mkstandalone/
2).
在上述步骤的同一个硬盘上,做一个fat32的 esp 分区:
werner@X10DAi:~$ sudo apt install mtools dosfstools
# 格式化一个 100M作用的 fat32分区即可:
werner@X10DAi:~$ sudo gparted
# 实际测试,这步没有必要:
set boot/esp flag for the efi partition
# 下面是关键步骤:
基于rsync的操作:
mkdir /tmp/aa && sudo mount /dev/sda3 /tmp/aa/
挂载 refind-cd-0.14.0.2.iso
method 1:
werner@X10DAi:/media/werner/rEFInd_0.14.0.2$ sudo rm -fr /tmp/aa/EFI/
werner@X10DAi:/media/werner/rEFInd_0.14.0.2$ sudo rsync -avP --delete --mkpath ./refind/ /tmp/aa/EFI/boot/
cd /tmp/aa/EFI/boot/
sudo mv refind_x64.efi bootx64.efi
or
method 2: (这个是最简单因而推荐使用的方法。)
werner@X10DAi:/media/werner/rEFInd_0.14.0.2$ sudo rm -fr /tmp/aa/EFI/
sudo rsync -avP --delete --mkpath ./EFI/ /tmp/aa/EFI/
进一步分析iso上的EFI/boot/ 和 refind 两个目录中的内容,发现确实是对应的,只不过某些文件的命名做了稍微改动:
werner@X10DAi:/media/werner/rEFInd_0.14.0.2$ diff EFI/boot/ refind | grep -Ev '^Common|\.conf$'
Only in EFI/boot/: bootaa64.efi
Only in EFI/boot/: bootia32.efi
Only in EFI/boot/: bootx64.efi
Only in refind: refind_aa64.efi
Only in refind: refind_ia32.efi
Only in refind: refind_x64.efi
Only in refind: tools_aa64
Only in refind: tools_ia32
Only in refind: tools_x64
werner@X10DAi:/media/werner/rEFInd_0.14.0.2$ diff EFI/boot/bootaa64.efi refind/refind_aa64.efi
werner@X10DAi:/media/werner/rEFInd_0.14.0.2$ diff EFI/boot/bootia32.efi refind/refind_ia32.efi
werner@X10DAi:/media/werner/rEFInd_0.14.0.2$ diff EFI/boot/bootx64.efi refind/refind_x64.efi
werner@X10DAi:/media/werner/rEFInd_0.14.0.2$ diff EFI/tools/gptsync_ia32.efi refind/tools_ia32/gptsync_ia32.efi
werner@X10DAi:/media/werner/rEFInd_0.14.0.2$ diff EFI/tools/gptsync_x64.efi refind/tools_x64/gptsync_x64.efi
werner@X10DAi:/media/werner/rEFInd_0.14.0.2$
若能够引导成功,则重启后,就会有下面的条目:
werner@X10DAi:/tmp/aa/EFI/boot$ sudo efibootmgr -v|grep -i '\*.*hd'
Boot0006* UEFI OS HD(3,GPT,e57a46e5-4154-4220-b186-082bbc3edd95,0x3ded2800,0x32000)/File(\EFI\BOOT\BOOTX64.EFI)..BO
# 下面是一些尝试,实际上没有必要执行:
werner@X10DAi:~$ sudo efibootmgr -Bb 0005
werner@X10DAi:~$ sudo efibootmgr -Bb 0006
werner@X10DAi:~$ sudo efibootmgr -ab 0004
werner@X10DAi:~$ sudo efibootmgr -v
BootCurrent: 0006
Timeout: 1 seconds
BootOrder: 0003,0002,0004
Boot0002 Network Card BBS(Network,,0x0)..GO..NO........q.I.B.A. .G.E. .S.l.o.t. .0.4.0.0. .v.1.5.7.8.........................rN.D+..,.\...........B..Gd-.;.A..MQ..L.I.B.A. .G.E. .S.l.o.t. .0.4.0.0. .v.1.5.7.8........BO
Boot0003* UEFI: Built-in EFI Shell VenMedia(5023b95c-db26-429b-a648-bd47664c8012)..BO
Boot0004* Hard Drive BBS(HD,,0x0)..GO..NO........o.W.D.C. . .W.D.S.1.0.0.T.2.B.0.A.-.0.0.S.M.5.0....................A...........................>..Gd-.;.A..MQ..L.9.1.5.1.3.3.6.4.9.7.6.0. . . . . . . . ........BO
重启之后,就会成为类似下面的设置:
werner@X10DAi:~$ sudo efibootmgr -Ab 0005
werner@X10DAi:~$ sudo efibootmgr -ab 0006
werner@X10DAi:~$ sudo efibootmgr -v
BootCurrent: 0006
Timeout: 1 seconds
BootOrder: 0005,0006,0003,0002,0004
Boot0002 Network Card BBS(Network,,0x0)..GO..NO........q.I.B.A. .G.E. .S.l.o.t. .0.4.0.0. .v.1.5.7.8.........................rN.D+..,.\...........B..Gd-.;.A..MQ..L.I.B.A. .G.E. .S.l.o.t. .0.4.0.0. .v.1.5.7.8........BO
Boot0003* UEFI: Built-in EFI Shell VenMedia(5023b95c-db26-429b-a648-bd47664c8012)..BO
Boot0004 Hard Drive BBS(HD,,0x0)..GO..NO........o.W.D.C. . .W.D.S.1.0.0.T.2.B.0.A.-.0.0.S.M.5.0....................A...........................>..Gd-.;.A..MQ..L.9.1.5.1.3.3.6.4.9.7.6.0. . . . . . . . ........BO
Boot0005* UEFI OS HD(3,GPT,e57a46e5-4154-4220-b186-082bbc3edd95,0x3ded2800,0x32000)/File(\EFI\BOOT\BOOTIA32.EFI)..BO
Boot0006* UEFI OS HD(3,GPT,e57a46e5-4154-4220-b186-082bbc3edd95,0x3ded2800,0x32000)/File(\EFI\BOOT\BOOTX64.EFI)..BO
# 这个也没有必要:
werner@X10DAi:~$ sudo efibootmgr -c -l \\EFI\\refind\\refind_x64.efi -L rEFInd
ref:
官方指南推荐的步骤:
===
https://www.rodsbooks.com/refind/installing.html#linux
Installing rEFInd Manually Using Linux
On a UEFI-based PC, you'll normally install rEFInd to the ESP, which is usually mounted at /boot/efi. You can verify that this is the case by using the df command:
$ df /boot/efi
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 191284 16604 174681 9% /boot/efi
This example shows that /dev/sda1 is mounted at /boot/efi, which is a typical configuration. (The ESP can be on another disk or partition, but /dev/sda1 is the most common place for an ESP.) If your output shows /boot or / under the Mounted on column, then your ESP isn't mounted. (An exception is if you're mounting the ESP at /boot. This is an unusual configuration. If you're using it, you can proceed, making suitable adjustments to subsequent commands.) If you get a df: `/boot/efi': No such file or directory error message, then the /boot/efi directory doesn't even exist. In such cases, you may need to jump through some extra hoops, as described on my EFI Boot Loader Installation page.
Assuming the ESP is mounted at /boot/efi, you can install the rEFInd files as follows (you must be root to issue these commands, or precede each of them with sudo):
1. Type cp -r refind /boot/efi/EFI/ from the refind-version directory in which the refind directory exists. This copies all the files that rEFInd needs to work. Note that this includes all of rEFInd's drivers. This command also copies the rEFInd binaries as signed by me; if you prefer to re-sign the binaries yourself, you'll have to do so before or during the copy operation, as described on the Managing Secure Boot page.
2. Type cd /boot/efi/EFI/refind to change into rEFInd's new directory on the ESP.
3. You may optionally remove the rEFInd binaries for the CPU types you're not using. For instance, you might type rm refind_ia32.efi refind_aa64.efi to remove the IA32 and AARCH64 binaries if you're using an x86-64 (AMD64, X64) system.
4. Similarly, you may optionally remove the drivers subdirectories for the CPU types you're not using. For instance, you could type rm -r drivers_ia32 drivers_aa64 to remove the x86 and ARM64 drivers from an x86-64 system.
5. I strongly recommend that you remove some or all of the drivers for the architecture you are using. If you don't need them, they'll slow down the start process, and worse, loading unnecessary drivers can cause some systems to hang or interfere with the drivers you do need. See the page on drivers for more on this topic. Chances are you need only one filesystem driver, for whatever filesystem holds your Linux kernels.
6. Rename the configuration file by typing mv refind.conf-sample refind.conf. Consult the Editing the rEFInd Configuration File page for information on how to adjust your options.
7. On a UEFI-based system, type efibootmgr -c -l \\EFI\\refind\\refind_x64.efi -L rEFInd to add rEFInd to your EFI's list of available boot loaders, which it stores in NVRAM. Adjust the path to the binary as required if you install somewhere else. You may also need to include additional options if your ESP isn't on /dev/sda1 or if your configuration is otherwise unusual; consult the efibootmgr man page for details. You may need to install this program on some systems; it's a standard part of most distributions' repositories. Also, if you're installing in Secure Boot mode, you must normally register shim.efi rather than the rEFInd binary, and rename refind_x64.efi to grubx64.efi. Shim 0.7 and later enables you to keep rEFInd's usual name by adding a -u "shim.efi refind_x64.efi" option to your efibootmgr command line, though. Change the filenames to the ones used by your actual Shim and rEFInd binaries, respectively.
Weird: A bug exists in some Lenovo computers (and perhaps in some others, too) that causes the firmware's boot manager to refuse to boot any boot loader that doesn't have the name Windows Boot Manager or Red Hat Enterprise Linux. If you have such a system, you must pass one of those names (in quotes) rather than rEFInd to efibootmgr via its -L option. This bug was reported to Lenovo in mid-November 2012, and by late 2013, at least some Lenovos were mercifully free of this bug.
werner@X10DAi:~$ sudo efibootmgr -c -l \\EFI\\refind\\refind_x64.efi -L rEFInd
8. If other boot loaders are already installed, you can use efibootmgr to adjust their boot order. For instance, efibootmgr -o 3,7,2 sets the firmware to try boot loader #3 first, followed by #7, followed by #2. (The program should have displayed a list of boot loaders when you added yours in the preceding step.) Place rEFInd's number first to set it as the default boot program.
Note the use of doubled-up backslashes (\\) rather than forward slashes (/) in the directory separators when using efibootmgr. This command will work on most systems that are already booted into EFI mode; however, it won't work if you're booted in BIOS mode. You may also need to add options if your ESP is in some unusual location or if your system is unusual in some way. Consult the efibootmgr man page if you need help.
On some systems, efibootmgr won't do what you expect. On such systems, you may have better luck renaming the rEFInd files, as described in the Alternative Naming Options section.
See below for more details:
https://www.rodsbooks.com/refind/installing.html#naming
===
区别在于,我的操作直接使用 iso 上的EFI目录来替换硬盘上的EFI目录。而refind 的手册中的安装说明,则是将iso上的refind目录整体copy到硬盘上的EFI目录下。
因此,若使用官方手册安装描述的安装方法,则可以将 iso 上的 refind 目录copy 到作为esp 使用的 fat32 分区上的 EFI 子目录下,即可。而我描述的操作,则对应于如下命令:
cp -r EFI /boot/efi/
但是,实际上没有必要在fstab中挂载 /boot/efi/,所以上面的target 位置不一定存在,可以检查如下:
$ df /boot/efi
如果不存在这样的挂载点,则直接使用相应的磁盘路径即可。
3). In order to ensure the maximum portability, for tasks such as searching the OSes,
includes all disks; for other tasks such as finding the bootable installation images,
only includes the disk where the EFI/grub-mkstandalone/grubx64.efi used for booting the computer is located.
Compile and install using source code:
sudo apt-get build-dep gnu-efi
make -j24
For installation:
$ sudo mount /dev/sda1 /boot/efi
$ sudo ./refind-install
After installation, it will give some instructions on doing some adjustments.
According the directory structure of the refind-cd's EFI sub-directory to rename corresponding files.
4). 关于 usb 启动盘的识别是否挑usb口的问题,我的测试结果如下:
a)
$ inxi -S
System:
Host: X10DAi Kernel: 5.19.0-21-generic x86_64 bits: 64 Desktop: GNOME 43.0
Distro: Ubuntu 22.10 (Kinetic Kudu)
用usb 3.0盘做的基于 refind-cd 的EFI目录和 EFI/grub-mkstandalone 集成的启动盘,只有用主板后置面板上的usb3.0口才可以成功启动。
b)再后来的测试,用 refind-cd-0.14.0.2.iso 直接做成启动盘,则并没有发现挑usb口的现象。
推测起来,用上面的两种方法作出的启动盘都应该不挑usb口,但是,后一种方法的健壮性更强。