错误地删除了目录 /boot 中的文件 initrd.img-3.11.0-20-generic。现在系统无法再启动。
是否有可能恢复 initrd.img-3.11.0-20-generic?
live-cd 中 blkid 的输出:
ubuntu@ubuntu:~$ sudo blkid
/dev/loop0: TYPE="squashfs"
/dev/sda1: UUID="999feae4-d45b-4cbf-8015-ef5d62d952cd" TYPE="ext2"
/dev/sda5: UUID="9k5hUW-e2Hq-IfIN-08zV-jjDd-0mHm-CHySv4" TYPE="LVM2_member"
/dev/sr0: LABEL="Ubuntu 14.04 LTS amd64" TYPE="iso9660"
/dev/mapper/ubuntu--vg-root: UUID="8cf4d204-bbf8-44e2-a3e4-0f8c618e67ef" TYPE="ext4"
/dev/mapper/ubuntu--vg-swap_1: UUID="6a0999af-2cee-453f-9a01-7c878df6213e" TYPE="swap"
2014年5月29日更新:
这是我输入的内容(遵循缪尼斯) 系统响应:
ubuntu@ubuntu:~$ sudo -i
root@ubuntu:~# mount /dev/mapper/ubuntu--vg-root /mnt
root@ubuntu:~# mount /dev/sda1 /mnt/boot
root@ubuntu:~# for i in dev dev/pts proc sys sys/firmware; do mount --bind /$i /mnt/$i; done
root@ubuntu:~# cp /etc/resolv.conf /mnt/etc/resolv.conf
root@ubuntu:~# chroot /mnt
root@ubuntu:/# apt-get update
命令执行后系统响应apt-get update
:
Ign http://extras.ubuntu.com trusty InRelease
Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Get:2 http://extras.ubuntu.com trusty Release.gpg [72 B]
Ign http://de.archive.ubuntu.com trusty InRelease
Get:3 http://security.ubuntu.com trusty-security Release [58.5 kB]
Hit http://extras.ubuntu.com trusty Release
Ign http://de.archive.ubuntu.com trusty-updates InRelease
Ign http://de.archive.ubuntu.com trusty-backports InRelease
Ign http://de.archive.ubuntu.com trusty-proposed InRelease
Hit http://de.archive.ubuntu.com trusty Release.gpg
Hit http://extras.ubuntu.com trusty/main Sources
Get:4 http://security.ubuntu.com trusty-security/main Sources [16.0 kB]
Get:5 http://de.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://extras.ubuntu.com trusty/main amd64 Packages
Hit http://extras.ubuntu.com trusty/main i386 Packages
Get:6 http://de.archive.ubuntu.com trusty-backports Release.gpg [933 B]
Get:7 http://security.ubuntu.com trusty-security/restricted Sources [14 B]
Get:8 http://security.ubuntu.com trusty-security/universe Sources [4,212 B]
Get:9 http://de.archive.ubuntu.com trusty-proposed Release.gpg [933 B]
Get:10 http://security.ubuntu.com trusty-security/multiverse Sources [687 B]
Hit http://de.archive.ubuntu.com trusty Release
Get:11 http://security.ubuntu.com trusty-security/main amd64 Packages [51.8 kB]
Get:12 http://de.archive.ubuntu.com trusty-updates Release [58.5 kB]
Get:13 http://security.ubuntu.com trusty-security/restricted amd64 Packages [14 B]
Get:14 http://security.ubuntu.com trusty-security/universe amd64 Packages [17.9 kB]
Get:15 http://security.ubuntu.com trusty-security/multiverse amd64 Packages [1,154 B]
Get:16 http://de.archive.ubuntu.com trusty-backports Release [58.6 kB]
Get:17 http://security.ubuntu.com trusty-security/main i386 Packages [49.4 kB]
Get:18 http://security.ubuntu.com trusty-security/restricted i386 Packages [14 B]
Get:19 http://de.archive.ubuntu.com trusty-proposed Release [58.5 kB]
Get:20 http://security.ubuntu.com trusty-security/universe i386 Packages [17.9 kB]
Get:21 http://security.ubuntu.com trusty-security/multiverse i386 Packages [1,404 B]
Hit http://de.archive.ubuntu.com trusty/main Sources
Ign http://extras.ubuntu.com trusty/main Translation-en_US
Hit http://de.archive.ubuntu.com trusty/restricted Sources
Hit http://de.archive.ubuntu.com trusty/universe Sources
Get:22 http://security.ubuntu.com trusty-security/main Translation-en [24.4 kB]
Hit http://de.archive.ubuntu.com trusty/multiverse Sources
Ign http://extras.ubuntu.com trusty/main Translation-en
Hit http://de.archive.ubuntu.com trusty/main amd64 Packages
Ign http://extras.ubuntu.com trusty/main Translation-de
Hit http://security.ubuntu.com trusty-security/multiverse Translation-en
Hit http://de.archive.ubuntu.com trusty/restricted amd64 Packages
Hit http://security.ubuntu.com trusty-security/restricted Translation-en
Hit http://de.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://de.archive.ubuntu.com trusty/multiverse amd64 Packages
Get:23 http://security.ubuntu.com trusty-security/universe Translation-en [9,065 B]
Hit http://de.archive.ubuntu.com trusty/main i386 Packages
Hit http://de.archive.ubuntu.com trusty/restricted i386 Packages
Hit http://de.archive.ubuntu.com trusty/universe i386 Packages
Hit http://de.archive.ubuntu.com trusty/multiverse i386 Packages
Hit http://de.archive.ubuntu.com trusty/main Translation-en
Hit http://de.archive.ubuntu.com trusty/main Translation-de
Hit http://de.archive.ubuntu.com trusty/multiverse Translation-en
Hit http://de.archive.ubuntu.com trusty/multiverse Translation-de
Hit http://de.archive.ubuntu.com trusty/restricted Translation-en
Hit http://de.archive.ubuntu.com trusty/restricted Translation-de
Hit http://de.archive.ubuntu.com trusty/universe Translation-en
Hit http://de.archive.ubuntu.com trusty/universe Translation-de
Get:24 http://de.archive.ubuntu.com trusty-updates/main Sources [45.7 kB]
Get:25 http://de.archive.ubuntu.com trusty-updates/restricted Sources [14 B]
Get:26 http://de.archive.ubuntu.com trusty-updates/universe Sources [28.2 kB]
Ign http://security.ubuntu.com trusty-security/main Translation-en_US
Get:27 http://de.archive.ubuntu.com trusty-updates/multiverse Sources [2,234 B]
Ign http://security.ubuntu.com trusty-security/main Translation-de
Get:28 http://de.archive.ubuntu.com trusty-updates/main amd64 Packages [109 kB]
Ign http://security.ubuntu.com trusty-security/multiverse Translation-en_US
Ign http://security.ubuntu.com trusty-security/multiverse Translation-de
Get:29 http://de.archive.ubuntu.com trusty-updates/restricted amd64 Packages [14 B]
Ign http://security.ubuntu.com trusty-security/restricted Translation-en_US
Get:30 http://de.archive.ubuntu.com trusty-updates/universe amd64 Packages [74.9 kB]
Ign http://security.ubuntu.com trusty-security/restricted Translation-de
Ign http://security.ubuntu.com trusty-security/universe Translation-en_US
Get:31 http://de.archive.ubuntu.com trusty-updates/multiverse amd64 Packages [7,089 B]
Ign http://security.ubuntu.com trusty-security/universe Translation-de
Get:32 http://de.archive.ubuntu.com trusty-updates/main i386 Packages [107 kB]
Get:33 http://de.archive.ubuntu.com trusty-updates/restricted i386 Packages [14 B]
Get:34 http://de.archive.ubuntu.com trusty-updates/universe i386 Packages [75.3 kB]
Get:35 http://de.archive.ubuntu.com trusty-updates/multiverse i386 Packages [7,273 B]
Get:36 http://de.archive.ubuntu.com trusty-updates/main Translation-en [51.2 kB]
Hit http://de.archive.ubuntu.com trusty-updates/multiverse Translation-en
Hit http://de.archive.ubuntu.com trusty-updates/restricted Translation-en
Get:37 http://de.archive.ubuntu.com trusty-updates/universe Translation-en [33.8 kB]
Get:38 http://de.archive.ubuntu.com trusty-backports/main Sources [14 B]
Get:39 http://de.archive.ubuntu.com trusty-backports/restricted Sources [14 B]
Get:40 http://de.archive.ubuntu.com trusty-backports/universe Sources [4,123 B]
Get:41 http://de.archive.ubuntu.com trusty-backports/multiverse Sources [768 B]
Get:42 http://de.archive.ubuntu.com trusty-backports/main amd64 Packages [14 B]
Get:43 http://de.archive.ubuntu.com trusty-backports/restricted amd64 Packages [14 B]
Get:44 http://de.archive.ubuntu.com trusty-backports/universe amd64 Packages [4,099 B]
Get:45 http://de.archive.ubuntu.com trusty-backports/multiverse amd64 Packages [619 B]
Get:46 http://de.archive.ubuntu.com trusty-backports/main i386 Packages [14 B]
Get:47 http://de.archive.ubuntu.com trusty-backports/restricted i386 Packages [14 B]
Get:48 http://de.archive.ubuntu.com trusty-backports/universe i386 Packages [4,114 B]
Get:49 http://de.archive.ubuntu.com trusty-backports/multiverse i386 Packages [619 B]
Hit http://de.archive.ubuntu.com trusty-backports/main Translation-en
Get:50 http://de.archive.ubuntu.com trusty-backports/multiverse Translation-en [307 B]
Hit http://de.archive.ubuntu.com trusty-backports/restricted Translation-en
Get:51 http://de.archive.ubuntu.com trusty-backports/universe Translation-en [2,506 B]
Get:52 http://de.archive.ubuntu.com trusty-proposed/main amd64 Packages [88.4 kB]
Get:53 http://de.archive.ubuntu.com trusty-proposed/restricted amd64 Packages [14 B]
Get:54 http://de.archive.ubuntu.com trusty-proposed/multiverse amd64 Packages [14 B]
Get:55 http://de.archive.ubuntu.com trusty-proposed/universe amd64 Packages [16.6 kB]
Get:56 http://de.archive.ubuntu.com trusty-proposed/main i386 Packages [85.5 kB]
Get:57 http://de.archive.ubuntu.com trusty-proposed/restricted i386 Packages [14 B]
Get:58 http://de.archive.ubuntu.com trusty-proposed/multiverse i386 Packages [14 B]
Get:59 http://de.archive.ubuntu.com trusty-proposed/universe i386 Packages [16.7 kB]
Get:60 http://de.archive.ubuntu.com trusty-proposed/main Translation-en [40.7 kB]
Hit http://de.archive.ubuntu.com trusty-proposed/main Translation-de
Hit http://de.archive.ubuntu.com trusty-proposed/multiverse Translation-en
Hit http://de.archive.ubuntu.com trusty-proposed/multiverse Translation-de
Hit http://de.archive.ubuntu.com trusty-proposed/restricted Translation-en
Hit http://de.archive.ubuntu.com trusty-proposed/restricted Translation-de
Get:61 http://de.archive.ubuntu.com trusty-proposed/universe Translation-en [10.4 kB]
Hit http://de.archive.ubuntu.com trusty-proposed/universe Translation-de
Ign http://de.archive.ubuntu.com trusty/main Translation-en_US
Ign http://de.archive.ubuntu.com trusty/multiverse Translation-en_US
Ign http://de.archive.ubuntu.com trusty/restricted Translation-en_US
Ign http://de.archive.ubuntu.com trusty/universe Translation-en_US
Ign http://de.archive.ubuntu.com trusty-updates/main Translation-en_US
Ign http://de.archive.ubuntu.com trusty-updates/main Translation-de
Ign http://de.archive.ubuntu.com trusty-updates/multiverse Translation-en_US
Ign http://de.archive.ubuntu.com trusty-updates/multiverse Translation-de
Ign http://de.archive.ubuntu.com trusty-updates/restricted Translation-en_US
Ign http://de.archive.ubuntu.com trusty-updates/restricted Translation-de
Ign http://de.archive.ubuntu.com trusty-updates/universe Translation-en_US
Ign http://de.archive.ubuntu.com trusty-updates/universe Translation-de
Ign http://de.archive.ubuntu.com trusty-backports/main Translation-en_US
Ign http://de.archive.ubuntu.com trusty-backports/main Translation-de
Ign http://de.archive.ubuntu.com trusty-backports/multiverse Translation-en_US
Ign http://de.archive.ubuntu.com trusty-backports/multiverse Translation-de
Ign http://de.archive.ubuntu.com trusty-backports/restricted Translation-en_US
Ign http://de.archive.ubuntu.com trusty-backports/restricted Translation-de
Ign http://de.archive.ubuntu.com trusty-backports/universe Translation-en_US
Ign http://de.archive.ubuntu.com trusty-backports/universe Translation-de
Ign http://de.archive.ubuntu.com trusty-proposed/main Translation-en_US
Ign http://de.archive.ubuntu.com trusty-proposed/multiverse Translation-en_US
Ign http://de.archive.ubuntu.com trusty-proposed/restricted Translation-en_US
Ign http://de.archive.ubuntu.com trusty-proposed/universe Translation-en_US
Fetched 1,250 kB in 8s (145 kB/s)
Reading package lists... Done
root@ubuntu:/#
然后我输入:
root@ubuntu:/# apt-get --reinstall install linux-image-3.11.0-20-generic
...并收到以下答复:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reinstallation of linux-image-3.11.0-20-generic is not possible, it cannot be downloaded.
The following package was automatically installed and is no longer required:
linux-image-generic
Use 'apt-get autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 1674 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? Y
Setting up icaclient (12.1.0) ...
/var/lib/dpkg/info/icaclient.postinst: 696: /var/lib/dpkg/info/icaclient.postinst: nspluginwrapper: not found
dpkg: error processing icaclient (--configure):
subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
icaclient
E: Sub-process /usr/bin/dpkg returned an error code (1)
接下来我输入的是:
root@ubuntu:/# update-grub
系统回复:
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.11.0-20-generic
Found linux image: /boot/vmlinuz-3.11.0-19-generic
Found linux image: /boot/vmlinuz-3.11.0-18-generic
Found linux image: /boot/vmlinuz-3.11.0-17-generic
Found linux image: /boot/vmlinuz-3.11.0-15-generic
Found linux image: /boot/vmlinuz-3.11.0-12-generic
Found memtest86+ image: /memtest86+.bin
done
然后我输入:
root@ubuntu:/# grub-install
并得到这个:
Install device isn't specified.
Usage: grub-install [OPTION] [INSTALL_DEVICE]
Install GRUB on your drive.
-h, --help print this message and exit
-v, --version print the version information and exit
--modules=MODULES pre-load specified modules MODULES
--boot-directory=DIR install GRUB images under the directory DIR/grub
instead of the /boot/grub directory
--target=TARGET install GRUB for TARGET platform
[default=current]
--directory=DIR use GRUB images from DIR. Takes precedence
over target
--grub-setup=FILE use FILE as grub-setup
--grub-mkimage=FILE use FILE as grub-mkimage
--grub-mkrelpath=FILE use FILE as grub-mkrelpath
--grub-probe=FILE use FILE as grub-probe
--allow-floppy make the drive also bootable as floppy (default
for fdX devices). May break on some BIOSes.
--recheck delete device map if it already exists
--force install even if problems are detected
--force-file-id use identifier file even if UUID is available
--disk-module=MODULE disk module to use (biosdisk or native). This
option is only available on BIOS target.
--no-nvram don't update the `boot-device' NVRAM
variable. This option is only available on
IEEE1275 targets.
--removable the installation device is removable. This option
is only available on EFI.
--bootloader-id=ID the ID of bootloader. This option is only
available on EFI.
--efi-directory=DIR use DIR as the EFI System Partition root.
--uefi-secure-boot install an image usable with UEFI Secure
Boot. This option is only available on EFI and if
the grub-efi-amd64-signed package is installed.
--no-uefi-secure-boot do not install an image usable with UEFI Secure
Boot, even if the system was currently started
using it. This option is only available on EFI.
INSTALL_DEVICE must be system device filename.
grub-install copies GRUB images into /boot/grub, and uses grub-setup
to install grub into the boot sector.
Report bugs to <[email protected]>.
如上所示,该过程显示了一些错误。结果是系统仍然无法启动。有人知道如何解决这些错误吗?
答案1
首先,特别是作为初学者,你应该绝不编辑用户主目录之外的文件。不要手动弄乱您的系统。让 Ubuntu 负责何时何地需要哪些文件。
话虽如此:这有点复杂,但您可以使用实时 DVD 或 USB 棒修复 Ubuntu(USB 速度更快)。我将指导您完成此过程:
启动实时系统并收集信息
这与安装 Ubuntu 时的操作相同。只需确保选择“尝试 Ubuntu”。当您看到桌面时,打开终端(++ CTRL)并运行以下命令:ALTT
sudo blkid
这将给你这样的结果
/dev/sda1: LABEL="EFI" UUID="70D6-1701" TYPE="vfat"
/dev/sda2: UUID="68ca53b3" LABEL="OSX" TYPE="hfsplus"
/dev/sda3: UUID="49526001" LABEL="Recovery HD" TYPE="hfsplus"
/dev/sda4: LABEL="BOOTCAMP" UUID="FCF67D7DF67D394A" TYPE="ntfs"
/dev/sda6: UUID="c1c76922" TYPE="ext4"
/dev/sda7: UUID="3b171268" TYPE="ext4"
/dev/sda8: UUID="bf3dd1b7" TYPE="swap"
请将此命令的结果发回此处,以便我们进一步为您提供帮助。我将继续上述示例。
Chroot 进入已安装的系统
使用 chroot,您可以使用实时 Linux 并切换到硬盘上安装的 Linux 来修复它。您的系统使用 EFI 还是 BIOS 很重要。如果您的机器上有/曾经有 Windows 8,则它表明 EFI 很好。在上面的示例中,有一个小的 vfat 分区甚至称为 EFI,因此上述系统使用 EFI 进行启动。两个 ext4 分区是 Linux 分区。您可以从启动器打开它们,查看哪一个包含根文件系统(包含类似ETC,用户,变量, ...). 在上述情况下/dev/sda6是根分区,并且/dev/sda1是EFI分区。
在终端中运行以下命令来准备并打开 chroot。
sudo -i
mount /dev/sda6 /mnt
mount /dev/sda1 /mnt/boot/efi
for i in dev dev/pts proc sys sys/firmware; do mount --bind /$i /mnt/$i; done
chroot /mnt
仅当实际使用 EFI 时才需要挂载 EFI 分区,否则可以省略该行。
您发布的分区列表表明您使用 LVM,因此我们需要考虑到这一点。将上面的两个 mount 命令替换为以下命令:
mount /dev/mapper/ubuntu--vg-root /mnt
mount /dev/sda1 /mnt/boot
维修
要修复您的系统,请继续运行以下命令。
apt-get update
apt-get --reinstall install linux-image-3.11.0-20-generic
update-grub
grub-install
exit
现在重新启动机器,一切就绪。
答案2
此目录中的文件对于您的安装至关重要,因此您应该非常小心地处理它们,正如您刚刚发现的那样:-)
但我认为并非一切都丢失了。您应该能够重新安装该文件。为此,您可能必须使用 Ubuntu Live CD/USB 启动机器。步骤如下
- 在您的实时环境中挂载机器的本地分区,并将 chroot 到挂载的根目录中。
- 重新安装 linux-image-3.11.0-20-generic,IIRC,它应该为您生成文件。
我无法在这里进一步详述这两个步骤。在 Google 上搜索它们应该会找到一些可以帮到你的指南。
编辑:请参阅 emniess 的精彩帖子,他比我更快,并且很好地指导您完成整个过程。
答案3
- 从 GRUB 打开“Ubuntu 的高级选项”(如果它只是操作系统,请Shift在 BIOS 屏幕后使用)。
- 启动旧内核。
使用
sudo update-grub
(我认为它可以在较新的 Ubuntu 上运行)
重启。
答案4
抱歉,又要提起这么老的帖子了。我也遇到过类似的事情,一路上遇到了一些障碍,下面是它们及其解决方案:
我在 chroot 中运行 apt-get 时遇到了很多问题。您必须从另一个控制台安装/运行 resolvconf:
sudo dpkg-reconfigure resolvconf
您还必须复制该文件:
mv mnt/etc/resolv.conf{,.bak}
cp /etc/resolv.conf mnt/etc/resolv.conf
apt-get 卡住了几次,并给出了各种错误,您必须清除它以及一些我忘记的其他命令。
您可以通过查看 /mnt/boot 并查找启动文件来验证它是否有效。
重新启动时,您必须删除 /etc/resolv.conf 并再次运行 reconfigure resolvconf 以恢复 DNS。
为了让 grub 再次运行,我之前刚刚使用了 Boot-Repair,但不再需要它了。
谢谢** mniess**