我一直在尝试将 lxc 容器转换为虚拟机,但在尝试启动时遇到了问题。我最终得到了 (initramfs) 命令行,并得到了以下错误:
mount: mounting /dev on /root/dev failed: No such file or directory
mount: mounting /run on /root/run failed: No such file or directory
run-init: opening console: No such file or directory
Target filesystem
doesn't have requested /sbin/init.
run-init: opening console: No such
file or directory (repeated a few times)
No init found. Try passing init= bootarg
BusyBox v1.22.1 (Ubuntu 1:1.22.0-15ubuntu1) built-in shell (ash) Enter
'help' for a list of built-in commands.
(initramfs)
从 live cd ubuntu 16.04:
blkid
/dev/sda1: UUID="3e671c97-7695-49e7-8c83-4527c94d8f14" TYPE="ext4" PARTUUID="406cef0c-01"
/dev/sda2: UUID="c555438a-fd29-4cad-a8cf-fe92c3b78e0b" TYPE="ext4" PARTUUID="406cef0c-02"
/dev/sr0: UUID="2018-07-31-01-12-13-00" LABEL="Ubuntu 16.04.5 LTS amd64" TYPE="iso9660" PTUUID="6be2cd0d" PTTYPE="dos
cat /etc/fstab:
UUID="3e671c97-7695-49e7-8c83-4527c94d8f14" /boot ext4 defaults,noatime0 0 UUID="c555438a-fd29-4cad-a8cf-fe92c3b78e0b" / ext4 defaults,noatime0 1
UUID="688b6a9b-0f30-450c-b8d6-1316c0d17798" none swap defaults 00
/boot/grub/grub.cfg的相关部分:
set root='hd0,msdos2' if [ x$feature_platform_search_hint = xy ];
then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2
--hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2 c555438a-fd29-4cad-a8cf-fe92c3b78e0belse search --no-floppy
--fs-uuid --set=root c555438a-fd29-4cad-a8cf-fe92c3b78e0b fi
和:
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu
--class os $menuentry_id_option 'gnulinux-simple-c555438a-fd29-4cad-a8cf-fe92c3b78e0b' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 3e671c97-7695-49e7-8c83-4527c94d8f14
else
search --no-floppy --fs-uuid --set=root 3e671c97-7695-49e7-8c83-4527c94d8f14
fi
linux /vmlinuz-4.15.0-30-generic root=UUID=3e671c97-7695-49e7-8c83-4527c94d8f14 ro quiet splash
$vt_handoff initrd /initrd.img-4.15.0-30-generic }
我更改了 linux /vmlinuz-4.15.0-30-generic 的 uuid,使其与 /dev/sda1 匹配,而不是 /dev/sda2。grub-installer 将 /dev/sda2 的 UUID 放在根分区所在的位置,我不知道为什么。有什么办法可以解决这个问题吗?
答案1
在解决了 grub 问题后,我终于意识到了实际问题所在。空白屏幕与控制台 (tty) 的识别方式有关。每次在 grub 菜单后出现空白屏幕时,操作系统实际上都会正常启动,但它不会显示任何内容。但每当我按下 ctrl+alt F1 或 F2 时,提示就会出现,一切实际上都很好。为了解决这个问题,我将这一行:GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" 替换为 GRUB_CMDLINE_LINUX_DEFAULT="text" 现在工作正常,启动过程也显示在屏幕上。