Skip to content

Commit 427ea10

Browse files
committed
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 should look for mounted devices only. Signed-off-by: Tiago Bueno <[email protected]>
1 parent 2bcc596 commit 427ea10

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

docs/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ nav_order: 9
2828
### Bug fixes
2929

3030
- Fix fetch-offline for Oracle Cloud Infrastructure
31+
- Fix device mapper partitioning ([#2128](https://github.com/coreos/ignition/issues/2128))
3132

3233
## Ignition 2.22.0 (2025-07-08)
3334
Starting with this release, ignition-validate binaries are signed with the

internal/exec/stages/disks/partitions.go

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,6 @@ func (p PartitionList) Swap(i, j int) {
323323
p[i], p[j] = p[j], p[i]
324324
}
325325

326-
// Expects a /dev/xyz path
327-
func blockDevHeld(blockDevResolved string) (bool, error) {
328-
_, blockDevNode := filepath.Split(blockDevResolved)
329-
330-
holdersDir := fmt.Sprintf("/sys/class/block/%s/holders/", blockDevNode)
331-
entries, err := os.ReadDir(holdersDir)
332-
if err != nil {
333-
return false, fmt.Errorf("failed to retrieve holders of %q: %v", blockDevResolved, err)
334-
}
335-
return len(entries) > 0, nil
336-
}
337-
338326
// Expects a /dev/xyz path
339327
func blockDevMounted(blockDevResolved string) (bool, error) {
340328
mounts, err := os.Open("/proc/mounts")
@@ -383,16 +371,10 @@ func blockDevPartitions(blockDevResolved string) ([]string, error) {
383371
// Expects a /dev/xyz path
384372
func blockDevInUse(blockDevResolved string, skipPartitionCheck bool) (bool, []string, error) {
385373
// Note: This ignores swap and LVM usage
386-
inUse := false
387-
held, err := blockDevHeld(blockDevResolved)
388-
if err != nil {
389-
return false, nil, fmt.Errorf("failed to check if %q is held: %v", blockDevResolved, err)
390-
}
391-
mounted, err := blockDevMounted(blockDevResolved)
374+
inUse, err := blockDevMounted(blockDevResolved)
392375
if err != nil {
393376
return false, nil, fmt.Errorf("failed to check if %q is mounted: %v", blockDevResolved, err)
394377
}
395-
inUse = held || mounted
396378
if skipPartitionCheck {
397379
return inUse, nil, nil
398380
}

0 commit comments

Comments
 (0)