安裝Ubuntu之後沒有Window開機選單 [論壇 - Ubuntu安裝問題]


正在瀏覽:   1 名遊客


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



安裝Ubuntu之後沒有Window開機選單
會員一級
註冊日期:
2017/12/6 12:27
所屬群組:
已註冊使用者
等級: 1
HP : 0 / 2
MP : 1 / 42
EXP: 10
離線
小弟把兩個OS安裝到不同的硬碟
Window10安裝到硬碟1,Ubuntu 16.04安裝到硬碟三
我有看過教學
sean@sean-MS-7A37:~$ sudo fdisk -l
[sudo] sean 的密码: 
Disk /dev/sda: 256.2 GiB, 275064201216 bytes, 537234768 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5b3452f3

设备       启动     Start    末尾    扇区   Size Id 类型
/dev/sda1            2048 535601665 535599618 255.4G  7 HPFS/NTFS/exFAT
/dev/sda2       535603200 537229311   1626112   794M 27 Hidden NTFS WinRE


Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x5b3452fb

设备       启动   Start     末尾     扇区  Size Id 类型
/dev/sdb1  *       2048    1026047    1024000  500M  7 HPFS/NTFS/exFAT
/dev/sdb2       1026048 1953519615 1952493568  931G  7 HPFS/NTFS/exFAT


Disk /dev/sdc: 256.2 GiB, 275064201216 bytes, 537234768 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 3EE96F14-69BE-41E3-8619-909286A983C7

设备           Start    末尾    扇区   Size 类型
/dev/sdc1       2048   1050623   1048576   512M EFI System
/dev/sdc2    1050624 126460040 125409417  59.8G Linux filesystem
/dev/sdc3  503779328 537233407  33454080    16G Linux swap
/dev/sdc4  253227008 503779327 250552320 119.5G Linux filesystem
/dev/sdc5  126461952 253227007 126765056  60.5G Linux filesystem

Partition table entries are not in disk order.


然後我去改了grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'
# 

title Window10
map(hd2)(hd0)
map(hd0)(hd2)
rootnoverify(hd0,0)
chainloader+1
makeactive

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"


要update的時候發生錯誤

sean@sean-MS-7A37:~$ sudo update-grub
/usr/sbin/grub-mkconfig: 7: /etc/default/grub: title: not found


請問該如何解決

2017/12/6 12:41
應用擴展 工具箱
回覆: 安裝Ubuntu之後沒有Window開機選單
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 36
HP : 0 / 898
MP : 664 / 28684
EXP: 92
離線
SEAN208208 寫到:
小弟把兩個OS安裝到不同的硬碟
Window10安裝到硬碟1,Ubuntu 16.04安裝到硬碟三
我有看過教學
sean@sean-MS-7A37:~$ sudo fdisk -l
[sudo] sean 的密码:
Disk /dev/sda: 256.2 GiB, 275064201216 bytes, 537234768 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5b3452f3

设备       启动     Start    末尾    扇区   Size Id 类型
/dev/sda1            2048 535601665 535599618 255.4G  7 HPFS/NTFS/exFAT
/dev/sda2       535603200 537229311   1626112   794M 27 Hidden NTFS WinRE


Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x5b3452fb

设备       启动   Start     末尾     扇区  Size Id 类型
/dev/sdb1  *       2048    1026047    1024000  500M  7 HPFS/NTFS/exFAT
/dev/sdb2       1026048 1953519615 1952493568  931G  7 HPFS/NTFS/exFAT


Disk /dev/sdc: 256.2 GiB, 275064201216 bytes, 537234768 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 3EE96F14-69BE-41E3-8619-909286A983C7

设备           Start    末尾    扇区   Size 类型
/dev/sdc1       2048   1050623   1048576   512M EFI System
/dev/sdc2    1050624 126460040 125409417  59.8G Linux filesystem
/dev/sdc3  503779328 537233407  33454080    16G Linux swap
/dev/sdc4  253227008 503779327 250552320 119.5G Linux filesystem
/dev/sdc5  126461952 253227007 126765056  60.5G Linux filesystem

Partition table entries are not in disk order.


然後我去改了grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'
#


title Window10
map(hd2)(hd0)
map(hd0)(hd2)
rootnoverify(hd0,0)
chainloader+1
makeactive


GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"


要update的時候發生錯誤

