#1141452 using mount --rbind causes systemd to latch onto the device of the mount point

Package:
systemd
Source:
systemd
Description:
system and service manager
Submitter:
Piotr Morgwai Kotarbinski
Date:
2026-07-05 02:33:03 UTC
Severity:
normal
#1141452#5
Date:
2026-07-05 02:31:11 UTC
From:
To:
= Steps to reproduce =

0. Let's assume we have a block device with some partitions on it:
```
$ lsblk /dev/nbd0
NAME     MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
nbd0      43:0    0   20G  0 disk
├─nbd0p1  43:1    0  100M  0 part
└─nbd0p2  43:2    0 19.9G  0 part
```

1. Create a filesystem on one of the partitions:
```
$ sudo mkfs.ext4 /dev/nbd0p2
mke2fs 1.47.2 (1-Jan-2025)
Discarding device blocks: done
Creating filesystem with 5216768 4k blocks and 1305600 inodes
Filesystem UUID: a052641a-2c21-4ce2-aaff-8d37145822d8
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
```

2. mount the newly created filesystem somewhere and create a folder inside it:
```
$ mkdir mnt
$ sudo mount -o relatime /dev/nbd0p2 mnt/
$ sudo mkdir mnt/dev
```

3. bind /dev hierarchy to the newly created folder:
```
$ sudo mount --rbind --make-rslave /dev mnt/dev/
```

4. recursively umount the partition:
```
$ sudo umount -R mnt
```

= Expected result =

The partition's underlying device should not be in use.

= Actual result =

systemd latches onto the device:
```
$ sudo mkfs.ext4 /dev/nbd0p2
mke2fs 1.47.2 (1-Jan-2025)
/dev/nbd0p2 is apparently in use by the system; will not make a filesystem
here!
```

Additionally in case of nbd devices, an attempt to disconnect causes I/O
errors:
```
$ sudo qemu-nbd --disconnect /dev/nbd0
/dev/nbd0 disconnected
morgwai@vm-trixie:~/systemd-sux$ journalctl --since=2026-07-03T22:15
--until=2026-07-03T22:16
Jul 03 22:15:20 vm-trixie sudo[3642]:  morgwai : TTY=pts/0 ;
PWD=/home/morgwai/systemd-sux ; USER=root ; COMMAND=/usr/bin/qemu-nbd
--disconnect /dev/nbd0
Jul 03 22:15:20 vm-trixie sudo[3642]: pam_unix(sudo:session): session opened
for user root(uid=0) by morgwai(uid=1000)
Jul 03 22:15:20 vm-trixie kernel: block nbd0: NBD_DISCONNECT
Jul 03 22:15:20 vm-trixie kernel: block nbd0: Disconnected due to user request.
Jul 03 22:15:20 vm-trixie kernel: block nbd0: shutting down sockets
Jul 03 22:15:20 vm-trixie sudo[3642]: pam_unix(sudo:session): session closed
for user root
Jul 03 22:15:20 vm-trixie kernel: I/O error, dev nbd0, sector 0 op 0x0:(READ)
flags 0x80700 phys_seg 16 prio class 2
Jul 03 22:15:20 vm-trixie kernel: I/O error, dev nbd0, sector 0 op 0x0:(READ)
flags 0x800000 phys_seg 1 prio class 2
Jul 03 22:15:20 vm-trixie kernel: Buffer I/O error on dev nbd0, logical block
0, async page read
Jul 03 22:15:20 vm-trixie kernel: I/O error, dev nbd0, sector 2048 op
0x0:(READ) flags 0x80700 phys_seg 16 prio class 2
Jul 03 22:15:20 vm-trixie kernel: I/O error, dev nbd0, sector 2048 op
0x0:(READ) flags 0x800000 phys_seg 1 prio class 2
Jul 03 22:15:20 vm-trixie kernel: Buffer I/O error on dev nbd0p1, logical block
0, async page read
Jul 03 22:15:20 vm-trixie kernel: I/O error, dev nbd0, sector 0 op 0x0:(READ)
flags 0x800000 phys_seg 1 prio class 2
Jul 03 22:15:20 vm-trixie kernel: Buffer I/O error on dev nbd0, logical block
0, async page read
Jul 03 22:15:20 vm-trixie kernel: I/O error, dev nbd0, sector 0 op 0x0:(READ)
flags 0x800000 phys_seg 1 prio class 2
Jul 03 22:15:20 vm-trixie kernel: Buffer I/O error on dev nbd0, logical block
0, async page read
Jul 03 22:15:20 vm-trixie udisksd[961]: Partitions found on device '/dev/nbd0'
but couldn't read partition table signature: Failed to assign the new context
to disk '/dev/nbd0': Input/output error
Jul 03 22:15:20 vm-trixie udisksd[961]: Partitions found on device '/dev/nbd0'
but couldn't read partition table signature: Failed to assign the new context
to disk '/dev/nbd0': Input/output error
Jul 03 22:15:20 vm-trixie kernel: I/O error, dev nbd0, sector 206880 op
0x0:(READ) flags 0x80700 phys_seg 8 prio class 2
Jul 03 22:15:20 vm-trixie kernel: I/O error, dev nbd0, sector 206880 op
0x0:(READ) flags 0x800000 phys_seg 1 prio class 2
Jul 03 22:15:20 vm-trixie kernel: Buffer I/O error on dev nbd0p2, logical block
4, async page read
Jul 03 22:15:20 vm-trixie kernel: I/O error, dev nbd0, sector 41940864 op
0x0:(READ) flags 0x80700 phys_seg 11 prio class 2
Jul 03 22:15:20 vm-trixie kernel: I/O error, dev nbd0, sector 41940864 op
0x0:(READ) flags 0x800000 phys_seg 1 prio class 2
Jul 03 22:15:20 vm-trixie kernel: Buffer I/O error on dev nbd0p2, logical block
5216752, async page read
Jul 03 22:15:20 vm-trixie kernel: Buffer I/O error on dev nbd0, logical block
0, async page read
Jul 03 22:15:20 vm-trixie kernel: Buffer I/O error on dev nbd0, logical block
0, async page read
Jul 03 22:15:20 vm-trixie kernel: Buffer I/O error on dev nbd0, logical block
0, async page read
Jul 03 22:15:20 vm-trixie kernel: Buffer I/O error on dev nbd0p1, logical block
0, async page read
```

From then on, the nbd device becomes unusable: attempts to connect it to a
qcow2 file result in subsequent I/O errors.

This also affects physical removable devices in a similar way, preventing their
clean removal:
```
$ sudo eject /dev/sda
eject: cannot open /dev/sda: Device or resource busy
```

Disconnecting produces the following errors in logs:
```
Jul 05 04:27:21 morgwai-x4tuxedo kernel: usb 3-2: USB disconnect, device number
5
Jul 05 04:27:21 morgwai-x4tuxedo kernel: EXT4-fs (sda5): shut down requested
(2)
Jul 05 04:27:21 morgwai-x4tuxedo kernel: Aborting journal on device sda5-8.
Jul 05 04:27:21 morgwai-x4tuxedo kernel: device offline error, dev sda, sector
126885888 op 0x1:(WRITE) flags 0x9800 phys_seg 1 prio class 2
Jul 05 04:27:21 morgwai-x4tuxedo kernel: Buffer I/O error on dev sda5, logical
block 1081344, lost sync page write
Jul 05 04:27:21 morgwai-x4tuxedo kernel: JBD2: I/O error when updating journal
superblock for sda5-8.
```

On Devuan Excalibur this works perfectly fine, so this seems to be a systemd
issue.