我已经在lvm上的ext4文件系统上安装了系统(vg encrypted,root称为encrypted-root)。当我试图运行fstrim /时,我得到了fstrim: /: the discard operation is not supported。
我的/etc/crypttab包含
cryptroot UUID=5ddb7e3a-dcbe-442d-85e8-359e944d0717 none luks,discard,lvm=encrypted/etc/lvm/lvm.conf包含
issue_discards = 1/etc/initramfs-tools/conf.d/cryptroot只包含
CRYPTROOT=target=encrypted-root,source=/dev/disk/by-uuid/5ddb7e3a-dcbe-442d-85e8-359e944d0717(我使用update-initramfs -k all -c创建initramfs)。
/etc/default/grub包含
GRUB_CMDLINE_LINUX="cryptops=target=encrypted-root,source=/dev/disk/by-uuid/5ddb7e3a-dcbe-442d-85e8-359e944d0717,lvm=encrypted"我尝试在grub中手动将rd.luks.options=discard作为linux的参数。我尝试过refresh选项的cryptsetup实用程序(cryptsetup --allow-discards refreshdevice),但它似乎没有一个(cryptsetup: Unknown action)。
物理设备显然有TRIM支持,当我运行fstrim /boot时它可以工作(它是同一台设备,只是没有加密)。
dmsetup table命令不显示用于cryptroot的allow_discards。
当我从USB启动并手动解密(带有--allow-discards参数到cryptsetup)并挂载根分区时,它可以工作。我尝试过使用--persistent选项,但是它说它不能使它持久。
我迷路了。我该怎么做才能让fstrim /发挥作用?有些东西告诉我,我应该以某种方式修改grub中的引导选项,但我不确定如何修改。我也不确定是否使用了/etc/crypttab中的行(我在安装后将其更改为cryptroot,即使我更改了它,它似乎也什么也不做)。
我正在运行LinuxMint19.3。
发布于 2020-06-20 17:18:34
我发现问题在加密层面。(您可以将dmsetup table作为根用户运行,以查看设备是否显示allow_discards。)
这解决了我的问题:
/etc/initramfs-tools/conf.d/cryptroot,为特定设备添加discard选项。在我的案例中,行看起来是这样的:CRYPTROOT=target=encrypted-root,source=/dev/disk/by-uuid/5ddb7e3a-dcbe-442d-85e8-359e944d0717,discard。update-initramfs -k all -c。(如果您的配置有问题而您不知道的话,请先进行备份。)https://unix.stackexchange.com/questions/574400
复制相似问题