refind介紹
首先,refind一般在UEFI啓動環境下使用,他可以用來引導各類操作系統的啓動(Windows 8+,Linux,Mac OS),不基於任何操作系統平臺,總之,當refind被選爲系統首選引導項的時候,可以實現如下的效果:
二、rEFind的使用
必須提醒的是:下面所述的所有關於rEFInd引導教程都必須要求電腦支持UEFI,傳統的Legacy引導不可用!本部分可以基於兩個系統平臺來進行,首先是Linux平臺,個人推薦Linux下進行,簡單快捷。
基於debian系的Linux平臺的rEFInd安裝:(建議選擇此種安裝方式)
sudo apt-add-repository ppa:rodsmith/refind sudo apt-get update sudo apt-get install refind
安裝過程中會彈出來一個選擇頁面,選Yes就對了。
或者手動安裝,deb包下載鏈接:下載鏈接
雙擊安裝,或者命令行安裝,命令行逼格高一點
sudo dpkg -i refind_0.11.4-1_amd64.deb sudo refind-install
到此,refind的安裝已經完畢,比Windows不知道快到哪裏去了。
其實完成到這一步,電腦默認會首選rEFInd引導,反正我的電腦是。如果沒有,可以自己去BIOS中設置一下,這個就不多說了,相信大家應該會,如果不會進BIOS的話,也可以在Windows平臺通過easyUEFI軟件進行處理,這一步等後面介紹Windows平臺的使用再說。
下面是rEFInd的編輯與使用:
Refind所有的配置信息位於/boot/efi/EFI/refind/refind.conf。
下面對這一文件用得到的相關參數說明一下:
refind.conf文件的所有內容,很長,我只選了一部分,挑中文註釋看就好了,你們編輯的時候選擇對應的內容搜索就好了,以下的「#」代表註釋的意思,沒有執行的作用,若是去掉某一行的#,則代表執行這條指令。
# # refind.conf # Configuration file for the rEFInd boot menu # # Timeout in seconds for the main menu screen. Setting the timeout to 0 # disables automatic booting (i.e., no timeout). Setting it to -1 causes # an immediate boot to the default OS *UNLESS* a keypress is in the buffer # when rEFInd launches, in which case that keypress is interpreted as a # shortcut key. If no matching shortcut is found, rEFInd displays its # menu with no timeout. # # 設置默認等待時間爲5s # timeout 0代表無限等待timeout -1代表立即進入對應的系統 timeout 5 # # Set the screen's video resolution. Pass this option either: # * two values, corresponding to the X and Y resolutions # * one value, corresponding to a GOP (UEFI) video mode # Note that not all resolutions are supported. On UEFI systems, passing # an incorrect value results in a message being shown on the screen to # that effect, along with a list of supported modes. On EFI 1.x systems # (e.g., Macintoshes), setting an incorrect mode silently fails. On both # types of systems, setting an incorrect resolution results in the default # resolution being used. A resolution of 1024x768 usually works, but higher # values often don't. # Default is "0 0" (use the system default resolution, usually 800x600). # # 分辨率設置,我建立這裏別動,上面註釋中也說了。1024*768以上的分辨率並不支持, # 我是默認的,沒動它,所以沒事別自己搞個1920 1080 # resolution 1024 768 # resolution 1440 900 # resolution 3 # # Directories that should NOT be scanned for boot loaders. By default, # rEFInd doesn't scan its own directory, the EFI/tools directory, the # EFI/memtest directory, the EFI/memtest86 directory, or the # com.apple.recovery.boot directory. Using the dont_scan_dirs option # enables you to "blacklist" other directories; but be sure to use "+" # as the first element if you want to continue blacklisting existing # directories. You might use this token to keep EFI/boot/bootx64.efi out # of the menu if that's a duplicate of another boot loader or to exclude # a directory that holds drivers or non-bootloader utilities provided by # a hardware manufacturer. If a directory is listed both here and in # also_scan_dirs, dont_scan_dirs takes precedence. Note that this # blacklist applies to ALL the filesystems that rEFInd scans, not just # the ESP, unless you precede the directory name by a filesystem name or # partition unique GUID, as in "myvol:EFI/somedir" to exclude EFI/somedir # from the scan on the myvol volume but not on other volumes. # # 這部分看註釋的意思,應該是不掃描ESP分區的某些文件夾,我自己爲了去除某些多餘 # 的啓動項,於是設置了dont_scan_dirs ESP:/EFI/ubuntu,但不知道爲什麼,沒有用, # 啓動項裏仍會出現Ubuntu的引導項,所以我不建議在這部分選擇屏蔽引導項. # dont_scan_dirs ESP:/EFI/boot,EFI/Dell,EFI/memtest86 # Files that should NOT be included as EFI boot loaders (on the # first line of the display). If you're using a boot loader that # relies on support programs or drivers that are installed alongside # the main binary or if you want to "blacklist" certain loaders by # name rather than location, use this option. Note that this will # NOT prevent certain binaries from showing up in the second-row # set of tools. Most notably, various Secure Boot and recovery # tools are present in this list, but may appear as second-row # items. # The file may be specified as a bare name (e.g., "notme.efi"), as # a complete pathname (e.g., "/EFI/somedir/notme.efi"), or as a # complete pathname with volume (e.g., "SOMEDISK:/EFI/somedir/notme.efi" # or 2C17D5ED-850D-4F76-BA31-47A561740082:/EFI/somedir/notme.efi"). # OS tags hidden via the Delete or '-' key in the rEFInd menu are # added to this list, but stored in NVRAM. # The default is shim.efi,shim-fedora.efi,shimx64.efi,PreLoader.efi, # TextMode.efi,ebounce.efi,GraphicsConsole.efi,MokManager.efi,HashTool.efi, # HashTool-signed.efi,bootmgr.efi,fb{arch}.efi # (where "{arch}" is the architecture code, like "x64"). # # 這部分和上面那部分類似,都是屏蔽之用,區別在於上面部分是針對文件夾,這部分是針 # 對具體文件,這部分在去除某些啓動項有着極爲關鍵的作用,我將詳細展開敘述。 # dont_scan_files shim.efi,MokManager.efi
多餘啓動項的刪除策略:
首選,我們可以先看一下EFI分區的文件信息:(Linux系統中的位置:boot/efi/EFI)
refind他針對某些.efi的文件會選擇無腦的引導,因此我們爲了簡潔或者美觀,需要屏蔽某些文件的引導,屏蔽不會修改原EFI分區中的系統引導文件,換言之,安全,針對我的Deepin,引導文件位於deepin/grubx64.efi(EFI分區的相對路徑),以及我的Windows引導文件,位於Microsoft/Boot/bootmgfw.efi,而我們需要保留的就這兩個,其他的一律屏蔽,屏蔽的命令:
dont_scan_files /EFI/ubuntu/grubx64.efi,XXX,XXX
(這代表屏蔽了ubuntu文件夾下的grubx64.efi引導文件,還需要屏蔽其他文件XXX,直接在上面的指令中以英文格式下的逗號分隔就好了,最後一項不需要逗號)
# Scan for Linux kernels that lack a ".efi" filename extension. This is # useful for better integration with Linux distributions that provide # kernels with EFI stub loaders but that don't give those kernels filenames # that end in ".efi", particularly if the kernels are stored on a # filesystem that the EFI can read. When set to "1", "true", or "on", this # option causes all files in scanned directories with names that begin with # "vmlinuz" or "bzImage" to be included as loaders, even if they lack ".efi" # extensions. Passing this option a "0", "false", or "off" value causes # kernels without ".efi" extensions to NOT be scanned. # Default is "true" -- to scan for kernels without ".efi" extensions. # # 此段爲屏蔽掃描所有Linux內核,refind啓動項包括了掃描的操作系統內核,其實通過 # 掃描的內核啓動操作系統更快,因爲會直接跳過Linux系統的grub引導而直接啓動對應 # 的Linux系統,但是考慮到有時候需要系統修復什麼的,建議還是通過grub引導的菜單 # 啓動吧,屏蔽內核檢查的指令如下: scan_all_linux_kernels false
在refind.conf文件的最後一行,需要加一行指令,這是涉及到refind的主題美化的方面,指令內容爲:
include <相對路徑>/theme.config
(相對路徑是指你的主題配置文件theme.config在以refind目錄爲根目錄的文件路徑)
比如我的theme文件位於refind目錄下的themes/rEFInd-minimal處,所以我的指令是:
include themes/rEFInd-minimal/theme.config
至此,關於refind.conf文件的介紹就完畢了,下面是關於theme文件的介紹
首先,看refind文件夾結構(refind文件夾位於EFI分區目錄)
主題文件位於theme文件夾:
這是我的主題,就用了這一個,打開:
然後來介紹theme.conf文件,以下是我的文件內容,不長,看中文註釋信息就好了:
# Minimal refind theme # Hide user interface elements for personal preference or to increase # security: # banner - the rEFInd title banner (built-in or loaded via "banner") # label - boot option text label in the menu # singleuser - remove the submenu options to boot Mac OS X in single-user # or verbose modes; affects ONLY MacOS X # safemode - remove the submenu option to boot Mac OS X in "safe mode" # hwtest - the submenu option to run Apple's hardware test # arrows - scroll arrows on the OS selection tag line # hints - brief command summary in the menu # editor - the options editor (+, F2, or Insert on boot options menu) # all - all of the above # Default is none of these (all elements active) # hideui singleuser,hints,arrows,label,badges # Set the name of a subdirectory in which icons are stored. Icons must # have the same names they have in the standard directory. The directory # name is specified relative to the main rEFInd binary's directory. If # an icon can't be found in the specified directory, an attempt is made # to load it from the default directory; thus, you can replace just some # icons in your own directory and rely on the default for others. # Default is "icons". # 各種系統的啓動圖標 icons_dir themes/rEFInd-minimal/icons # Use a custom title banner instead of the rEFInd icon and name. The file # path is relative to the directory where refind.efi is located. The color # in the top left corner of the image is used as the background color # for the menu screens. Currently uncompressed BMP images with color # depths of 24, 8, 4 or 1 bits are supported, as well as PNG images. # 這是啓動界面背景圖片路徑,也是相對路徑,且暫時似乎只支持png格式的圖片 banner themes/rEFInd-minimal/background.png # Tells rEFInd whether to display banner images pixel-for-pixel (noscale) # or to scale banner images to fill the screen (fillscreen). The former is # the default. # 默認全屏填充 banner_scale fillscreen # Custom images for the selection background. There is a big one (144 x 144) # for the OS icons, and a small one (64 x 64) for the function icons in the # second row. If only a small image is given, that one is also used for # the big icons by stretching it in the middle. If only a big one is given, # the built-in default will be used for the small icons. # # Like the banner option above, these options take a filename of an # uncompressed BMP image file with a color depth of 24, 8, 4, or 1 bits, # or a PNG image. The PNG format is required if you need transparency # support (to let you "see through" to a full-screen banner). # selection_bigthemes/rEFInd-minimal/selection_big.png selection_small themes/rEFInd-minimal/selection_small.png # Which non-bootloader tools to show on the tools line, and in what # order to display them: # shell - the EFI shell (requires external program; see rEFInd # documentation for details) # gptsync - the (dangerous) gptsync.efi utility (requires external # program; see rEFInd documentation for details) # apple_recovery - boots the Apple Recovery HD partition, if present # mok_tool - makes available the Machine Owner Key (MOK) maintenance # tool, MokManager.efi, used on Secure Boot systems # about - an "about this program" option # exit - a tag to exit from rEFInd # shutdown - shuts down the computer (a bug causes this to reboot # EFI systems) # reboot - a tag to reboot the computer # firmware - a tag to reboot the computer into the firmware's # user interface (ignored on older computers) # Default is shell,apple_recovery,mok_tool,about,shutdown,reboot,firmware # showtools shutdown
文件中還有很多雜七雜八的東西,感興趣的話可以Google一下,官方文檔說得也十分詳細,再有就是refind主題的下載鏈接,我放一下,來源於Github,分享只作學習交流之用。GitHub地址
大家可以選擇自己感興趣的主題下載,安裝的話,記得在refind.conf文件末尾改路徑哦。
以上針對的是對rEFInd比較感興趣並且動手能力比較強的朋友們的一個介紹,你們完全可以自己去折騰rEFInd的配置,又不動EFI分區的其他系統文件,所以基本無風險,大不了在BIOS中改回原來的引導。
再就是,懶人版!
我自己用的主題以及自己配的rEFind文件:
感興趣的朋友可以把我的refind配置拿來用,UEFI機器通用。你可以用我的refind.conf文件替換官方的,也可以把我theme文件夾中的主題拿去用,也可以替換你EFI文件夾中的整個refind文件夾。下載鏈接(提取碼: cmyj)
記得解壓出裏面的refind文件夾,將refind文件夾放入EFI分區即可。而如何放入EFI分區呢,Linux操作系統很簡單,直接取得root權限,將refind文件夾移動至boot/efi/EFI即可,命令行操作:
sudo cp -a ****/refind /boot/efi/EFI/
(****代表你的refind文件夾的路徑)
Windows下,需要將EFI分區單獨搞出來
三、Windows操作如下:
訪問EFI分區的操作步驟(點此進入):
進行到這一步,refind的移動就算處理完畢了,最後就是在BIOS中添加rEFInd的引導項,並選爲第一引導項,在Windows平臺,我通過easyUEFI來進行(搜索查找即可下載)
打開easyUEFI
選擇Linux或其他操作系統,描述自己取個名字,用英文吧。目標分區選中ESP分區,我這裏是第二個。
點擊瀏覽
點那個小加號,找到refind:
選中refind_x64.efi,過一會兒,點擊確定,會發現在最後一行出現你新建的項:
上移,移動到第一個爲止,到此,即已完成。以上便是整個教程了,趕快定製你喜歡的啓動頁面吧(主要是主題,背景也可單獨更換)。