日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > > 充電吧
[導(dǎo)讀]https://wiki.archlinux.org/index.php/GRUB2_(簡體中文) GRUB2?下一代 GRand Unified Bootloader (GRUB)。 GRUB

https://wiki.archlinux.org/index.php/GRUB2_(簡體中文)


GRUB2?下一代 GRand Unified Bootloader (GRUB)。 GRUB2 來自下一代 GRUB 研究項目?PUPA,代碼全部重寫,實現(xiàn)了模塊化和增強(qiáng)了移植性。[1].

簡單的說,啟動引導(dǎo)器是電腦啟動時第一個運(yùn)行的程序。負(fù)責(zé)裝載內(nèi)核并將控制權(quán)轉(zhuǎn)入。內(nèi)核再初始化操作系統(tǒng)的其它部分。

Contents ?[hide]? 1?前言 1.1?當(dāng)前 GRUB 用戶請注意1.2?GRUB2 所需條件 1.2.1?BIOS 系統(tǒng) 1.2.1.1?GPT 專用指令1.2.1.2?MBR 即 msdos 分區(qū)專用指令1.2.2?UEFI 系統(tǒng) 1.2.2.1?創(chuàng)建并掛載 UEFI 系統(tǒng)分區(qū)2?安裝 2.1?在已有系統(tǒng)中安裝grub2 2.1.1?BIOS 系統(tǒng) 2.1.1.1?備份之前的數(shù)據(jù)2.1.1.2?grub_bios 安裝前2.1.1.3?Run grub-install3?引導(dǎo)器配置 3.1?Dual booting 3.1.1?其他GNU/Linux發(fā)行版3.2?背景圖像和點(diǎn)陣字體3.3?菜單顏色3.4?Hidden menu3.5?設(shè)置 Framebuffer 分辨率4?常見問題 4.1?msdos-style Error Message4.2?Other5?更多資源 前言

GRUB Legacy(如0.9x)已經(jīng)被上游開發(fā)團(tuán)隊標(biāo)為過時,有許多發(fā)行版使用 GRUB2 或者syslinux替換。Arch 現(xiàn)在提供的?grub?已經(jīng)是 Grub2,推薦現(xiàn)在的 grub 用戶進(jìn)行切換。

注意:?grub2 支持 btrfs 根分區(qū),不需要給 /boot 單獨(dú)分區(qū)。 當(dāng)前 GRUB 用戶請注意 GRUB 和 GRUB2 的內(nèi)置命令有所不同(例如 "find" 已經(jīng)變成 "search"),詳情可見:?GRUB2 命令GRUB2 已經(jīng)模塊化,不再需要"stage 1.5"。所以,啟動引導(dǎo)器可以變得很小 -- 模塊按需從硬盤導(dǎo)入以擴(kuò)展功能。(例如LVM?或 RAID 支持)。GRUB 和 GRUB2 的分區(qū)命名有變化。分區(qū)從 1開始編號,并以分區(qū)類型開始,原來是從 0 開始編號。注意:磁盤還是從 0 編號。例如,/dev/sda1應(yīng)該是?(hd0,msdos1)?(用于MBR) 或?(hd0,gpt1)?(用于 GPT)。 GRUB2 所需條件 BIOS 系統(tǒng) GPT?專用指令

BIOS-GPT 配置中的 GRUB2 需要一個BIOS 啟動分區(qū)以便植入core.img,因為 GPT 分區(qū)系統(tǒng)中 MBR 后面沒有了 32 KiB 的空間(已經(jīng)被 GPT 主頭部和主分區(qū)表占據(jù))。此分區(qū)僅在 BIOS-GPT 配置中使用,如果使用 MBR 分區(qū)方式,此分區(qū)不被使用。同時如果系統(tǒng)是基于 UEFI 的,也無需創(chuàng)建這個分區(qū),因為其中并沒有嵌入啟動扇區(qū)。 Syslinux 也不使用這個分區(qū)。

用 cgdisk 或 GNU Parted 創(chuàng)建 2 MB 的無文件系統(tǒng)分區(qū)。只要位于磁盤的前 2TiB 空間內(nèi),分區(qū)位置沒有要求。但是建議放在磁盤開始位置,/boot 之前。cgdisk 中設(shè)置類型為 "EF02" 或在GNU Parted 中設(shè)置set bios_grub on標(biāo)記。

