From 13a44baf739dabb5687a7e54c0e612a496cf9e03 Mon Sep 17 00:00:00 2001 From: Tiago Bueno Date: Mon, 29 Sep 2025 11:58:40 -0300 Subject: [PATCH] Fix device mapper partitioning When run ignition on a device mapper, ie, multipath, it fails because the function blockDevHeld returns true as the block device contains holders. A block device with holders do not necessary means the block device is in use (like mounted). The function blockDevInUse will not check if it is a device mapper and if so, do not check for blockDevHeld. Signed-off-by: Tiago Bueno (cherry picked from commit 2d04de325c59cc60158a12530b5ac2f40ec1e8c9) --- docs/release-notes.md | 7 +++++++ internal/exec/stages/disks/partitions.go | 18 +++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index da586fc8..a6077cf5 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -14,6 +14,13 @@ nav_order: 9 ### Bug fixes +## Ignition 2.22.1 (2025-11-07) +Starting with this release, ignition-validate binaries are signed with the +[Fedora 42 key](https://getfedora.org/security/). + +### Bug fixes + +- Fix multipath partitioning: ignore DM holders when no partitions are mounted;continue to refuse if the disk or any partition is active. ([#2128](https://github.com/coreos/ignition/issues/2128)) ## Ignition 2.22.0 (2025-07-08) Starting with this release, ignition-validate binaries are signed with the diff --git a/internal/exec/stages/disks/partitions.go b/internal/exec/stages/disks/partitions.go index 801485a4..1ae42721 100644 --- a/internal/exec/stages/disks/partitions.go +++ b/internal/exec/stages/disks/partitions.go @@ -323,6 +323,13 @@ func (p PartitionList) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +func isBlockDevMapper(blockDevResolved string) bool { + blockDevNode := filepath.Base(blockDevResolved) + dmName := fmt.Sprintf("/sys/class/block/%s/dm/name", blockDevNode) + _, err := os.Stat(dmName) + return err == nil +} + // Expects a /dev/xyz path func blockDevHeld(blockDevResolved string) (bool, error) { _, blockDevNode := filepath.Split(blockDevResolved) @@ -384,9 +391,14 @@ func blockDevPartitions(blockDevResolved string) ([]string, error) { func blockDevInUse(blockDevResolved string, skipPartitionCheck bool) (bool, []string, error) { // Note: This ignores swap and LVM usage inUse := false - held, err := blockDevHeld(blockDevResolved) - if err != nil { - return false, nil, fmt.Errorf("failed to check if %q is held: %v", blockDevResolved, err) + isDevMapper := isBlockDevMapper(blockDevResolved) + held := false + if !isDevMapper { + var err error + held, err = blockDevHeld(blockDevResolved) + if err != nil { + return false, nil, fmt.Errorf("failed to check if %q is held: %v", blockDevResolved, err) + } } mounted, err := blockDevMounted(blockDevResolved) if err != nil { -- 2.51.1