sudo update-grub:********#:未找到

sudo update-grub:********#:未找到

我想編輯我的 GRUB 設定檔並用來sudo update-grub更新它,但我得到了輸出:

Sourcing file `enter code here`/etc/default/grub
/usr/sbin/grub-mkconfig: 1: /etc/default/grub: *******#: not found

這些 * 是一些類似於我的帳戶密碼的數字。我也嘗試過sudo update-grub2,但也沒有成功。我能做些什麼?

答案1

您的系統上的命令update-grub(實際上是命令的一個小快捷方式)沒有任何問題。您只是在編輯文件時以某種方式grub-mkconfig -o /boot/grub/grub.cfg將一些垃圾文字插入文件中:/etc/default/grub

zanna@toaster:~$ sudo update-grub
Sourcing file `/etc/default/grub'
/usr/sbin/grub-mkconfig: 35: /etc/default/grub: junk: not found

在我的例子中,它junk在第 35 行。

您可以透過再次編輯文件並刪除包含的行*******(或問題中代表的任何內容)以及您插入的不應該存在的任何其他行來解決此問題。

您通常可以在 中找到適用於您的系統的最新下載的軟體包維護者版本的檔案/var/lib/ucf/cache/:etc:default:grub。您可以透過運行來讀取此文件,例如:

cat /var/lib/ucf/cache/:etc:default:grub

您可以透過執行看到您編輯的文件與此文件之間的差異,例如:

diff /var/lib/ucf/cache/:etc:default:grub /etc/default/grub

在最壞的情況下,您需要更換遺失或損壞的設備,/etc/default/grub那麼您可以使用此命令(請注意現有的將/etc/default/grub被此命令悄悄覆蓋)。

sudo cp /var/lib/ucf/cache/:etc:default:grub /etc/default/grub

答案2

檢查該文件/etc/default/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'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
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"

你可以試試:

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

另請參閱這個 Ubuntu 論壇主題

相關內容