Grub 和 linux-image 问题?

Grub 和 linux-image 问题?

我已经遇到这个问题有一段时间了,但不知道如何解决这个问题,因为我对 Linux 还比较陌生。每当我尝试通过终端安装某些东西时,我都会在最后看到以下几行:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
wget is already the newest version (1.20.3-1ubuntu1).
wget set to manually installed.
build-essential is already the newest version (12.8ubuntu1.1).
build-essential set to manually installed.
libssl-dev is already the newest version (1.1.1f-1ubuntu2.4).
libssl-dev set to manually installed.
The following package was automatically installed and is no longer required:
  linux-modules-5.8.0-49-generic
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libncurses-dev libnspr4-dev
Suggested packages:
  ncurses-doc readline-doc
The following packages will be REMOVED:
  linux-image-5.8.0-49-generic
The following NEW packages will be installed:
  libffi-dev libgdbm-dev libncurses-dev libncurses5-dev libnspr4-dev libnss3-dev libreadline-dev zlib1g-dev
0 upgraded, 8 newly installed, 1 to remove and 7 not upgraded.
3 not fully installed or removed.
Need to get 1.214 kB of archives.
After this operation, 2.901 kB disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libgdbm-dev amd64 1.18.1-5 [83,4 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 libncurses-dev amd64 6.2-0ubuntu2 [339 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/main amd64 libncurses5-dev amd64 6.2-0ubuntu2 [976 B]
Get:4 http://archive.ubuntu.com/ubuntu focal/main amd64 libnspr4-dev amd64 2:4.25-1 [206 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libnss3-dev amd64 2:3.49.1-1ubuntu1.5 [231 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/main amd64 libreadline-dev amd64 8.0-4 [141 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 zlib1g-dev amd64 1:1.2.11.dfsg-2ubuntu1.2 [155 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 libffi-dev amd64 3.3-4 [57,0 kB]
Fetched 1.214 kB in 0s (2.750 kB/s)   
(Reading database ... 290766 files and directories currently installed.)
Removing linux-image-5.8.0-49-generic (5.8.0-49.55~20.04.1) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-5.8.0-49-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 ...
Script `/boot/grub/grub.cfg.new' contains no commands and will do nothing
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.8.0-49-generic (--remove):
 installed linux-image-5.8.0-49-generic package post-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-image-5.8.0-49-generic
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

不幸的是它不会告诉我错误行号,所以我不知道要寻找什么。

这是我的内容/etc/default/grub

GNU nano 4.8                                                                                 /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=0
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_DISABLGNU nano 4.8                                                                                 /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=0
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"E_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 nano /etc/grub.d/*

nano 打开并在底部给出以下消息:

[ Directory '/etc/grub.d' does not exist ]

And `dpkg -C`:
The following packages are only half configured, probably due to problems
configuring them the first time.  The configuration should be retried using
dpkg --configure <package> or the configure menu option in dselect:
 grub-pc              GRand Unified Bootloader, version 2 (PC/BIOS version)
 linux-image-5.8.0-53-generic Signed kernel image generic

The following packages are only half installed, due to problems during
installation.  The installation can probably be completed by retrying it;
the packages can be removed using dselect or dpkg --remove:
 linux-image-5.8.0-49-generic Signed kernel image generic

dpkg --configure按照上面输出中的建议运行grub-pc和 的命令会给出:linux-image

$ sudo dpkg --configure grub-pc
[sudo] password for reagan: 
Setting up grub-pc (2.04-1ubuntu26.11) ...
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Script `/boot/grub/grub.cfg.new' contains no commands and will do nothing
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.
dpkg: error processing package grub-pc (--configure):
 installed grub-pc package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 grub-pc

$ sudo dpkg --configure linux-image-5.8.0-53-generic
    Setting up linux-image-5.8.0-53-generic (5.8.0-53.60~20.04.1) ...
    Processing triggers for linux-image-5.8.0-53-generic (5.8.0-53.60~20.04.1) ...
    /etc/kernel/postinst.d/dkms:
     * dkms: running auto installation service for kernel 5.8.0-53-generic
       ...done.
    /etc/kernel/postinst.d/initramfs-tools:
    update-initramfs: Generating /boot/initrd.img-5.8.0-53-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 ...
    Script `/boot/grub/grub.cfg.new' contains no commands and will do nothing
    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.8.0-53-generic (--configure):
     installed linux-image-5.8.0-53-generic package post-installation script subprocess returned error exit status 1
    Errors were encountered while processing:
     linux-image-5.8.0-53-generic

运行时nano /boot/grub/grub.cfg.new

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#








             [ File '/boot/grub/grub.cfg.new' is unwritable ]

运行nano /boot/grub/grub.cfg是同样的事情加上一大堆if...else语句。

答案1

删除第一行/etc/default/grub

GNU nano 4.8                                                                                 /etc/default/grub                                                                                           

它不属于那里。第 28 行还有另一行类似的行,但它被注释了并且没有什么坏处。

相关内容