:未找到 rub-mkconfig:5:/etc/default/grub:

:未找到 rub-mkconfig:5:/etc/default/grub:

由于此错误,我无法安装任何程序:

linux-image-5.0.0-19-generic

E: 子进程 /usr/bin/dpkg 返回错误代码 (1)

我尝试了这些网页上的所有方法:

以及我在这个论坛上找到的任何内容。

什么都没起作用。有什么想法吗?

$ sudo apt-get install --reinstall linux-image-5.0.0-19-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  linux-modules-5.0.0-19-generic
The following NEW packages will be installed
  linux-modules-5.0.0-19-generic
0 to upgrade, 1 to newly install, 1 reinstalled, 0 to remove and 4 not to upgrade.
3 not fully installed or removed.
Need to get 22.1 MB of archives.
After this operation, 68.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://pl.archive.ubuntu.com/ubuntu disco-updates/main amd64 linux-modules-5.0.0-19-generic amd64 5.0.0-19.20 [13.7 MB]
Get:2 http://pl.archive.ubuntu.com/ubuntu disco-updates/main amd64 linux-image-5.0.0-19-generic amd64 5.0.0-19.20 [8,352 kB]
Fetched 22.1 MB in 7s (3,014 kB/s)                                             
(Reading database ... 228114 files and directories currently installed.)
Preparing to unpack .../linux-modules-5.0.0-19-generic_5.0.0-19.20_amd64.deb ...
Unpacking linux-modules-5.0.0-19-generic (5.0.0-19.20) ...
Preparing to unpack .../linux-image-5.0.0-19-generic_5.0.0-19.20_amd64.deb ...
Unpacking linux-image-5.0.0-19-generic (5.0.0-19.20) over (5.0.0-19.20) ...
Setting up linux-image-5.0.0-23-generic (5.0.0-23.24) ...
Setting up linux-modules-5.0.0-19-generic (5.0.0-19.20) ...
Setting up linux-image-5.0.0-21-generic (5.0.0-21.22) ...
Setting up linux-image-5.0.0-19-generic (5.0.0-19.20) ...
Processing triggers for linux-image-5.0.0-23-generic (5.0.0-23.24) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.0.0-23-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.0.0-23-generic
/etc/kernel/postinst.d/zz-update-grub:
Killed
Sourcing file `/etc/default/grub'
: not foundrub-mkconfig: 5: /etc/default/grub: 
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.0.0-23-generic (--configure):
 installed linux-image-5.0.0-23-generic package post-installation script subprocess returned error exit status 1
Processing triggers for linux-image-5.0.0-21-generic (5.0.0-21.22) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.0.0-21-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.0.0-21-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
: not foundrub-mkconfig: 5: /etc/default/grub: 
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.0.0-21-generic (--configure):
 installed linux-image-5.0.0-21-generic package post-installation script subprocess returned error exit status 1
Processing triggers for linux-image-5.0.0-19-generic (5.0.0-19.20) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.0.0-19-generic
Error! Your kernel headers for kernel 5.0.0-19-generic cannot be found.
Please install the linux-headers-5.0.0-19-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.0.0-19-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
: not foundrub-mkconfig: 5: /etc/default/grub: 
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.0.0-19-generic (--configure):
 installed linux-image-5.0.0-19-generic package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-image-5.0.0-23-generic
 linux-image-5.0.0-21-generic
 linux-image-5.0.0-19-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 to upgrade, 0 to newly install, 0 to remove and 4 not to upgrade.
3 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up linux-image-5.0.0-23-generic (5.0.0-23.24) ...
Setting up linux-image-5.0.0-19-generic (5.0.0-19.20) ...
Setting up linux-image-5.0.0-21-generic (5.0.0-21.22) ...
Processing triggers for linux-image-5.0.0-23-generic (5.0.0-23.24) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.0.0-23-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.0.0-23-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
: not foundrub-mkconfig: 5: /etc/default/grub: 
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.0.0-23-generic (--configure):
 installed linux-image-5.0.0-23-generic package post-installation script subprocess returned error exit status 1
Processing triggers for linux-image-5.0.0-19-generic (5.0.0-19.20) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.0.0-19-generic
Error! Your kernel headers for kernel 5.0.0-19-generic cannot be found.
Please install the linux-headers-5.0.0-19-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.0.0-19-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
: not foundrub-mkconfig: 5: /etc/default/grub: 
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.0.0-19-generic (--configure):
 installed linux-image-5.0.0-19-generic package post-installation script subprocess returned error exit status 1
Processing triggers for linux-image-5.0.0-21-generic (5.0.0-21.22) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.0.0-21-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.0.0-21-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
: not foundrub-mkconfig: 5: /etc/default/grub: 
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.0.0-21-generic (--configure):
 installed linux-image-5.0.0-21-generic package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-image-5.0.0-23-generic
 linux-image-5.0.0-19-generic
 linux-image-5.0.0-21-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

$ sudo dpkg --configure -a
Setting up linux-image-5.0.0-23-generic (5.0.0-23.24) ...
Setting up linux-image-5.0.0-21-generic (5.0.0-21.22) ...
Processing triggers for linux-image-5.0.0-23-generic (5.0.0-23.24) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.0.0-23-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.0.0-23-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
: not foundrub-mkconfig: 5: /etc/default/grub: 
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.0.0-23-generic (--configure):
 installed linux-image-5.0.0-23-generic package post-installation script subprocess returned error exit status 1
Processing triggers for linux-image-5.0.0-21-generic (5.0.0-21.22) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.0.0-21-generic
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.0.0-21-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
: not foundrub-mkconfig: 5: /etc/default/grub: 
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-5.0.0-21-generic (--configure):
 installed linux-image-5.0.0-21-generic package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-image-5.0.0-23-generic
 linux-image-5.0.0-21-generic

答案1

听起来您缺少文件/etc/default/grub设置文件,该文件已被删除或以某种方式被移除。

我们可以尝试重新创建该文件。

以下是全新安装的 19.04 的副本:

https://paste.ubuntu.com/p/tsN4RhqRkB

如果你打开终端并运行

sudo nano /etc/default/grub

并输入链接文件的内容。输入内容后,按 Ctl-x 退出,然后输入“y”并按 Enter 保存。

然后重试 apt 命令并查看 apt 是否成功完成。

答案2

是的,我这样做了,但我发现了另一个问题。我的文件 /etc/default/grub 是 DOS 格式。我更改了它,一切正常。谢谢!

相关内容