如何設定雙系統開機選項 [論壇 - Ubuntu安裝問題]


正在瀏覽:   1 名遊客


 到底部   前一個主題   下一個主題  [無發表權] 請登錄或者註冊

(1) 2 »


如何設定雙系統開機選項
會員一級
註冊日期:
2022/2/16 14:14
所屬群組:
已註冊使用者
等級: 1
HP : 0 / 0
MP : 0 / 2
EXP: 2
離線
單一PC中安裝了ubuntu20.04與win11在兩不同硬碟.
不想進BIOS去選擇OS.
想在ubuntu開機進入的選單中,可選擇OS.
grub相關開機內容已更改,開機選單有Win11,但就是無法讀取windows的硬碟進入系統,請問各位大大,原因為何?Tks

2022/2/16 16:55
應用擴展 工具箱
回覆: 如何設定雙系統開機選項
會員五級
註冊日期:
2009/10/29 4:50
所屬群組:
已註冊使用者
等級: 41
HP : 204 / 1021
MP : 928 / 40609
EXP: 87
離線
因為Windows的「快速啟動」沒關?

2022/2/17 4:37
應用擴展 工具箱
回覆: 如何設定雙系統開機選項
會員一級
註冊日期:
2022/2/16 14:14
所屬群組:
已註冊使用者
等級: 1
HP : 0 / 0
MP : 0 / 2
EXP: 2
離線
在ubuntu開機進入的選單中有選單可選,但點選Windows11選項,點選後一直停在選單頁面,無法進入Win OS

2022/2/17 13:07
應用擴展 工具箱
回覆: 如何設定雙系統開機選項
會員三級
註冊日期:
2012/4/26 9:45
所屬群組:
已註冊使用者
等級: 12
HP : 0 / 293
MP : 62 / 9514
EXP: 72
離線
重新執行一次 update-grub2 試看看,也許你有動到win11過。

2022/2/18 20:05
應用擴展 工具箱
回覆: 如何設定雙系統開機選項
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29295
EXP: 6
離線
## 前提

以下提供您除錯的思路,
並且導引您去閱讀相關的文章,
讓您有個探索的方向,

## 索引

我會分批貼上,索引如下

* #6 - 關於「/boot/grub/grub.cfg」這個檔案
* #7 - 關於「/etc/default/grub」這個檔案
* #8 - 關於「/etc/grub.d」這個資料夾
* #9 - 自訂「Grub開機選項(Grub Menu Entry)」
* #10 - 關於「/etc/grub.d/40_custom」這個檔案
* #11 - 關於「/boot/grub/custom.cfg」這個檔案
* #12 - 關於「/etc/grub.d/30_os-prober」這個檔案


相關連結,也紀錄在「[索引] 開機流程」。

相關筆記,則是「grub 探索筆記」。

2022/2/25 10:47
應用擴展 工具箱
回覆: 如何設定雙系統開機選項
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29295
EXP: 6
離線
## 相關文章

* GRUB架構解析 / 組態結構
* GRUB架構解析 / GRUB的整體流程圖
* GRUB架構解析 / GRUB Legacy和GRUB2的主要差異


## 聚焦學習

Grub會根據「/boot/grub/grub.cfg」這個設定檔來運作,

不過在實務上,一般不會直接直接去修改「/boot/grub/grub.cfg」這個檔案。

因為Grub有設計一個機制,

會根據「/etc/default/grub」這個檔案裡面的參數,

以及根據「/etc/grub.d」這個資料夾裡面的腳本(Shell Script),

然後透過「update-grub」或是「grub-mkconfig」這兩個指令,

來產生「/boot/grub/grub.cfg」這個檔案。


## 相關文件

* $ man update-grub
* $ man grub-mkconfig
* $ info grub -n 'Simple configuration'
* $ info grub -n 'Invoking grub-mkconfig'

2022/2/25 10:49
應用擴展 工具箱
回覆: 如何設定雙系統開機選項
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29295
EXP: 6
離線
## 相關連結

* GRUB架構解析 / /etc/default/grub的所有可用參數
* $ info grub -n 'Simple configuration'


## 關於「/etc/default/grub」

延續「#6」提到的,

在實務上,會先修改「/etc/default/grub」這個檔案,

然後再執行下面指令,產生新的「/boot/grub/grub.cfg」。

執行

sudo update-grub



或是執行


sudo grub-mkconfig -o /boot/grub/grub.cfg



================================================================================

## 使用案例

最常見的使用案例,是設定採用「Grub的佈景主題」,

就會修改「/etc/default/grub」這個檔案。

加入類似下面這一行,


GRUB_THEME="/boot/grub/themes/dracula/theme.txt"



接著執行下面指令,產生新的「/boot/grub/grub.cfg」。


sudo update-grub



詳細步驟,請參考另一篇「設定採用佈景主題]」的說明。

2022/2/25 10:57
應用擴展 工具箱
回覆: 如何設定雙系統開機選項
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29295
EXP: 6
離線
## 關於「/etc/grub.d」


延續「#6」提到的,

在「/etc/grub.d」裡面有放置很多「執行腳本(Shell Script)」