sean@sean-MS-7A37:~$ sudo update-grub
/usr/sbin/grub-mkconfig: 7: /etc/default/grub: title: not found


請問該如何解決



先提如何把上面提到的錯誤先修正。

您上面是編輯「/etc/default/grub」這個檔案,上面有一部分藍色字如下



title Window10
map(hd2)(hd0)
map(hd0)(hd2)
rootnoverify(hd0,0)
chainloader+1
makeactive




這一段不能寫在「/etc/default/grub」這個檔案,所以請把上面這一段移除

比較有可能的,是寫在「/boot/grub/grub.cfg」這個檔案。
(註:藍色字那段也不是寫在「/boot/grub/grub.cfg」,見「#6」)

另外若直接修改「/boot/grub/grub.cfg」這個檔案,有一些要注意的,
可以參考之前的幾篇分析
* 「#10 回覆: 文字界面開機
* 「#11 回覆: 文字界面開機
* http://samwhelp.github.io/book-ubuntu-qna/read/case/linux-package/
(註:建議不用直接修改「/boot/grub/grub.cfg」,
可以將客製的「menu entry」
,寫在「/etc/grub.d/40_custom」或「/boot/grub/custom.cfg」,見「#7」)

關於「/etc/default/grub」這個檔案的參數,可以參考下面這個文件
https://www.gnu.org/software/grub/manual/grub/html_node/Simple-configuration.html#Simple-configuration
或是執行「info -f grub -n 'Simple configuration'」也可以看到上面的文件,
上面這個指令在「/etc/default/grub」裡面開頭的註解看到的,我在上面有標記綠色字

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

另外聲明一下,我還沒深入去研究「GRUB」,所以我有可能講錯
所以我提到的,只是大略的概念,您就當參考,
細節部份還需要您自行模索

我之前在網路上有發現一篇「GRUB架構解析」,雖然我還沒仔細去閱讀,
不過初步來看,應該是很好的參考資料。

或是「鳥哥的 Linux 私房菜 / 第十九章、開機流程、模組管理與 Loader / 19.3 Boot loader: Grub2

而「GRUB」的文件,則是可以從下面的連結找到

* https://www.gnu.org/software/grub/grub-documentation.html

關於「GRUB」有一些討論案例和參考連結,我之前有紀錄在「[索引] 開機流程」 。

因為我還沒有去深究「GRUB」,我目前會的只有幾個簡易的操作步驟,
可以參考我之前的討論回覆,例如

* 「#2 回覆: Ubuntu 14.04LTS 開機選單的問題?


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

## Manpage

$ man update-grub
$ man grub-install

## 相關檔案

* /etc/default/grub
* /boot/grub/grub.cfg

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

一般狀況下的操作步驟


* 編輯檔案: /etc/default/grub
* 執行指令update-grub
* 產生檔案: /boot/grub/grub.cfg



以下是操作參考步驟

## 安裝GRUB或重新安裝GRUB

執行


$ sudo grub-install /dev/sdc



關於「/dev/sdc」請依照您自己實際的狀況而定,有可能是「/dev/sda」,「/dev/sdb」... 。


## 編輯參數設定

執行下面指令,編輯「/etc/default/grub」這個檔案。


$ sudo vi /etc/default/grub



編輯「/etc/default/grub」的內容,舉例如下


GRUB_TIMEOUT=0
GRUB_DISABLE_OS_PROBER=true
# GRUB_OS_PROBER_SKIP_LIST
...略...


## 產生GRUB設定檔

執行下面指令,重新產生「GRUB的設定檔」,也就是產生「/boot/grub/grub.cfg」這個檔案


$ sudo update-grub




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

以上提供參考

報告完畢


2017/12/6 15:51
應用擴展 工具箱
回覆: 安裝Ubuntu之後沒有Window開機選單
會員一級
註冊日期:
2017/12/6 12:27
所屬群組:
已註冊使用者
等級: 1
HP : 0 / 2
MP : 1 / 42
EXP: 10
離線
感謝大大 我來試看看><

2017/12/7 19:47
應用擴展 工具箱
回覆: 安裝Ubuntu之後沒有Window開機選單
會員一級
註冊日期:
2017/12/6 12:27
所屬群組:
已註冊使用者
等級: 1
HP : 0 / 2
MP : 1 / 42
EXP: 10
離線
大大你好:

我使用了下面的指令更新
$ sudo apt-get update

$ sudo apt-get upgrade

$ sudo apt-get dist-upgrade


使用了sudo gedit /boot/grub/grub.cf 來編輯檔案

加入了

title Window10
map(hd2)(hd0)
map(hd0)(hd2)
rootnoverify(hd0,0)
chainloader+1
makeactive

並且輸入
$ sudo update-grub
$ sudo grub-install /dev/sdc

但重開機還是沒有選單><

有人說不要再grub.cf理面編輯
還是要編輯「/etc/default/grub」的內容
GRUB_TIMEOUT=0
GRUB_DISABLE_OS_PROBER=true
# GRUB_OS_PROBER_SKIP_LIST

2017/12/18 20:27
應用擴展 工具箱
回覆: 安裝Ubuntu之後沒有Window開機選單
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 36
HP : 0 / 898
MP : 664 / 28684
EXP: 92
離線
SEAN208208 寫到:
大大你好:

我使用了下面的指令更新
$ sudo apt-get update

$ sudo apt-get upgrade

$ sudo apt-get dist-upgrade


使用了sudo gedit /boot/grub/grub.cf 來編輯檔案

加入了

title Window10
map(hd2)(hd0)
map(hd0)(hd2)
rootnoverify(hd0,0)
chainloader+1
makeactive

並且輸入
$ sudo update-grub
$ sudo grub-install /dev/sdc

但重開機還是沒有選單><

有人說不要再grub.cf理面編輯
還是要編輯「/etc/default/grub」的內容
GRUB_TIMEOUT=0
GRUB_DISABLE_OS_PROBER=true
# GRUB_OS_PROBER_SKIP_LIST



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

一開始我要先跟您說聲抱歉

我在「#2」沒有說明清楚。

關於


使用了sudo gedit /boot/grub/grub.cf 來編輯檔案

加入了


title Window10
map(hd2)(hd0)
map(hd0)(hd2)
rootnoverify(hd0,0)
chainloader+1
makeactive




我在「Arch Wiki / GRUB (正體中文)」發現到您藍色字的那段語法,
應該不是直接寫在「/etc/default/grub」,
也不是直接寫在「/boot/grub/grub.cfg」,
而是需要透過「grub-menulst2cfg」,做轉換 (見#6)。


NAME

grub-menulst2cfg - transform legacy menu.lst into grub.cfg




我對這方面沒有研究,所以我並沒有確認上面藍色字那段的設定是否能讓開機選單,可以找到Windows的系統。
我其實並不了解您寫的那段語法。
所以我要跟您說聲抱歉。

我上面「#2」要表達的是,您要自己設定,要編輯「/boot/grub/grub.cfg」這個檔案如此而已。
(註:剛發現,客製的可以寫在「/etc/grub.d/40_custom」這個檔案,見最下方)

至於您要設定「Windows」開機選項,則是需要您再自行研究
我目前並沒有Windows的系統,所以無法幫您測試。
對這部份手動設定,我也沒有概念,和相關的經驗。


以前我的經驗
我通常並沒有去編輯/boot/grub/grub.cfg」,
也沒有去設定/etc/default/grub的內容

因為正常的狀況下
我只要執行「sudo update-grub」,
程式自然就會偵測到「Windows」的系統,
然後程式就會產生新的「/boot/grub/grub.cfg」檔案,
這樣開機選單,就會有「Widnows」開機選項可選,

然而我也只會這樣的操作步驟,遇到其他的例外狀況,我就不會了
我之前在上面的「#2」有特別標紅字。

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

另外關於


有人說不要再grub.cf理面編輯
還是要編輯「/etc/default/grub」的內容
GRUB_TIMEOUT=0
GRUB_DISABLE_OS_PROBER=true
# GRUB_OS_PROBER_SKIP_LIST


您應該被我誤導了,
我上面只是舉例,並沒有說這樣的設定,就可以達到您原本的需求,
所以我針對這部份,再次跟您道歉。

關於「GRUB_DISABLE_OS_PROBER=true」這個參數的作用,

您可以參考

https://www.gnu.org/software/grub/manual/grub/html_node/Simple-configuration.html#Simple-configuration

裡面有說明如下



‘GRUB_DISABLE_OS_PROBER’

Normally, grub-mkconfig will try to use the external os-prober program, if installed, to discover other operating systems installed on the same system and generate appropriate menu entries for them. Set this option to ‘true’ to disable this.





若您設定「GRUB_DISABLE_OS_PROBER=true」,
這樣我剛剛提到的會自動偵測其他作業系統存在的功能就會被停掉了。

所以在設定「/etc/default/grub」時,請您要弄清楚該參數的作用,
再次說聲抱歉,是我誤導您了。

也可以參考我上面「#2」貼的另一個參考連結「GRUB架構解析」,其中一個章節,也有相關的參數說明。

https://hugh712.gitbooks.io/grub/content/configuration-parameters.html#GRUB_DISABLE_OS_PROBER

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

關於如何手動設定「Windows」的選單,
這部份可能就需要其他有經驗的人來解答了
印象中,在這個論壇,以前好像有看到相關的討論,
之前回覆您,我有試著找過那篇討論,
可能是我之前忘了把那篇連結,紀錄在「[索引] 開機流程」,
我目前一時找不到該篇討論,歹勢拉。


剛我有找到「GRUB架構解析」的另一個章節,
https://hugh712.gitbooks.io/grub/content/general-boot-methods.html
這其實我也不懂,也沒實際去測試就請您當參考,由您自行做實驗確認是否可行了


或是參考「鳥哥的 Linux 私房菜 / 第十九章、開機流程、模組管理與 Loader / 19.3 Boot loader: Grub2 / 選單建置的腳本 /etc/grub.d/*

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

另外找到「GRUB架構解析」的下面兩個頁面
https://hugh712.gitbooks.io/grub/content/configuration-files.html
https://hugh712.gitbooks.io/grub/content/multi-boot-manual-config.html
裡面有提到,可以將「客製的menu entry」寫在「/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.




簡單做個實驗,將「/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.

## 客製的內容




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


$ sudo update-grub



然後觀察「/boot/grub/grub.cfg」的內容,會看到其中有一段如下


### 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 ###




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

執行


$ whereis update-grub



顯示


update-grub: /usr/sbin/update-grub /usr/share/man/man8/update-grub.8.gz



執行下面指令,觀看「/usr/sbin/update-grub」這個檔案的內容


$ cat /usr/sbin/update-grub



顯示


#!/bin/sh
set -e
exec grub-mkconfig -o /boot/grub/grub.cfg "$@"



所以「update-grub」也只是呼叫「grub-mkconfig

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

執行


$ whereis grub-mkconfig



顯示


grub-mkconfig: /usr/sbin/grub-mkconfig /usr/share/man/man8/grub-mkconfig.8.gz



執行


$ file /usr/sbin/grub-mkconfig



顯示


/usr/sbin/grub-mkconfig: POSIX shell script, ASCII text executable



所以可以直接執行下面指令,觀看「/usr/sbin/grub-mkconfig」如何實做


$ less /usr/sbin/grub-mkconfig



內容有點多,所以就不貼上來了。

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

關於「grub-install」,

則是可以參考「GRUB架構解析」的下面這個頁面

* https://hugh712.gitbooks.io/grub/content/installing-grub-using-grub-install.html

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

## 相關的文件

我在上面「#2」有貼下面這個連結

https://www.gnu.org/software/grub/grub-documentation.html

從上面這個連結,可以找到下面的連結

* https://www.gnu.org/software/grub/manual/grub/
* https://www.gnu.org/software/grub/manual/grub/html_node/index.html
* https://www.gnu.org/software/grub/manual/grub/grub.html

或是也可以直接在「Terminal」,執行「$ info grub」來閱讀,

若要指定某個「node」來閱讀,例如執行


$ info -f grub -n 'Simple configuration'

$ info -f grub -n 'Installing GRUB using grub-install'

$ info -f grub -n 'Chain-loading'

$ info -f grub -n 'Multi-boot manual config'

$ info -f grub -n 'menuentry'

$ info -f grub -n 'Invoking grub-install'

$ info -f grub -n 'Invoking grub-mkconfig'




### Ubuntu TW Wiki

* GRUB 2 中文指南


### Ubuntu Community Help Wiki

* https://help.ubuntu.com/community/Grub2
* https://help.ubuntu.com/community/Grub2/CustomMenus


### 在「Arch Wiki」那也可以找到參考文件

* https://wiki.archlinux.org/index.php/GRUB_(正體中文)
* https://wiki.archlinux.org/index.php/GRUB


### 鳥哥的 Linux 私房菜

* 第十九章、開機流程、模組管理與 Loader / 19.3 Boot loader: Grub2


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

以上釐清

報告完畢


2017/12/18 22:42
應用擴展 工具箱
回覆: 安裝Ubuntu之後沒有Window開機選單
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 36
HP : 0 / 898
MP : 664 / 28684
EXP: 92
離線
延續上面「#5

提到的

samwhelp 寫到:
我在「Arch Wiki / GRUB (正體中文)」發現到您藍色字的那段語法,
應該不是直接寫在「/etc/default/grub」,
也不是直接寫在「/boot/grub/grub.cfg」,
而是需要透過「grub-menulst2cfg」,做轉換。


NAME

grub-menulst2cfg - transform legacy menu.lst into grub.cfg





來做點小實驗

因為只是做實驗,所以先產生一個做實驗的資料夾


$ mkdir -p ~/tmp



並且切換到該資料夾「~/tmp」


$ cd ~/tmp



然後產生一個檔案「~/tmp/menu.lst」,內容如下,也就是您原本提供的內容



title Window10
map(hd2)(hd0)
map(hd0)(hd2)
rootnoverify(hd0,0)
chainloader+1
makeactive





然後執行下面指令


$ grub-menulst2cfg menu.lst test.cfg



就會產生一個檔案「test.cfg」,也就是路徑「~/tmp/test.cfg」。

而產生出來的「test.cfg」的內容如下


menuentry 'Window10' {
  # Unsupported legacy command: map(hd2)(hd0)

  # Unsupported legacy command: map(hd0)(hd2)

  # Unsupported legacy command: rootnoverify(hd0,0)

  # Unsupported legacy command: chainloader+1

  parttool "$root" boot+
}




一些細節我也不清楚,

所以您可能要再研究看看,

猜測「menu.lst」應該是舊版的GRUB在使用的

* Arch Wiki / GRUB (正體中文) / 設置(Configuration)
* https://zh.wikipedia.org/zh-tw/GNU_GRUB


請再參考上面的「#5」和「#2

有列一些其他相關的參考連結。

以上補充說明。

報告完畢。


2017/12/19 8:33
應用擴展 工具箱
回覆: 安裝Ubuntu之後沒有Window開機選單
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 36
HP : 0 / 898
MP : 664 / 28684
EXP: 92
離線
上面一直忘了提我測試的環境是

* Ubuntu 17.10
* grub2-common 2.02~beta3-4ubuntu7
* grub-common 2.02~beta3-4ubuntu7

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

延續「#5」。

原本有提到

可以將「客製的 menu entry」直接寫在「/etc/grub.d/40_custom」,
然後執行「$ sudo update-grub」,就會重新產生新的「/boot/grub/grub.cfg」,
重新開機後,選單就會有所不同了。

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

稍微看了「這篇」,

剛做了點測試,

另外也可以將「客製的 menu entry」直接寫在「/boot/grub/custom.cfg」這個檔案,
跟上面的「/etc/grub.d/40_custom」這個方式不同的是,
改完「/boot/grub/custom.cfg」這個檔案,並不用重新執行「$ sudo update-grub」。
重新開機後,選單就會有所不同了。

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

上面兩個方式,在做實驗的時候,可以直接複製「/boot/grub/grub.cfg」裡面其中一個「menuentry」,
然後修改「title」那個欄位,就可以用來做實驗了。

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

而「/boot/grub/custom.cfg」這個檔案的機制,是根據「/etc/grub.d/41_custom」的機制而來。


執行下面指令,觀看「/etc/grub.d/41_custom」


$ cat /etc/grub.d/41_custom



顯示


#!/bin/sh
cat <<EOF
if [ -f  \${config_directory}/custom.cfg ]; then
  source \${config_directory}/custom.cfg
elif [ -z "\${config_directory}" -a -f  \$prefix/custom.cfg ]; then
  source \$prefix/custom.cfg;
fi
EOF




然後若沒有修改過「/etc/grub.d/41_custom」。
重複的執行「$ sudo update-grub」。
都會在「/boot/grub/grub.cfg」看到其中有一段內容如下


### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###




推測這也是為啥,修改完「/boot/grub/custom.cfg」這個檔案,
不需要重新執行「$ sudo update-grub」,
重開機就會有新的選單。

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

以上新的發現,提供參考

報告完畢

2017/12/19 17:57
應用擴展 工具箱


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


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