udev deletes and recreates partition devices when the disk is opened r/w
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
systemd (Ubuntu) |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
Description: Ubuntu 16.04.1 LTS
Release: 16.04
parted: 3.2-15
gparted: 0.25.0-1
Applications that utilized parted/libparted to probe for block device information disable the read only status during the probe.
Example:
Set a block device read only using either hdparm -r1 /dev/sdc* or blockdev --setro /dev/sdc*:
# hdparm -r1 /dev/sdc*
/dev/sdc:
readonly = 1 (on)
/dev/sdc1:
readonly = 1 (on)
Run gparted
Check the readonly status with hdparm:
# hdparm -r /dev/sdc*
/dev/sdc:
readonly = 0 (off)
/dev/sdc1:
readonly = 0 (off)
The read only status has changed to off. This can be replicated using partprobe:
Set a block device read only using either hdparm -r1 /dev/sdc*:
# hdparm -r1 /dev/sdc*
/dev/sdc:
readonly = 1 (on)
/dev/sdc1:
readonly = 1 (on)
Probe the devices using partprobe -s:
# partprobe -s
/dev/sda: msdos partitions 1 2 3
/dev/sdb: gpt partitions 1 2 3 5 4
/dev/sdc: msdos partitions 1
Recheck the read only status:
# hdparm -r /dev/sdc*
/dev/sdc:
readonly = 0 (off)
/dev/sdc1:
readonly = 0 (off)
As before the read only status has been switched off. Again, this can be replicated using parted:
Set a block device read only using either hdparm -r1 /dev/sdc*:
# hdparm -r1 /dev/sdc*
/dev/sdc:
readonly = 1 (on)
/dev/sdc1:
readonly = 1 (on)
List the partition layout using parted -l:
# parted -l
.
.
Model: WDC WD10 EFRX-68JCSN0 (scsi)
Disk /dev/sdc: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 1000GB 1000GB primary ntfs
Recheck the read only status:
# hdparm -r /dev/sdc*
/dev/sdc:
readonly = 0 (off)
/dev/sdc1:
readonly = 0 (off)
affects: | udev (Ubuntu) → systemd (Ubuntu) |
I could not reproduce this at first using a loop device, but then I tried scsi_debug. This can be reproduced with a simple dd if=/dev/zero count=0 of=/dev/sda. Parted takes care to not needlessly delete and recreate partition dev nodes when they are not modified, but it appears that there has been a regression in udev/systemd that deletes and recreates all partitions on the disk any time the disk is opened for RW access, thus resetting the RO flag, and also triggering needless update events that cause unity to re-add removed drive icons to the launcher.