Skip to content

Commit

Permalink
Partition: Mask DM/LVM rules, don't stop udev
Browse files Browse the repository at this point in the history
While partitions are being created and wiped, mask udev rules related to
Device Mapper and LVM to prevent partitions from being activated
automatically. This replaces the previous solution of completely
stopping udev during these operations, which prevented the use of
device names created by the persistent storage rules.

Fixes #105.
  • Loading branch information
jrha committed Feb 9, 2024
1 parent fc8b517 commit 259de6f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/perl/Partition.pm
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,9 @@ sub create_pre_ks
# make sure this never matches on anything else
$extended_txt .= "_no_msdos_label" if ($self->{holding_dev}->{label} ne MSDOS);

# Avoid LVM/mdadm/etc. autodiscovery kicking in after the partition has
# been created
my $pause_udev = $self->{anaconda_version} >= ANACONDA_VERSION_EL_7_0 ? "udevadm control --stop-exec-queue" : "";
my $unpause_udev = $self->{anaconda_version} >= ANACONDA_VERSION_EL_7_0 ? "udevadm control --start-exec-queue" : "";
# Avoid LVM/mdadm/etc. autodiscovery kicking in after the partition has been created
my $mask_udev_rules = $self->{anaconda_version} >= ANACONDA_VERSION_EL_7_0 ? "find /usr/lib/udev/rules.d/ -type f -name \*.rules | grep -E '(dm|lvm)' | xargs basename -a | xargs -I@ touch /etc/udev/rules.d/@" : "";
my $unmask_udev_rules = $self->{anaconda_version} >= ANACONDA_VERSION_EL_7_0 ? "rm -f /etc/udev/rules.d/*.rules" : "";

print <<EOF;
if ! grep -q '$self->{devname}\$' /proc/partitions
Expand Down Expand Up @@ -676,7 +675,7 @@ EOF
}
print <<EOF;
$end_txt
$pause_udev
$mask_udev_rules
parted $disk -s -- u s mkpart $self->{type} \$begin \$end
while true; do
sleep 1
Expand All @@ -692,7 +691,7 @@ EOF
}

print <<EOF;
$unpause_udev
$unmask_udev_rules
udevadm settle
EOF

Expand Down

0 comments on commit 259de6f

Please sign in to comment.