系统重启后无法使 LVM 缓存持久化

系统重启后无法使 LVM 缓存持久化

我在 MDADM RAID1 设置上建立了 LVM 逻辑卷。我尝试通过以下方式将 SSD 设备作为缓存添加到此逻辑卷:

vgextend dataVG /dev/sdd
lvcreate --type cache --cachemode writethrough -L 120G -n dataLV_cachepool dataVG/dataLV /dev/sdd

一切似乎都很好,直到我重新启动系统。重新启动后,它无法启动,我进入恢复模式(Ubuntu)。

我在启动过程中看到以下错误:

lvm[740]:   dataVG: autoactivation failed.
systemd[1]: lvm2-pvscan@9:2.service: Main process exited, code=exited, status=5/NOTINSTALLED
systemd[1]: lvm2-pvscan@9:2.service: Failed with result 'exit-code'.
systemd[1]: Failed to start LVM2 PV scan on device 9:2.
lvm[774]:   /usr/sbin/cache_check: execvp failed: No such file or directory
lvm[774]:   Check of pool dataVG/dataLV_cachepool failed (status:2). Manual repair required!
lvm[774]:   0 logical volume(s) in volume group "dataVG" now active
lvm[774]:   dataVG: autoactivation failed.
systemd[1]: Started File System Check on /dev/mapper/BACKUPVG-mainbackup.
systemd[1]: lvm2-pvscan@8:16.service: Main process exited, code=exited, status=5/NOTINSTALLED
systemd[1]: lvm2-pvscan@8:16.service: Failed with result 'exit-code'.
systemd[1]: Failed to start LVM2 PV scan on device 8:16.
systemd[1]: Mounting /mnt/mainbackup...
systemd[1]: Mounted /mnt/mainbackup.
kernel: EXT4-fs (dm-1): mounted filesystem with ordered data mode. Opts: (null)
systemd[1]: dev-mapper-dataVG\x2dataLV.device: Job dev-mapper-dataVG\x2dataLV.device/start timed out.
systemd[1]: Timed out waiting for device dev-mapper-dataVG\x2dataLV.device.
systemd[1]: Dependency failed for /mnt/dataLV.
systemd[1]: Dependency failed for Local File Systems.
systemd[1]: local-fs.target: Job local-fs.target/start failed with result 'dependency'.
systemd[1]: local-fs.target: Triggering OnFailure= dependencies.
systemd[1]: mnt-dataLV.mount: Job mnt-dataLV.mount/start failed with result 'dependency'.
systemd[1]: Dependency failed for File System Check on /dev/mapper/dataVG-dataLV.
systemd[1]: systemd-fsck@dev-mapper-dataVG\x2dataLV.service: Job systemd-fsck@dev-mapper-dataVG\x2dataLV.service/start failed with resu
systemd[1]: dev-mapper-dataVG\x2dataLV.device: Job dev-mapper-dataVG\x2dataLV.device/start failed with result 'timeout'.

仅当我从 VG 中删除缓存驱动器时它才有效:

lvconvert --uncache dataVG/dataLV

不确定如何解决这个问题...

LVM 版本

LVM version:     2.02.176(2) (2017-11-03)
Library version: 1.02.145 (2017-11-03)

答案1

我在 Debian 8 上遇到了同样的问题。解决包括两个步骤。

首先,由于启动时未加载所需模块,因此系统启动时缓存的 LV 处于非活动状态的 LVM。

尝试手动激活它们,导致错误:

vgchange -a y vg0/home_cache
   /usr/sbin/cache_check: execvp failed: No such file or directory
   Check of pool vg0/home_cache failed (status:2). Manual repair required!

确实,命令 /usr/sbin/cache_check 不存在。通过安装来修复它:

apt-get install thin-provisioning-tools

其次,修复导致 LVM 缓存卷未激活的问题。initramfs 启动映像中需要存在几个模块。将它们添加到强制模块中以包含:

sudo echo "dm_cache" >> /etc/initramfs-tools/modules
sudo echo "dm_cache_mq" >> /etc/initramfs-tools/modules
sudo echo "dm_persistent_data" >> /etc/initramfs-tools/modules
sudo echo "dm_bufio" >> /etc/initramfs-tools/modules

然后执行以下操作:

update-initramfs -k `uname -r` -u -t

最后通过以下方式保护自己:

update-grub

检查所有内容两次,最后重新启动。

答案2

我认为您需要在 init ramdisk 中安装缓存内核模块 (dm-cache) 和 /usr/sbin/cache_* 工具。在 fedora 中,它由 debian (和 ubuntu) initramfs-tools 包中的 dracut 处理。

相关内容