由于 GRUB 文件错误,现在无法安装任何软件包

由于 GRUB 文件错误,现在无法安装任何软件包
$ cat /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 config="quiet splash acpi_backlight=vendor"
GRUB_CMDLINE_LINUX=""uration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT

# 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 update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-42-generic
Found initrd image: /boot/initrd.img-5.4.0-42-generic
Found linux image: /boot/vmlinuz-5.4.0-40-generic
Found initrd image: /boot/initrd.img-5.4.0-40-generic
Adding boot menu entry for UEFI Firmware Settings
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 172
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
$ sudo dpkg --configure -a

Setting up linux-image-5.4.0-42-generic (5.4.0-42.46) ...
Processing triggers for linux-image-5.4.0-42-generic (5.4.0-42.46) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.4.0-42-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.4.0-42-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-42-generic
Found initrd image: /boot/initrd.img-5.4.0-42-generic
Found linux image: /boot/vmlinuz-5.4.0-40-generic
Found initrd image: /boot/initrd.img-5.4.0-40-generic
Adding boot menu entry for UEFI Firmware Settings
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 172
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-5.4.0-42-generic (--configure):
 installed linux-image-5.4.0-42-generic package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-image-5.4.0-42-generic
$ sudo apt install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-image-5.4.0-26-generic
0 upgraded, 0 newly installed, 1 to remove and 71 not upgraded.
2 not fully installed or removed.
After this operation, 11.7 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 232459 files and directories currently installed.)
Removing linux-image-5.4.0-26-generic (5.4.0-26.30) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.4.0-26-generic
/etc/kernel/postrm.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-42-generic
Found initrd image: /boot/initrd.img-5.4.0-42-generic
Found linux image: /boot/vmlinuz-5.4.0-40-generic
Found initrd image: /boot/initrd.img-5.4.0-40-generic
Adding boot menu entry for UEFI Firmware Settings
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 172
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 1
dpkg: error processing package linux-image-5.4.0-26-generic (--remove):
 installed linux-image-5.4.0-26-generic package post-removal script subpro
cess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-image-5.4.0-26-generic
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
$ sudo mv /var/lib/dpkg/info/* /tmp
sudo: unable to execute /usr/bin/mv: Argument list too long

答案1

编辑时似乎出了点问题/etc/default/grub。请再次编辑并将第 5-12 行更改为如下内容:

#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX="quiet splash acpi_backlight=vendor"
GRUB_CMDLINE_LINUX_DEFAULT=""

相关内容