How to remove an inactive network block device?

How am creating VM images and using qemu-nbd to mount qcow2 images where I connect to it, then mount it and once I'm done, I disconnect. I am on Gentoo.

The problem is that the device, /dev/nbd0, still hangs around in /dev and I can no longer reconnect to it without input/output errors.

How do I completely remove this device? I know that it always works on a new nbd device, but not a reused one. I've seen another post similar to this one that uses the following (edited w/ my device) to remove it ...

echo 1 > /sys/block/nbd0/nbd0p1/device/delete

... but even as root I get ...

bash: ./nbd0/device/delete: No such file or directory

Update:

$ lsblk
NAME           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
nbd0            43:0    0    40G  0 disk
├─nbd0p1        43:1    0    63M  0 part
├─nbd0p2        43:2    0     6M  0 part  [SWAP]
└─nbd0p3        43:3    0  39.9G  0 part
nbd1            43:32   0    40G  0 disk
├─nbd1p1        43:33   0    63M  0 part
├─nbd1p2        43:34   0     6M  0 part  [SWAP]
└─nbd1p3        43:35   0  39.9G  0 part

And here's a reuse of the device error ...

Warning: Error fsyncing/closing /dev/nbd0p1: Input/output error
Warning: Error fsyncing/closing /dev/nbd0p3: Input/output error
Warning: Error fsyncing/closing /dev/nbd0: Input/output error
Warning: Error fsyncing/closing /dev/nbd0p1: Input/output error
Warning: Error fsyncing/closing /dev/nbd0p3: Input/output error
Error: Input/output error during read on /dev/nbd0
Error: Input/output error during write on /dev/nbd0
添加评论
点赞收藏
点踩分享查看原文
评论
?
参与讨论