I ran into a strange problem where mkfs.ext4 won't work on loop devices backed by a temp file.
tmp_file="$(mktemp)"
fallocate -l 8M "$tmp_file"
loop="$(losetup --show -f "$tmp_file")"
mkfs.ext4 "$loop"
I tried dd if=/dev/zero
and truncate
as well. Same result. What's absurd is that the failure doesn't propagate up to the application layer. mkfs programs exit with 0, but the output file system is basically mangled. It's probably got something to do with buffered/delayed io.
Am I not allowed to do this? Or is it a bug? I could probably investigate further by reading kernel code, but I wanted to hear from the experts first.
Update Oops. Sorry. Kernel version: 5.7.10-201.fc32.x86_64
The kernel messages.
[ 3213.106709] blk_update_request: operation not supported error, dev loop6, sector 16256 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3213.107013] blk_update_request: operation not supported error, dev loop6, sector 196 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3213.108396] blk_update_request: operation not supported error, dev loop6, sector 708 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3213.110006] blk_update_request: operation not supported error, dev loop6, sector 160 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3213.110158] blk_update_request: operation not supported error, dev loop6, sector 166 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3213.110852] blk_update_request: operation not supported error, dev loop6, sector 710 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3223.152191] blk_update_request: operation not supported error, dev loop7, sector 16256 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3223.152619] blk_update_request: operation not supported error, dev loop7, sector 196 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3223.153694] blk_update_request: operation not supported error, dev loop7, sector 708 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3223.155495] blk_update_request: operation not supported error, dev loop7, sector 160 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3223.155670] blk_update_request: operation not supported error, dev loop7, sector 166 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3223.156233] blk_update_request: operation not supported error, dev loop7, sector 710 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3568.666245] blk_update_request: operation not supported error, dev loop6, sector 16256 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3568.666543] blk_update_request: operation not supported error, dev loop6, sector 196 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3568.667546] blk_update_request: operation not supported error, dev loop6, sector 708 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3568.669204] blk_update_request: operation not supported error, dev loop6, sector 160 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3568.669380] blk_update_request: operation not supported error, dev loop6, sector 166 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3568.669974] blk_update_request: operation not supported error, dev loop6, sector 710 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
Like I said, mkfs should run successfully. The error is silent.
mkfs.ext4
is successful and I can mount the loop device. Where are you seeing this error message? – Andy Dalton Aug 11 '20 at 01:08loop6
andloop7
. What is$loop
in this case? – Andy Dalton Aug 11 '20 at 23:25