只有在 BIOS-GPT 配置中 GRUB2 才會使用這個分區(qū)。MBR 分區(qū)中不存在這種分區(qū)類型(至少 GRUB2 中如此)。如果系統(tǒng)基于 UEFI,也是不需要這個分區(qū),因為沒有嵌入。GRUB-legacy 和 SYSLINUX 也都不需要這個分區(qū)。

注意:?這個分區(qū)應(yīng)該在 grub2_bios-install 或 grub-setup 和 Archlinux 安裝程序的Install Bootloader?部分執(zhí)行之前建立。 注意:?如果選擇 GRUB2 作為啟動加載器,這個分區(qū)應(yīng)該在 grub2_bios-install 或 grub-setup 和 Archlinux 安裝程序的Install Bootloader?部分執(zhí)行之前建立。 MBR?即 msdos 分區(qū)專用指令

通常情況下,在許多 MBR(或 msdos 磁盤標(biāo)簽)分區(qū)的系統(tǒng)中,只要 DOS 兼容扇區(qū)對齊問題能夠滿足,MBR 后面就有 32KiB 空白(MBR 512字節(jié)區(qū)域之后,第一個分區(qū)之前)。然而,要放置 grub2 的 core.img, 推薦使用 1MiB 或 2 MiB。建議使用支持 1MiB 分區(qū)對齊的分區(qū)工具獲取所需空間,同時滿足其他非 512 字節(jié)簇的問題(與嵌入 core.img 無關(guān))。

如果不雙啟動 MS Windows,建議切換到 GPT 分區(qū)方式 -?無損數(shù)據(jù)切換到 GPT

注意:?轉(zhuǎn)換到 GPT 之前就要創(chuàng)建上面說的 2MiB 分區(qū)。否則 gparted 認(rèn)不出啟動分區(qū),重啟時 grub2 也不知道到哪里找數(shù)據(jù)。 UEFI 系統(tǒng) 創(chuàng)建并掛載 UEFI 系統(tǒng)分區(qū)

Linux 中創(chuàng)建 UEFI 系統(tǒng)分區(qū)?包含了創(chuàng)建指令。創(chuàng)建后將 UEFI 系統(tǒng)分區(qū)掛載到?/boot/efi。這個分區(qū)應(yīng)該是 FAT32 格式,至少 200 MiB 大小。如果已經(jīng)在其它地方掛載了這個分區(qū),用掛載點(diǎn)替換掉下面的?/boot/efi:

# mkdir -p /boot/efi
# mount -t vfat  /boot/efi

創(chuàng)建 /efi 目錄:

# mkdir -p /boot/efi/efi
安裝 在已有系統(tǒng)中安裝grub2 BIOS 系統(tǒng) 備份之前的數(shù)據(jù)

grub 安裝應(yīng)該很順利,但是極個別時候會導(dǎo)致系統(tǒng)無法啟動。所以強(qiáng)烈建議安裝?grub-bios?前備份數(shù)據(jù)。

復(fù)制 grub 模塊和數(shù)據(jù)
# cp -a /boot/grub /path/to/backup/
備份 MBR 和 GRUB-Legacy stage 1.5
# dd if=/dev/sdX of=/path/to/backup/mbr-boot-code bs=440 count=1

現(xiàn)在可以刪除?/boot/grub?了:

# rm -rf /boot/grub

如果后面的指令出了問題,可以通過如下方式恢復(fù):

刪除無法工作的 grub-legacy 或 grub2 文件
# mv /boot/grub /boot/grub.nonfunctional
將備份的 grub 復(fù)制到 /boot
# cp -a /path/to/backup/grub /boot/
將 MBR 和它后面的 62 簇 sda 數(shù)據(jù)替換為備份數(shù)據(jù)(危險!)
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=440 count=1
grub_bios 安裝前

用 pacman 安裝 GRUB2(會替換掉?grub):

# pacman -S grub-bios
注意:?安裝 1.99~rc1-3-x86_64 在一些系統(tǒng)上花了很長時間,因為安裝中調(diào)用的腳步grub-mkconfig,沒有使用?--no-floppy選項,會不斷檢測軟驅(qū))。 注意:?僅安裝軟件不會更新 /boot/grub/core.img 文件和 /boot/grub 中的 grub 模塊。需要用下面的 grub_bios-install 手動更新它們。

