Hi. mkfs.ext4 on nbd device cause:
Discarding device blocks: failed - Input/output error message. The actions: ~# qemu-img create -f raw test.img 10G Formatting 'test.img', fmt=raw size=10737418240 ~# qemu-nbd -f raw -c /dev/nbd0 test.img ~# fdisk /dev/nbd0 ...[PARTITION A DISK]... ~# fdisk -l /dev/nbd0 Disk /dev/nbd0: 10 GiB, 10737418240 bytes, 20971520 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xe75e6795 Device Boot Start End Sectors Size Id Type /dev/nbd0p1 2048 20971519 20969472 10G 83 Linux ~# mkfs.ext4 /dev/nbd0p1 mke2fs 1.45.2 (27-May-2019) Discarding device blocks: failed - Input/output error Creating filesystem with 2621184 4k blocks and 655360 inodes Filesystem UUID: 442620a3-0f00-432b-884e-0f14d76a993a Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done ~# dmesg | tail ...[CUT]... [64297.914937] nbd0: p1 [64306.284714] block nbd0: Other side returned error (5) [64306.284722] blk_update_request: I/O error, dev nbd0, sector 34816 op 0x3:(DISCARD) flags 0x800 phys_seg 1 prio class 0 With qcow2 format i get the same problem. With losetup instead of qemu-nbd there is no errors. Forgot to say: kernel - 5.4.82(4.19.132 get the same error) qemu - 5.0.0 -- Олег Неманов (Oleg Nemanov)