避免了重装修复了Manjaro的启动问题
https://www.cnblogs.com/apocelipes/p/10192882.html
上周在更新Manjaro Linux的时候误触了电源键,导致内核更新了一半系统强制关机,重启时正常进入grub但无法正常引导进入系统。
由于不想重装系统(一大堆环境和工具的配置还是相当繁琐的),加上初步判断应该仅仅是内核引导镜像没能正常安装导致的问题,所以决定先用liveUSB进行急救。
需要准备的工具:
一个使用较新版本Manjaro Linux的liveUSB(可以使用dd将镜像直接写入u盘)
待修复设备需要联网环境(没有其实也不用担心,不过最好还是需要联网环境)
下面开始修复启动。
首先通过liveUSB启动,在liveUSB的中我们原先的系统文件是保存在电脑的磁盘上的,默认不会被挂载,所以我们先要把除了/home以外的系统目录挂载到当前的任意目录,我们选择挂载在/mnt中:
sudo mkdir /mnt/manjaro
sudo mount /dev/sda2 /mnt/manjaro # sda2为/分区所在设备,可以使用lsblk查看
随后是关键的一步,因为在UEFI下安装Manjaro Linux时我们都额外为/boot/efi/进行了单独的分区,所以我们这里也需要挂载它。默认挂载根目录时并不会挂载这个目录,因为它们不在同一个分区,我的efi目录根据lsblk显示位于/dev/sda1:
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
├─sda2 8:2 0 50.8G 0 part /
└─sda3 8:3 0 414.8G 0 part /home
所以我们把efi目录也挂载进文件系统,否则内核无法重新安装:
sudo mount /dev/sda1 /mnt/manjaro/boot/efi
另外对于一些虚拟目录,例如/dev和/sys,我们也需要手动绑定,否则chroot后运行pacman会出错:
sudo mount --bind /dev /mnt/manjaro/dev
sudo mount --bind /proc /mnt/manjaro/proc
sudo mount --bind /sys /mnt/manjaro/sys
这样系统文件就准备完成了,现在我们在挂载目录下chroot,然后重新安装内核:
cd /mnt/manjaro
chroot .
pacman -S linux # 如果这一步报错,检查自己系统目录是否正确挂载,如果正确挂载则先运行pacman -S archlinux-keyring
# 内核重装完成后继续上次未完成的系统更新
pacman -Syu
如果你安装了不同版本的内核的话,这样只能修复系统默认版本的内核,对于Manjaro 18.0来说是4.14.x。
所以在grub引导界面我们需要选择对应的版本才能正常启动,如果想恢复其他版本的内核,可以在用默认版本内核启动后去Manjaro Settings Manager中重新安装。
这样就避免了重装修复了Manjaro的启动问题。
mkdir manjaro
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 68.6M 1 loop /run/miso/sfs/livefs
loop1 7:1 0 1.2G 1 loop /run/miso/sfs/mhwdfs
loop2 7:2 0 1.7G 1 loop /run/miso/sfs/desktopfs
loop3 7:3 0 664.6M 1 loop /run/miso/sfs/rootfs
sda 8:0 0 1.4T 0 disk
├─sda1 8:1 0 256M 0 part
├─sda2 8:2 0 300M 0 part
├─sda3 8:3 0 130G 0 part
├─sda4 8:4 0 200G 0 part
├─sda5 8:5 0 200G 0 part
├─sda6 8:6 0 164.1G 0 part
├─sda7 8:7 0 97.7G 0 part
├─sda8 8:8 0 252G 0 part
├─sda9 8:9 0 133G 0 part
├─sda10 8:10 0 160G 0 part
└─sda11 8:11 0 60G 0 part
sdb 8:16 1 58.6G 0 disk /run/miso/bootmnt
├─sdb1 8:17 1 3.6G 0 part
└─sdb2 8:18 1 4M 0 part
nvme0n1 259:0 0 465.8G 0 disk
├─nvme0n1p1 259:1 0 300M 0 part
├─nvme0n1p2 259:2 0 128M 0 part
├─nvme0n1p3 259:3 0 115G 0 part
├─nvme0n1p4 259:4 0 100G 0 part
├─nvme0n1p5 259:5 0 100G 0 part
├─nvme0n1p6 259:6 0 55.6G 0 part
└─nvme0n1p7 259:7 0 94.8G 0 part
sudo mount /dev/sda7 manjaro
sudo mount --bind /dev manjaro/dev/
sudo mount --bind /proc manjaro/proc
sudo mount --bind /sys manjaro/sys
cd manjaro
sudo chroot .
#pacman -Syyu
cd /var/cache/pacman/pkg/
ls | grep linux6
pacman -U linux61-6.1.41-1-x86_64.pkg.tar.zst
loading packages... warning: linux61-6.1.41-1 is up to date -- reinstalling resolving dependencies... looking for conflicting packages... Packages (1) linux61-6.1.41-1 Total Installed Size: 142.93 MiB Net Upgrade Size: 0.00 MiB :: Proceed with installation? [Y/n] y (1/1) checking keys in keyring [###] 100% (1/1) checking package integrity [###] 100% (1/1) loading package files [###] 100% (1/1) checking for file conflicts [###] 100% (1/1) checking available disk space [###] 100% :: Running pre-transaction hooks... (1/1) Creating Timeshift snapshot before upgrade... ==> skipping timeshift-autosnap due skipRsyncAutosnap in /etc/timeshift-autosnap.conf set to TRUE. :: Processing package changes... (1/1) reinstalling linux61 [###] 100% :: Running post-transaction hooks... (1/5) Arming ConditionNeedsUpdate... (2/5) Updating module dependencies... (3/5) Updating linux initcpios... ==> Building image from preset: /etc/mkinitcpio.d/linux61.preset: 'default' ==> Using default configuration file: '/etc/mkinitcpio.conf' -> -k /boot/vmlinuz-6.1-x86_64 -g /boot/initramfs-6.1-x86_64.img --microcode /boot/intel-ucode.img ==> Starting build: '6.1.41-1-MANJARO' -> Running build hook: [base] -> Running build hook: [udev] -> Running build hook: [autodetect] -> Running build hook: [modconf] -> Running build hook: [block] ==> WARNING: Possibly missing firmware for module: 'xhci_pci' -> Running build hook: [keyboard] -> Running build hook: [keymap] loadkeys: Unable to open file: cn: No such file or directory -> Running build hook: [consolefont] ==> WARNING: consolefont: no font found in configuration -> Running build hook: [plymouth] -> Running build hook: [filesystems] -> Running build hook: [fsck] ==> Generating module dependencies ==> Creating gzip-compressed initcpio image: '/boot/initramfs-6.1-x86_64.img' ==> Image generation successful ==> Building image from preset: /etc/mkinitcpio.d/linux61.preset: 'fallback' ==> Using default configuration file: '/etc/mkinitcpio.conf' -> -k /boot/vmlinuz-6.1-x86_64 -g /boot/initramfs-6.1-x86_64-fallback.img -S autodetect --microcode /boot/intel-ucode.img ==> Starting build: '6.1.41-1-MANJARO' -> Running build hook: [base] -> Running build hook: [udev] -> Running build hook: [modconf] -> Running build hook: [block] ==> WARNING: Possibly missing firmware for module: 'qla2xxx' ==> WARNING: Possibly missing firmware for module: 'bfa' ==> WARNING: Possibly missing firmware for module: 'aic94xx' ==> WARNING: Possibly missing firmware for module: 'qed' ==> WARNING: Possibly missing firmware for module: 'qla1280' ==> WARNING: Possibly missing firmware for module: 'wd719x' ==> WARNING: Possibly missing firmware for module: 'xhci_pci' -> Running build hook: [keyboard] -> Running build hook: [keymap] loadkeys: Unable to open file: cn: No such file or directory -> Running build hook: [consolefont] ==> WARNING: consolefont: no font found in configuration -> Running build hook: [plymouth] -> Running build hook: [filesystems] -> Running build hook: [fsck] ==> Generating module dependencies ==> Creating gzip-compressed initcpio image: '/boot/initramfs-6.1-x86_64-fallback.img' ==> Image generation successful (4/5) Refreshing PackageKit... Error connecting: Could not connect: No such file or directory error: command failed to execute correctly (5/5) Updating Grub-Bootmenu Generating grub configuration file ... Found theme: /usr/share/grub/themes/manjaro/theme.txt Found linux image: /boot/vmlinuz-6.5-x86_64 Found initrd image: /boot/intel-ucode.img Found linux image: /boot/vmlinuz-6.1-x86_64 Found initrd image: /boot/intel-ucode.img /boot/initramfs-6.1-x86_64.img Found initrd fallback image: /boot/initramfs-6.1-x86_64-fallback.img Warning: os-prober will be executed to detect other bootable partitions. Its output will be used to detect bootable binaries on them and create new boot entries. ERROR: mkdir /var/lock/dmraid grub-probe: error: cannot find a GRUB drive for /dev/sdb1. Check your device.map. grub-probe: error: cannot find a GRUB drive for /dev/sdb1. Check your device.map. Found KDE neon 5.27 (22.04) on /dev/nvme0n1p7 Found Ubuntu 22.04.2 LTS (22.04) on /dev/sda9 Adding boot menu entry for UEFI Firmware Settings ... Root filesystem isn't btrfs If you think an error has occurred, please file a bug report at "https://github.com/Antynea/grub-btrfs" Found memtest86+ image: /boot/memtest86+/memtest.bin Found memtest86+ EFI image: /boot/memtest86+/memtest.efi done