裝入 device-mapper 內(nèi)核模塊,有了這個模塊 grub-probe 才能更好的檢測磁盤和分區(qū):

# modprobe dm-mod
Run grub-install
# grub-install --boot-directory=/boot --no-floppy --recheck --debug /dev/sda
# cp /usr/share/grub/{unicode.pf2,ascii.pf2} /boot/grub/

附加說明:若只是生成 core.img 文件而不將 grub2 安裝到 MBR,加上--grub-setup=/bin/true?參數(shù)到 grub2_bios-install:

# grub-install --grub-setup=/bin/true --boot-directory=/boot --no-floppy --recheck /dev/sda

這樣就可以從 grub-legacy 像多內(nèi)核啟動一樣載入 grub2 的 core.img。

/dev/sda是安裝到目的磁盤(第一個 SATA 磁盤的 MBR)。如果/boot?使用?LVM,可以將 GRUB2 安裝到多個物理磁盤。

--no-floppy參數(shù)加上之后就不會查找軟驅(qū),可大大減少該安裝所需時間,并避免了下面問題的發(fā)生:

grub-probe: error: Cannot get the real path of '/dev/fd0'
Auto-detection of a filesystem module failed.
Please specify the module with the option '--modules' explicitly.

執(zhí)行“生成GRUB2配置文件”步驟。

# GRUB_PREFIX="/boot/grub" grub-mkconfig -o /boot/grub/grub.cfg

如果失敗,用下面腳本將/boot/grub/menu.lst?轉(zhuǎn)換為?/boot/grub/grub.cfg

# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg

例如:

/boot/grub/menu.lst
default=0
timeout=5

title  Arch Linux Stock Kernel
root   (hd0,0)
kernel /vmlinuz-linux root=/dev/sda2 ro
initrd /initramfs-linux.img

title  Arch Linux Stock Kernel Fallback
root   (hd0,0)
kernel /vmlinuz-linux root=/dev/sda2 ro
initrd /initramfs-linux-fallback.img
/boot/grub/grub.cfg
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi
set timeout=5

menuentry 'Arch Linux Stock Kernel' {
  set root='(hd0,1)'; set legacy_hdbias='0'
  legacy_kernel   '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'
  legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'
  
}

menuentry 'Arch Linux Stock Kernel Fallback' {
  set root='(hd0,1)'; set legacy_hdbias='0'
  legacy_kernel   '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'
  legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'
}

如果忘記創(chuàng)建/boot/grub/grub.cfg配置文件就重啟,進(jìn)入 GRUB2命令后執(zhí)行:

sh:grub> insmod legacycfg
sh:grub> legacy_configfile ${prefix}/menu.lst

啟動后可以重新修改?/boot/grub/grub.cfg?配置文件。

如果想生成新的GRUB2配置文件,請執(zhí)行:

# grub-mkconfig -o /boot/grub/grub.cfg
注意:?僅在 BIOS 系統(tǒng)工作,UEFI 系統(tǒng)不能這么做。 引導(dǎo)器配置

grub2的配置文件是:

/boot/grub/grub.cfg

Be warned this section is incomplete, feel free to put all missing configuration options here!

(hdn,m)?is the partition?m?on disc?n, partition numbers starting with 1, disc numbers starting with 0set default=n?is the default boot entry, that is choosen after timeout for user actionset timeout=m?– time?m?to wait in seconds for a user selection, before default is bootedmenuentry "str"{entry options}?– title string?str?for a boot entry & basic layoutset root=(hdn,m)?– base partition, where the kernel is stored tolinux /path ro root=/dev/device initrd /initrd.img?– use the root option, if the kernel not placed in /chainloader +1?sets?root?active and gives booting procedure to its boot-loader (for Windows, e.g.)

For UUID entries:

# blkid

This gives you the UUID. We were doing the following command to set the root device:

# root=/dev/device
Instead, replace it with this:
# root=/dev/disk/by-uuid/bc285871-413 .... and so on, for your UUID.
Dual booting

These are the two most common ways of configuring the?grub.cfg?file. For more complex uses, feel free to add descriptions here.

其他GNU/Linux發(fā)行版

