grub 40_custom.save 换行错误

grub 40_custom.save 换行错误

我使用的是 16.04,并且安装了 win7。每当我尝试安装某些东西时,终端都会显示一堆错误

Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.13.0-39-generic
Found initrd image: /boot/initrd.img-4.13.0-39-generic
Found linux image: /boot/vmlinuz-4.13.0-38-generic
Found initrd image: /boot/initrd.img-4.13.0-38-generic
Found linux image: /boot/vmlinuz-4.13.0-36-generic
Found initrd image: /boot/initrd.img-4.13.0-36-generic
Found linux image: /boot/vmlinuz-4.4.0-122-generic
Found initrd image: /boot/initrd.img-4.4.0-122-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda1
/etc/grub.d/40_custom.save: 2: /etc/grub.d/40_custom.save: Syntax error: newline unexpected
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 2
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-4.13.0-38-generic.postinst line 1052.
dpkg: error processing package linux-image-4.13.0-38-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
No apport report written because MaxReports is reached already

dpkg: dependency problems prevent configuration of linux-image-extra-4.13.0-38-generic:
 linux-image-extra-4.13.0-38-generic depends on linux-image-4.13.0-38-generic; however:
  Package linux-image-4.13.0-38-generic is not configured yet.

dpkg: error processing package linux-image-extra-4.13.0-38-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
Errors were encountered while processing:
 friendly-recovery
 linux-image-4.4.0-122-generic
 linux-image-extra-4.4.0-122-generic
 linux-image-generic
 linux-generic
 linux-image-4.13.0-39-generic
 linux-image-extra-4.13.0-39-generic
 linux-image-generic-hwe-16.04
 linux-generic-hwe-16.04
 linux-image-4.13.0-38-generic
 linux-image-extra-4.13.0-38-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

40_custom.save 文件如下所示

>#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

第二行之后没有换行。我也尝试删除这 3 条注释,但出现同样的错误。

谁能帮助我,这真的很烦人:(

答案1

看起来您有 40_custom 的副本,即 40_custom.save。grub-update 会运行 /etc/grub.d 中以两个数字和一个下划线开头且已启用执行位的任何文件。

因此,请关闭 40_custom.save 的执行位或删除该文件。

sudo chmod a-x /etc/grub.d/40_custom.save

相关内容