1---2title: "Alpine BTRFS 修复记录"3date: 2023-06-19T19:49:05+08:004---56## 问题7alpine 3.18 更新 linux-lts 后,启动失败,进入救援系统,报错日志8```9mount: mounting /dev/sda3 on /newroot failed: Invalid argument10```1112## 过程13141. 首先想到的是文件系统出错了。15 进入到 liveos ,`btrfs check /dev/sda3` 无异常16172. 这大概是内核加载的时候出了什么问题。18 首先重新做一遍 `initramfs`,方法是在 liveos 里把分区都挂上,chroot 进去修1920 ```21 export chroot_dir=/mnt22 mount /dev/sda3 ${chroot_dir}23 mount /dev/sda1 ${chroot_dir}/boot2425 mount -o bind /dev ${chroot_dir}/dev26 mount -t proc none ${chroot_dir}/proc27 mount -o bind /sys ${chroot_dir}/sys2829 chroot ${chroot_dir} /bin/ash -l3031 ```3233 检查 `/etc/mkinitfs/mkinitfs.conf` 配置,对比其他机器,发现缺了 `btrfs` 的 features 。3435 加上之后 `apk fix linux-lts` 发现在 `syslinux-6.04_pre1-r13.trigger` 报了一个警告:36 ```37 WARNING: Root device is not specified in /etc/update-extlinux.conf.38 ```39 暂时先没管,重启,失败40413. 修 bootloader42 前面提到的 `/etc/update-extlinux.conf` 文件就是 syslinux 的配置文件,首先把 root 设备的配置加上4344 ```45 root=UUID=xxxxxxxxxxxxxxxxxx46 ```4748 然后看到这样一行配置49 ```50 # modules51 # modules which should be loaded before pivot_root52 modules=sd-mod,usb-storage,ext453 ```54 把 `ext4` 改成 `btrfs`,重新运行 `apk fix linux-lts`,警告消失,重启正常进入系统5556## 后日谈57为什么配置文件会变成这个样子,完全没有头绪。这台机器之前也更新过内核重启,没什么问题。5859另一台安装时间只相差十几天的机器,完全正常,修复配置参考的也是这台正常的机器。