這和載入Arch linux一樣。假設(shè)另一個發(fā)行版在分區(qū)[s/h]da2.

menuentry "Other Linux" {
set root=(hd0,2)
linux /boot/vmlinuz (add other options here as required)
initrd /boot/initrd.img (if the other kernel uses/needs one)
}
背景圖像和點(diǎn)陣字體

GRUB2支持背景圖像和pf2格式的點(diǎn)陣字體。unifont字體以unicode.pf2的文件名包含于grub2的安裝包,也可能只是文件名為ascii.pf2的ascii字體。只要載入適合的模塊,Grub2支持tga、png和jpeg的圖像格式。支持的最大分辨率取決于你的硬件配置。下面是一個以tga格式圖片為背景的配置的例子:

if loadfont /usr/share/grub/unicode.pf2?; then
  set gfxmode="1024x768x32"
  insmod gfxterm
  insmod vbe
  terminal_output gfxterm
  if terminal_output gfxterm; then true?; else
     terminal gfxterm
  fi
fi
insmod tga
background_image /boot/grub/archlinux.tga
菜單顏色

想要改變 GRUB2 菜單顏色,你需要在?/boot/grub/grub.cfg?指定一個選項:

set menu_color_normal=light-blue/black
set menu_color_highlight=light-cyan/blue

這是Arch's 官方 GRUB-legacy 的默認(rèn)顏色??捎玫念伾梢栽趆ttp://www.gnu.org/software/grub/manual/html_node/color.html 查看

Hidden menu

For hiding menu put that code in grub.cfg after picture initialization but before?menuentries?(e.g. background_image /boot/grub/archlinux.tga).

  set timeout=5
  echo -n "Press ESC to see the menu... "
if sleep --verbose --interruptible 5?; then
  set timeout=0
fi
設(shè)置 Framebuffer 分辨率

想要在 grub2 中改變 framebuffer 分辨率,在 grub.cfg 中?linux?行加入一行:

video=vesafb:mode=1024x768-32 vga=790

In the preceeding statement, the format mode=- vga= is used where fbresolution follows the following scheme:

+-------------------------------------------------+
     | 640x480    800x600    1024x768   1280x1024
 ----+--------------------------------------------
 256 | 0x301=769  0x303=771  0x305=773   0x307=775
 32K | 0x310=784  0x313=787  0x316=790   0x319=793
 64K | 0x311=785  0x314=788  0x317=791   0x31A=794
 16M | 0x312=786  0x315=789  0x318=792   0x31B=795
+-------------------------------------------------+

Make sure you add the following somewhere, (insmod statements are usually found at the top of the grub.cfg file):

insmod vbe
常見問題 msdos-style Error Message
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding won't be possible!
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.
            However, blocklists are UNRELIABLE and its use is discouraged.
grub-setup: error: If you really want blocklists, use --force.

This error may occur when you try installing GRUB2 in a VMware container. Read more about it?here. Hopefully a fix will be provided soon.

Other

I couldn't figure out how to uninstall grub1, and install grub2 to the MBR, as it isn't being booted by default. It is still booting grub1. So, an easy work-around, is rename?menu.lst.pacsave?or whatever, to?menu.lst?(in /boot/grub/) and for each menu entry that you would like to use grub2, at the end type?"chainloader +1". This will tell grub1 to forward control to grub2. This is an ugly hack though, so I advise setting the?menu.lst's timout as 0, otherwise the total timeout would be grub1's time out + grub2's which, for me would equal more than 18 seconds, which is quite a bit.

P.S. hopefully someone figures out how to pry grub1's dead fingers off of my MBR, and place grub2 on it?:) .

In my case it had to do with my boot partition. Say boot-partition is?(hd0,1)?and your root is?(hd0,3)?(grub2 naming). grub-setup searches for?(hd0,3)/boot/grub/core.img. Just because it's on?(hd0,1)/grub/core.img, it is unable to find it. So I copied the grub-folder to my root partition and everything worked fine:

E.g. (as root:)

# mount /boot
# cp -a /boot/grub /
# umount /boot
# mv /grub /boot/
# grub-install /dev/sda
更多資源 GRUB主頁GRUB維基
本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

CPU親和度通過限制進(jìn)程或線程可以運(yùn)行的CPU核心集合,使得它們只能在指定的CPU核心上執(zhí)行。這可以減少CPU緩存的失效次數(shù),提高緩存命中率,從而提升系統(tǒng)性能。

