Trim errors/not working on debian 11 guest / LVM-Thin storage

Humay

Active Member
Feb 19, 2017
5
0
41
48
Hello,

i have problems with trim on debian 11 guest VM , i used windows server as guest on different VM and its was working for it
i used virtio-scsi and ssd emulation on/off, discard on
underlying storage is NVME drive

pveversion
pve-manager/7.2-4/ca9d43cc (running kernel: 5.15.35-1-pve)

Code:
cat 105.conf
agent: 1
boot: order=scsi0;net0
cores: 1
cpu: host
machine: q35
memory: 8192
meta: creation-qemu=6.1.1,ctime=1645484114
name: debian
net0: virtio=CE:4E:D8:4B:55:74,bridge=vmbr0,firewall=1
numa: 0
ostype: l26
scsi0: local-lvm:vm-105-disk-0,discard=on,size=32G
scsihw: virtio-scsi-pci
smbios1: uuid=cbe727c0-419b-4187-93eb-3bd85db3808e
sockets: 1
vmgenid: 142716d5-c991-4322-8bbc-cf5b1fb7e7c6

on host:
Code:
fstrim -av
/boot/efi: 510.5 MiB (535343104 bytes) trimmed on /dev/nvme0n1p2
/: 6.9 GiB (7370207232 bytes) trimmed on /dev/mapper/pve-root

on guest:
Code:
fstrim -av
fstrim: /tmp: the discard operation is not supported
fstrim: /var: the discard operation is not supported
fstrim: /home: the discard operation is not supported
fstrim: /: the discard operation is not supported
dmesg:
Code:
46.128854] sd 0:0:0:0: [sda] tag#64 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE cmd_age=0s
[   46.128856] sd 0:0:0:0: [sda] tag#64 Sense Key : Illegal Request [current]
[   46.128857] sd 0:0:0:0: [sda] tag#64 Add. Sense: Invalid field in cdb
[   46.128858] sd 0:0:0:0: [sda] tag#64 CDB: Unmap/Read sub-channel 42 00 00 00 00 00 00 00 18 00
[   46.128864] blk_update_request: critical target error, dev sda, sector 20343292 op 0x3:(DISCARD) flags 0x0 phys_seg 1 prio class 0

mount on guest
Code:
 mount |grep sda
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro)
/dev/sda8 on /home type ext4 (rw,relatime)
/dev/sda5 on /var type ext4 (rw,relatime)
/dev/sda7 on /tmp type ext4 (rw,relatime)
 
Last edited:
In Debian Guest-VM -> fstab -> option discard is enabled?
that option does something different and will not solve the OPs problem.

i have problems with trim on debian 11 guest VM , i used windows server as guest on different VM and its was working for it
i used virtio-scsi and ssd emulation on/off, discard on
underlying storage is NVME drive
interessting problem and nothing amiss at the first glance. Was the windows VM also using virtio-scsi-pci?
 
edit TLDR; seems proxmox bug attached converted vmdk/vdi from LVM to VirtualBox trim success!

yes windows use virtio-scsi same as debian

seems there issue when regular (plain) partitions installed
seems when i trim alone /home /var error doesn't shows up
only when its try to discard /tmp and /
i dont know its related to debian or proxmox or actual qemu client in this /tmp related bug
interesting fstrim on /tmp /dev/sda7 (ext4) via live cd rescue mode give error FITTRIM ioctl failed: Remote IO error
and all other filesystems TRIM successfully

system was restored from backup, fsck is clean

error while running on livecd
Code:
[  175.231056] sd 0:0:0:0: [sda] tag#6 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE cmd_age=0s
[  175.231058] sd 0:0:0:0: [sda] tag#6 Sense Key : Illegal Request [current]
[  175.231059] sd 0:0:0:0: [sda] tag#6 Add. Sense: Invalid field in cdb
[  175.231061] sd 0:0:0:0: [sda] tag#6 CDB: Unmap/Read sub-channel 42 00 00 00 00 00 00 00 18 00
[  175.231064] blk_update_request: critical target error, dev sda, sector 20343280 op 0x3:(DISCARD) flags 0x800 phys_seg 1 prio class 0

