删除一些旧内核后

删除一些旧内核后

我删除了一些必要的内核部分,以扩大启动分区上的可用空间。首先,我按照以下方式进行操作关联。但是问题与链接中的问题并不完全相同(请参阅下面 Eliah 的回答)。我首先尝试的是以下分区方案的第一个输出:

ubuntu@ubuntu:~$  sudo parted -l
Model: ATA ST3500418AS (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      32.3kB  535MB   535MB   primary  ext4            boot
 2      535MB   5914MB  5379MB  primary  linux-swap(v1)
 3      5914MB  106GB   100GB   primary  ext4
 4      106GB   500GB   394GB   primary  ext4


Model: WD 5000AAC External (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size   Type     File system  Flags
 1      32.3kB  500GB  500GB  primary  ext4


Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0
has been opened read-only.
Error: Can't have a partition outside the disk!                           

ubuntu@ubuntu:~$ 

我的启动分区在 上sda1sda2是我的交换分区,sda3是我的根目录,sda4是我的主分区。我按照第二个答案(由 Eliah 提供)中的说明进行操作。这意味着:

1.

     ubuntu@ubuntu:~$ sudo mount /dev/sda3 /mnt 
ubuntu@ubuntu:~$ sudo mount --bind /dev /mnt/dev 
ubuntu@ubuntu:~$ sudo mount /dev/sda1 /mnt/boot
  1. 然后我chroot了:

        ubuntu@ubuntu:~$ sudo chroot /mnt
        root@ubuntu:/# mount -t proc none /proc
        root@ubuntu:/# mount -t sysfs none /sys
        root@ubuntu:/# mount -t devpts none /dev/pts
        root@ubuntu:/# export HOME=/root
        root@ubuntu:/# export LC_ALL=C
    
  2. 我尝试安装新内核:

     apt-get update
     apt-get -y install linux-image-generic
    

这里我收到以下错误:

root@ubuntu:/# apt-get -y install linux-image-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
linux-image-generic is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up linux-image-3.8.0-29-generic (3.8.0-29.42) ...
Internal Error: Could not find image (/boot/vmlinuz-3.8.0-29-generic)
dpkg: error processing linux-image-3.8.0-29-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-extra-3.8.0-29-generic:
 linux-image-extra-3.8.0-29-generic depends on linux-image-3.8.0-29-generic; however:
  Package linux-image-3.8.0-29-generic is not configured yet.

dpkg: error processing linux-image-extra-3.8.0-29-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.8.0-29-generic; however:
  Package linux-image-3.8.0-29-generic is not configured yet.
 linux-image-generic depends on linux-image-extra-3.8.0-29-generic; however:
  Package linux-image-extra-3.8.0-29-generic is not configured yet.

dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-imNo apport report written because the error message indicates its a followup error from a previous failure.
     No apport report written because the error message indicates its a followup error from a previous failure.
                               No apport report written because MaxReports is reached already
             age:
 linux-image depends on linux-image-generic; however:
  Package linux-image-generic is not configured yet.

dpkg: error processing linux-image (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-image-3.8.0-29-generic
 linux-image-extra-3.8.0-29-generic
 linux-image-generic
 linux-image
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@ubuntu:/# 


umount /proc || umount -lf /proc
umount /sys /dev/pts
exit
sudo umount /mnt/dev /mnt

我也尝试卸载所有内容并运行

apt-get install linux-generic linux-image-generic linux-headers-generic

而且当然

update-grub

启动时我仍然会进行内存测试。正如 Eliah 指出的那样,上述解决方案不适用于我的情况。因此,我按照下面他的回答中的说明进行操作。但是,这并不能解决问题。我得到了以下输出:

   ubuntu@ubuntu:~$ sudo mount /dev/sda3 /mnt
ubuntu@ubuntu:~$ sudo mount --bind /dev /mnt/dev
ubuntu@ubuntu:~$ sudo mount /dev/sda1 /mnt/boot
ubuntu@ubuntu:~$ sudo chroot /mnt
root@ubuntu:/# mount -t proc none /proc
root@ubuntu:/# mount -t sysfs none /sys
root@ubuntu:/# mount -t devpts none /dev/pts
root@ubuntu:/# export HOME=/root
root@ubuntu:/# export LC_ALL=C

然后运行apt-get update并按照建议操作:

root@ubuntu:/# apt-get -y --purge --reinstall install linux-image-3.8.0-29-generic linux-image-extra-3.8.0-29-generic linux-image-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 3 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/43.3 MB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg: warning: files list file for package 'linux-image-3.8.0-29-generic' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'initramfs-tools' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'linux-image-extra-3.8.0-29-generic' missing; assuming package has no files currently installed
(Reading database ... 251414 files and directories currently installed.)
Preparing to replace linux-image-3.8.0-29-generic 3.8.0-29.42 (using .../linux-image-3.8.0-29-generic_3.8.0-29.42_amd64.deb) ...
Done.
Unpacking replacement linux-image-3.8.0-29-generic ...
Preparing to replace linux-image-extra-3.8.0-29-generic 3.8.0-29.42 (using .../linux-image-extra-3.8.0-29-generic_3.8.0-29.42_amd64.deb) ...
Unpacking replacement linux-image-extra-3.8.0-29-generic ...
Preparing to replace linux-image-generic 3.8.0.29.47 (using .../linux-image-generic_3.8.0.29.47_amd64.deb) ...
Unpacking replacement linux-image-generic ...
Setting up linux-image-3.8.0-29-generic (3.8.0-29.42) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Failed to symbolic-link /boot/initrd.img-3.8.0-29-generic to initrd.img:File exists at /var/lib/dpkg/info/linux-image-3.8.0-29-generic.postinst line 614.
dpkg: error processing linux-image-3.8.0-29-generic (--configure):
 subprocess installed post-installation script returned error exit status 17
dpkg: dependency problems prevent configuration of linux-image-extra-3.8.0-29-generic:
 linux-image-extra-3.8.0-29-generic depends on linux-image-3.8.0-29-generic; however:
  Package linux-image-3.8.0-29-generic is not configured yet.

dpkg: error processing linux-image-extra-3.8.0-29-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.8.0-29-generic; however:
  Package linux-image-3.8.0-29-generic is not configured yet.
 linux-image-generic depends on linux-image-extra-3.8.0-29-generic; however:
  Package linux-image-extra-3.8.0-29-generic is not configured yet.

dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          No apport report written because the error message indicates its a followup error from a previous failure.
                                                    Errors were encountered while processing:
 linux-image-3.8.0-29-generic
 linux-image-extra-3.8.0-29-generic
 linux-image-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@ubuntu:/# 

答案1

答案就在那里是为没有内核的情况编写的,因为提供内核的软件包已经被删除了。

你的情况类似,但略有不同。你的系统似乎没有内核,因为它们的文件已被手动删除(或被某些自动过程删除)。其他比软件包卸载更糟糕)。 就软件包管理器而言,您似乎仍然安装了内核。

为了解决这个问题,可能只需告诉包管理器重新安装内核包。

您运行了以下命令:

apt-get -y install linux-image-generic

使用相同的步骤(包括apt-get update之前的命令),尝试替换将该apt-get -y install命令替换为以下命令:

apt-get -y --purge --reinstall install linux-image-3.8.0-29-generic linux-image-extra-3.8.0-29-generic linux-image-generic

(该--purge标志是可选的,因为这个问题与系统范围的配置文件无关。但它不会造成损害。)

这将卸载无法正常工作的软件包(由于删除了文件),然后重新安装它们,确保所有文件都从软件包档案中复制。它不应该依赖于任何存在的软件包文件,因此即使某些软件包文件似乎已被手动删除,它也应该可以正常工作。

linux-image-generic是一个元包;安装它会导致安装系统的最新稳定内核,因为linux-image-generic声明提供该内核的包为依赖项。规定linux-image-generic“从头开始”重新安装并不一定会导致重新安装其所有依赖项,这就是为什么我在上面的命令中明确列出了其相关依赖项。

我从你问题中的输出中得到了它们的名字(linux-image-extra-3.8.0-29-genericlinux-image-extra-3.8.0-29-generic)。遇到此问题的其他人不一定想要明确规定要安装哪些软件包,而应该查看软件包所linux-image-generic依赖的内容,然后明确重新安装至少缺少文件的包。

就这样钥匙促使我建议该解决方案的部分输出是:

Setting up linux-image-3.8.0-29-generic (3.8.0-29.42) ...
Internal Error: Could not find image (/boot/vmlinuz-3.8.0-29-generic)
dpkg: error processing linux-image-3.8.0-29-generic (--configure):

这很可能行不通。如果软件包损坏,导致软件包管理器无法卸载他们。如果出现该问题或任何其他问题,请更新您的问题并提供详细信息。

(对于作者以外的人问题——如果发生这种情况并且这里的信息不能帮助您解决它,请发布一个包含尽可能多详细信息的新问题,或者如果您已经发布了有关该问题的信息,请在您的问题中添加详细信息。)

答案2

一位朋友解决了这个问题。他提出了以下建议,这对我很有用:

apt-get purge grub grub-pc grub-common 
apt-get install grub-common grub-pc 
update-grub

答案3

使用上述信息,我使用了以下内容

uname -r

让我们将上述命令的输出称为南瓜

然后我输入:

dpkg --list | grep linux-image

我查看了这个列表的输出,并注意到 linux-image-PUMPKIN

任何不属于我的 linux-image-PUMPKIN 的东西都可以通过完成以下命令来删除:

sudo apt-get purge linux-image-(your non-PUMKIN entry goes here)

然后

sudo update-grub
sudo update-grub2

最后

sudo apt-get update
sudo apt-get autoremove
sudo apt-get upgrade

重启后就好了。

相关内容