關(guān)鍵字: Linux 嵌入式

在Linux系統(tǒng)性能優(yōu)化中,內(nèi)存管理與網(wǎng)絡(luò)連接處理是兩大核心領(lǐng)域。vm.swappiness與net.core.somaxconn作為關(guān)鍵內(nèi)核參數(shù),直接影響系統(tǒng)在高負(fù)載場景下的穩(wěn)定性與響應(yīng)速度。本文通過實戰(zhàn)案例解析這兩個...

關(guān)鍵字: Linux 內(nèi)存管理

對于LLM,我使用b谷歌Gemini的免費(fèi)層,所以唯一的成本是n8n托管。在使用了n8n Cloud的免費(fèi)積分后,我決定將其托管在Railway上(5美元/月)。然而,由于n8n是開源的,您可以在自己的服務(wù)器上托管它,而...

關(guān)鍵字: 人工智能 n8n Linux

在Linux系統(tǒng)管理中,權(quán)限控制是安全運(yùn)維的核心。本文通過解析/etc/sudoers文件配置與組策略的深度應(yīng)用,結(jié)合某金融企業(yè)生產(chǎn)環(huán)境案例(成功攔截98.7%的非法提權(quán)嘗試),揭示精細(xì)化權(quán)限管理的關(guān)鍵技術(shù)點(diǎn),包括命令別...

關(guān)鍵字: Linux 用戶權(quán)限 sudoers文件

Linux內(nèi)核中的信號量(Semaphore)是一種用于資源管理的同步原語,它允許多個進(jìn)程或線程對共享資源進(jìn)行訪問控制。信號量的主要作用是限制對共享資源的并發(fā)訪問數(shù)量,從而防止系統(tǒng)過載和數(shù)據(jù)不一致的問題。

關(guān)鍵字: Linux 嵌入式

在云計算與容器化技術(shù)蓬勃發(fā)展的今天,Linux網(wǎng)絡(luò)命名空間(Network Namespace)已成為構(gòu)建輕量級虛擬網(wǎng)絡(luò)的核心組件。某頭部互聯(lián)網(wǎng)企業(yè)通過命名空間技術(shù)將測試環(huán)境資源消耗降低75%,故障隔離效率提升90%。本...

關(guān)鍵字: Linux 云計算

在Linux內(nèi)核4.18+和主流發(fā)行版(RHEL 8/Ubuntu 20.04+)全面轉(zhuǎn)向nftables的背景下,某電商平臺通過遷移將防火墻規(guī)則處理效率提升40%,延遲降低65%。本文基于真實生產(chǎn)環(huán)境案例,詳解從ipt...

關(guān)鍵字: nftables Linux

在Linux設(shè)備驅(qū)動開發(fā)中,等待隊列(Wait Queue)是實現(xiàn)進(jìn)程睡眠與喚醒的核心機(jī)制,它允許進(jìn)程在資源不可用時主動放棄CPU,進(jìn)入可中斷睡眠狀態(tài),待資源就緒后再被喚醒。本文通過C語言模型解析等待隊列的實現(xiàn)原理,結(jié)合...

關(guān)鍵字: 驅(qū)動開發(fā) C語言 Linux

在Unix/Linux進(jìn)程間通信中,管道(pipe)因其簡單高效被廣泛使用,但默認(rèn)的半雙工特性和無同步機(jī)制容易導(dǎo)致數(shù)據(jù)競爭。本文通過父子進(jìn)程雙向通信案例,深入分析互斥鎖與狀態(tài)機(jī)在管道同步中的應(yīng)用,實現(xiàn)100%可靠的數(shù)據(jù)傳...

關(guān)鍵字: 管道通信 父子進(jìn)程 Linux

RTOS :RTOS的核心優(yōu)勢在于其實時性。它采用搶占式調(diào)度策略,確保高優(yōu)先級任務(wù)能夠立即獲得CPU資源,從而在最短時間內(nèi)完成處理。RTOS的實時性是通過嚴(yán)格的時間管理和任務(wù)調(diào)度算法實現(xiàn)的,能夠滿足對時間敏感性要求極高的...

關(guān)鍵字: Linux RTOS
關(guān)閉