on regular:
Code:
lsblk -D
NAME   DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda           0        4K       1G         0
├─sda1        0        4K       1G         0
├─sda2     1024        4K       1G         0
├─sda5        0        4K       1G         0
├─sda6        0        4K       1G         0
├─sda7        0        4K       1G         0
└─sda8        0        4K       1G         0

 fstrim -av
fstrim: /tmp: FITRIM ioctl failed: Remote I/O error
fstrim: /home: the discard operation is not supported
fstrim: /var: the discard operation is not supported
fstrim: /: the discard operation is not supported

 lsblk -D
NAME   DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda           0        4K       0B         0
├─sda1        0        4K       0B         0
├─sda2        0        4K       0B         0
├─sda5        0        4K       0B         0
├─sda6        0        4K       0B         0
├─sda7        0        4K       0B         0
└─sda8        0        4K       0B         0

Code:
qm agent 105 fstrim
{
   "paths" : [
      {
         "error" : "trim not supported",
         "path" : "/var"
      },
      {
         "error" : "trim not supported",
         "path" : "/home"
      },
      {
         "error" : "trim not supported",
         "path" : "/tmp"
      },
      {
         "error" : "trim not supported",
         "path" : "/"
      }
   ]
}

other debian just deleted 1gb on /home

Code:
 lsblk -D
NAME                    DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda                            0        4K       0B         0
├─sda1                         0        4K       0B         0
├─sda2                         0        4K       0B         0
└─sda5                         0        4K       0B         0
  ├─lgsm--av--vg-root          0        4K       1G         0
  ├─lgsm--av--vg-var           0        4K       1G         0
  ├─lgsm--av--vg-swap_1        0        4K       1G         0
  ├─lgsm--av--vg-tmp           0        4K       1G         0
  └─lgsm--av--vg-home          0        4K       1G         0
sr0                            0        0B       0B         0

Code:
qm agent 125 fstrim
{
   "paths" : [
      {
         "minimum" : 0,
         "path" : "/home",
         "trimmed" : 1089998848
      },
      {
         "minimum" : 0,
         "path" : "/var",
         "trimmed" : 0
      },
      {
         "error" : "trim not supported",
         "path" : "/boot"
      },
      {
         "minimum" : 0,
         "path" : "/tmp",
         "trimmed" : 0
      },
      {
         "minimum" : 0,
         "path" : "/",
         "trimmed" : 0
      }
   ]
}

Edit: added fstab for VM 105 debian in question
Code:
 cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=7740534b-eeb3-4ac8-8437-239ca52ca11b /               ext4    errors=remount-ro 0       1
# /home was on /dev/sda8 during installation
UUID=2469cfe8-f511-4cb0-93f1-27371afd5591 /home           ext4    defaults        0       2
# /tmp was on /dev/sda7 during installation
UUID=7b1fa0fc-a525-4d8c-8720-a5a565e6be6d /tmp            ext4    defaults        0       2
# /var was on /dev/sda5 during installation
UUID=fcd08abe-5449-4a67-ac6f-a31a300262e3 /var            ext4    defaults        0       2
# swap was on /dev/sda6 during installation
UUID=f1f002ec-369d-4443-9acb-6f0721f6abef none            swap    sw              0       0

mounts
Code:
mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=4057920k,nr_inodes=1014480,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,noexec,relatime,size=814848k,mode=755)
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
none on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=30,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=10644)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
tracefs on /sys/kernel/tracing type tracefs (rw,nosuid,nodev,noexec,relatime)
configfs on /sys/kernel/config type configfs (rw,nosuid,nodev,noexec,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)
/dev/sda8 on /home type ext4 (rw,relatime)
/dev/sda7 on /tmp type ext4 (rw,relatime)
/dev/sda5 on /var type ext4 (rw,relatime)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=814844k,nr_inodes=203711,mode=700)
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!