執行下面指令,觀看「/etc/grub.d」有哪些檔案


ls /etc/grub.d -1



顯示


00_header
05_debian_theme
10_linux
10_linux_zfs
20_linux_xen
20_memtest86+
30_os-prober
30_uefi-firmware
40_custom
41_custom
README



執行下面指令,觀看「README」




All executable files in this directory are processed in shell expansion order.

  00_*: Reserved for 00_header.
  10_*: Native boot entries.
  20_*: Third party apps (e.g. memtest86+).

The number namespace in-between is configurable by system installer and/or
administrator.  For example, you can add an entry to boot another OS as
01_otheros, 11_otheros, etc, depending on the position you want it to occupy in
the menu; and then adjust the default setting via /etc/default/grub.





## 相關連結

* Ubuntu Package / grub-common / filelist
* grub/util/grub.d
* grub/util/grub.d


================================================================================

延續「#6」提到的,

執行「sudo update-grub」,

會根據「/etc/grub.d」裡面的「執行腳本(Shell Script)」,

來產生新的「/boot/grub/grub.cfg」。

先簡易來探索「/boot/grub/grub.cfg」,

執行


grep '### BEGIN' /boot/grub/grub.cfg



顯示


### BEGIN /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/10_linux_zfs ###
### BEGIN /etc/grub.d/20_linux_xen ###
### BEGIN /etc/grub.d/20_memtest86+ ###
### BEGIN /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/30_uefi-firmware ###
### BEGIN /etc/grub.d/40_custom ###
### BEGIN /etc/grub.d/41_custom ###



執行


grep '### END' /boot/grub/grub.cfg



顯示


### END /etc/grub.d/00_header ###
### END /etc/grub.d/05_debian_theme ###
### END /etc/grub.d/10_linux ###
### END /etc/grub.d/10_linux_zfs ###
### END /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_memtest86+ ###
### END /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_uefi-firmware ###
### END /etc/grub.d/40_custom ###
### END /etc/grub.d/41_custom ###



執行


grep '### BEGIN /etc/grub.d/40_custom ###' /boot/grub/grub.cfg -A 5



顯示


### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

### END /etc/grub.d/40_custom ###


2022/2/25 11:04
應用擴展 工具箱
回覆: 如何設定雙系統開機選項
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29295
EXP: 6
離線
## 相關文章

* GRUB架構解析 / 自制開機menu組態
* GRUB架構解析 / GRUB 可用的命令


## 聚焦學習

延續之前提到的,透過「sudo update-grub」,會產生新的「/boot/grub/grub.cfg」,

而過程中,會偵測硬碟裡既有的系統,

進而產生相對應的「Grub開機選項(Grub Menu Entry)」,這些都紀錄在「/boot/grub/grub.cfg」。

另外「Grub」也提供一個機制,讓您可以自訂自己的「Grub開機選項(Grub Menu Entry)」,

有提供兩種方式來修改,

* 一種是修改「/etc/grub.d/40_custom」這個檔案,修改後需要執行「sudo update-grub」

* 一種是修改「/boot/grub/custom.cfg」這個檔案,修改後不需要執行「sudo update-grub」。


## 使用案例

* GRUB Boot ISO 範例

## 相關文件

* $ info grub -n 'Simple configuration'

2022/2/25 11:10
應用擴展 工具箱
回覆: 如何設定雙系統開機選項
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29295
EXP: 6
離線
## 關於「/etc/grub.d/40_custom」

延續「#9」提到的,提供修改「/etc/grub.d/40_custom」的使用方式。

舉例:

修改「/etc/grub.d/40_custom」,內容如下


#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.


menuentry 'Reboot Computer' --class restart {
	reboot
}


menuentry 'Shutdown Computer' --class shutdown {
	halt
}



特別要注意的是,最前面兩行,一定要保留


#!/bin/sh
exec tail -n +3 $0




修改後,需要執行「sudo update-grub」,就會產生新的「/boot/grub/grub.cfg」。

可以執行下面指令,觀察「/boot/grub/grub.cfg」的內容,來確認。


grep '### BEGIN /etc/grub.d/40_custom ###' /boot/grub/grub.cfg -A 14



顯示


### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.


menuentry 'Reboot Computer' --class restart {
	reboot
}


menuentry 'Shutdown Computer' --class shutdown {
	halt
}
### END /etc/grub.d/40_custom ###




## 完整範例

* Demo Grub Boot Menu Entry
* Demo Grub Boot ISO / Ubuntu

## 相關文件

* $ info grub -n 'Simple configuration'
* $ info grub -n 'menuentry'
* $ info grub -n 'halt'
* $ info grub -n 'reboot'


## 相關文章

* GRUB架構解析 / 自制開機menu組態
* GRUB架構解析 / GRUB 可用的命令

2022/2/25 11:16
應用擴展 工具箱

(1) 2 »

 [無發表權] 請登錄或者註冊


可以查看帖子.
不可發帖.
不可回覆.
不可編輯自己的帖子.
不可刪除自己的帖子.
不可發起投票調查.
不可在投票調查中投票.
不可上傳附件.
不可不經審核直接發帖.