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 行。在您的情况下,它在第 1 行。您要么在开头插入了错误文本,要么覆盖了整个文件。

您可以通过再次编辑文件并删除包含*******(或问题中所代表的任何内容)的行以及插入的任何其他不应该存在的行来解决此问题。

通常,您可以在 找到最新下载的适用于您系统的软件包维护者版本的文件/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 论坛主题

相关内容