Closed jkirk closed 4 weeks ago
Seems like udev kicks in:
root@grml ~ # while ! lsof +c0 /dev/sda; do sleep 0.1; done
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
(udev-worker) 8271 root 18rR BLK 8,0 0t0 215 /dev/sda
(udev-worker) 8271 root 19rR BLK 8,0 0t0 215 /dev/sda
root@grml ~ # udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
KERNEL[8081.262680] change /devices/pci0000:00/0000:00:05.0/0000:01:01.0/virtio2/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
UDEV [8081.514711] change /devices/pci0000:00/0000:00:05.0/0000:01:01.0/virtio2/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
KERNEL[8081.537754] remove /devices/pci0000:00/0000:00:05.0/0000:01:01.0/virtio2/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
KERNEL[8081.538049] change /devices/pci0000:00/0000:00:05.0/0000:01:01.0/virtio2/host0/target0:0:0/0:0:0:0/block/sda (block)
KERNEL[8081.538269] add /devices/pci0000:00/0000:00:05.0/0000:01:01.0/virtio2/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
UDEV [8081.746240] remove /devices/pci0000:00/0000:00:05.0/0000:01:01.0/virtio2/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
UDEV [8081.799125] change /devices/pci0000:00/0000:00:05.0/0000:01:01.0/virtio2/host0/target0:0:0/0:0:0:0/block/sda (block)
UDEV [8082.042753] add /devices/pci0000:00/0000:00:05.0/0000:01:01.0/virtio2/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
Instead of sync
and sleep 1
, I tried udevadm settle
which seems to do the trick.
Before creating a PR for this specific problem, I wonder where else do we need this?
Instead of sync and sleep 1, I tried udevadm settle which seems to do the trick.
I think this needs a retry instead, because lots of things try to access new devices...
Not sure, because an instant retry failed too:
root@grml ~ # grml-debootstrap -r bookworm -t /dev/sda1 --grub /dev/sda --hostname template-debian-bookworm --mirror http://mirror.hetzner.de/debian/packages; blockdev --rereadpt "$main_device"
[...]
blockdev: ioctl error on BLKRRPART: Device or resource busy
Unexpected non-zero exit code 1 in /sbin/grml-debootstrap /sbin/grml-debootstrap /sbin/grml-debootstrap at line 1376 2132 0 detected!
last bash command: blockdev --rereadpt "$main_device"
blockdev: ioctl error on BLKRRPART: Device or resource busy
root@grml ~ #
FTR, the problem did not occur when I stopped the udev event handler before and starting it after grml-debootstrap
:
root@grml ~ # udevadm control -s
root@grml ~ # grml-debootstrap -r bookworm -t /dev/sda1 --grub /dev/sda --hostname template-debian-bookworm --mirror http://mirror.hetzner.de/debian/packages;
[...]
* Finished execution of grml-debootstrap. Enjoy your Debian system.
root@grml ~ # udevadm control -S
instant retry
Retry of the entire grml-debootstrap call or of blockdev
with a sleep loop?
I try to run
grml-debootstrap
on a Proxmox VM and get the following error:As a workaround I added
sync
+sleep 2
beforeblockdev --rereadpt "$main_device"
https://github.com/grml/grml-debootstrap/blob/fa44c61d9c8b7a1559d409a0d6f8fbdcb7350cac/grml-debootstrap#L1376I am not sure that this is the right way to fix this problem. In fact I have no idea, why this happens in the first place. Any idea how to fix this?