Arch Linux Installation: ERROR: Root device mounted successfully, but /sbin/init does not exist

Arch Linux Installation: ERROR: Root device mounted successfully, but /sbin/init does not exist

我是 linux 的新手,但我决定直接使用 arch-linux 来熟悉一切。 不幸的是,我什至无法完成安装 - 我真可耻。

设置 arch up 后启动时的错误是:

ERROR: Root device mounted successfully, but /sbin/init does not exist.
Bailing out, you are on your own. Good luck.

我在 lvm 的 luks 上使用 btrfs

布局看起来像这样

sda
 |- sda1          512MB     fat32 /boot
 `- sda2          remaining lvm
     |- cryptswap 4GB       swap
     |- crypttmp  2GB       tmp   /tmp
     `- cryptroot remaining btrfs
         |- @                     /
         |- @home                 /home
         |- @snapshots            /.snapshots
         |- @log                  /var/log
         |- @cache                /var/cache
         `- @tmp                  /var/tmp

这些是我用来设置 arch 的命令和配置:

dd status=progress if=/dev/zero of=/dev/sda 擦除磁盘

gdisk /dev/sda

o 清除 gpt table

引导分区

n
↵
↵
+512M
ef00

lvm 分区

n
↵
↵
↵
8e00

w 写入分区更改

设置 lvm

pvcreate /dev/sda2
vgcreate vg1 /dev/sda2
lvcreate -L 4G -n cryptswap vg1
lvcreate -L 2G -n crypttmp vg1
lvcreate -l 100%FREE cryptroot vg1

设置加密

cryptsetup luksFormat /dev/vg1/cryptroot
cryptsetup open /dev/vg1/cryptroot root

制作文件系统

mkfs.fat -F32 -n BOOT /dev/sda1
mkfs.btrfs --label ROOT /dev/mapper/root

创建 btrfs 子卷

mount /dev/mapper/root /mnt
cd /mnt

btrfs subvolume create @
btrfs subvolume create @home
btrfs subvolume create @snapshots
btrfs subvolume create @log
btrfs subvolume create @cache
btrfs subvolume create @tmp

cd ..
umount /mnt

挂载 btrfs 子卷和 BOOT 分区

mount -o noatime,compress=lzo,space_cache=v2,discard=async,subvol=@ /dev/mapper/root /mnt

mkdir /mnt/home
mount -o noatime,compress=lzo,space_cache=v2,discard=async,subvol=@home /dev/mapper/root /mnt/home

mkdir /mnt/.snapshots
mount -o noatime,compress=lzo,space_cache=v2,discard=async,subvol=@snapshots /dev/mapper/root /mnt/.snapshots

mkdir /mnt/var
mkdir /mnt/var/log
mount -o noatime,compress=lzo,space_cache=v2,discard=async,subvol=@log /dev/mapper/root /mnt/var/log

mkdir /mnt/var/cache
mount -o noatime,compress=lzo,space_cache=v2,discard=async,subvol=@cache /dev/mapper/root /mnt/var/cache

mkdir /mnt/var/tmp
mount -o noatime,compress=lzo,space_cache=v2,discard=async,subvol=@tmp /dev/mapper/root /mnt/var/tmp

mkdir /mnt/boot
mount /dev/sda1 /mnt/boot

pacstrap /mnt base linux linux-firmware lvm2 btrfs-progs amd-ucode vim 安装必需品

genfstab -L /mnt > mnt/etc/fstab 生成 fstab

arch-chroot /mnt

基本配置

ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
hwclock --systohc
vim /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" >> /etc/locale.conf
echo "KEYMAP=de-latin1" >> /etc/vconsole.conf
echo "devstation" >> /etc/hostname
vim /etc/hosts

vim /etc/mkinitcpio.conf

mkinitcpio.conf内容:

MODULES=(btrfs)
HOOKS=(base udev autodetect keyboard keymap consolefont modconf block lvm2 encrypt filesystems fsck)

mkinitcpio -p linux

bootctl install

echo "default arch" > /boot/loader/loader.conf

vim /boot/loader/entries/arch.conf

arch.conf内容

title   Arch Linux
linux   /vmlinuz-linux
initrd  /initramfs-linux.img
options cryptdevice=UUID={/dev/vg1/cryptroot uuid inserted here}:root root=/dev/mapper/root rw

exit

umount -a

poweroff

从计算机中取出 arch 安装介质并启动它。

开机输出

:: running early hook [udev]
Starting version 248.3-2-arch
:: running hook [udev]
:: Triggering uevents...
:: running hook [keymap]
:: Loading keymap...done.
:: running hook [encrypt]

A password is requires to acces the root volume:
Enter passphrase for /dev/mapper/vg1-cryptroot: {inserting passphrase}
:: performing fsck on '/dev/mapper/root'
:: mounting '/dev/mapper/root' on real root
:: running cleanup hook [udev]
ERROR: Root device mounted successfully, but /sbin/init does not exist.
Bailing out, you are on your own. Good luck.

sh: can't access tty; job control turned off
[rootfs ]#

显然我还没有设置 cryptswap 和 crypttmp。这些将使用 crypttab 和 fstab 进行设置。我只是提到这一点,并且高度怀疑这是问题的一部分,因为它们只是目前无法识别的分区,不是吗。

我希望我没有遗漏我执行的任何命令或配置 - 我正在输入我观看的视频并从头开始,因为我发现没有一个视频具有我使用的 btrfs、luks、lvm 配置。感谢您 time/help 并通读本文。

像这样将 rootflags=subvol=@ 添加到 /boot/loader/entries/arch.conf

title   Arch Linux
linux   /vmlinuz-linux
initrd  /initramfs-linux.img
options cryptdevice=UUID={/dev/vg1/cryptroot uuid inserted here}:root root=/dev/mapper/root rootflags=subvol=@ rw

成功了。