From d6f331d7788bc9b9a38ec71952f5827dc4388461 Mon Sep 17 00:00:00 2001 From: Kai Lueke Date: Fri, 29 Sep 2023 18:06:09 +0200 Subject: [PATCH] sgdisk: Run partprobe after partition changes The sgdisk tool does not update the kernel partition table in contrast to other similar tools. Often udev can detect the changes but not always as experienced when adding a new partition on Flatcar's boot disk. Instead of implicitly relying on some other component to re-read the kernel partition table, trigger the re-read with partprobe. --- docs/release-notes.md | 2 ++ dracut/30ignition/module-setup.sh | 1 + internal/distro/distro.go | 2 ++ internal/sgdisk/sgdisk.go | 5 +++++ 4 files changed, 10 insertions(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 6cf20fa57f..5cf207396d 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -15,10 +15,12 @@ nav_order: 9 ### Changes +- The Dracut module now installs partprobe ### Bug fixes - Prevent races with udev after disk editing +- Force partition table reread rather than relying on udev ## Ignition 2.16.2 (2023-07-12) diff --git a/dracut/30ignition/module-setup.sh b/dracut/30ignition/module-setup.sh index ad7e80fdf8..3cdcb6317e 100755 --- a/dracut/30ignition/module-setup.sh +++ b/dracut/30ignition/module-setup.sh @@ -33,6 +33,7 @@ install() { mkfs.xfs \ mkswap \ sgdisk \ + partprobe \ useradd \ userdel \ usermod \ diff --git a/internal/distro/distro.go b/internal/distro/distro.go index 61ca87aed9..c1c13b6221 100644 --- a/internal/distro/distro.go +++ b/internal/distro/distro.go @@ -37,6 +37,7 @@ var ( mdadmCmd = "mdadm" mountCmd = "mount" sgdiskCmd = "sgdisk" + partprobeCmd = "partprobe" modprobeCmd = "modprobe" udevadmCmd = "udevadm" usermodCmd = "usermod" @@ -90,6 +91,7 @@ func GroupdelCmd() string { return groupdelCmd } func MdadmCmd() string { return mdadmCmd } func MountCmd() string { return mountCmd } func SgdiskCmd() string { return sgdiskCmd } +func PartprobeCmd() string { return partprobeCmd } func ModprobeCmd() string { return modprobeCmd } func UdevadmCmd() string { return udevadmCmd } func UsermodCmd() string { return usermodCmd } diff --git a/internal/sgdisk/sgdisk.go b/internal/sgdisk/sgdisk.go index 2991580982..72c95522ec 100644 --- a/internal/sgdisk/sgdisk.go +++ b/internal/sgdisk/sgdisk.go @@ -121,6 +121,11 @@ func (op *Operation) Commit() error { if _, err := op.logger.LogCmd(cmd, "deleting %d partitions and creating %d partitions on %q", len(op.deletions), len(op.parts), op.dev); err != nil { return fmt.Errorf("create partitions failed: %v", err) } + // In contrast to similar tools, sgdisk does not trigger the update of the kernel partition table + cmd = exec.Command(distro.PartprobeCmd(), op.dev) + if _, err := op.logger.LogCmd(cmd, "triggering partition table reread on %q", op.dev); err != nil { + return fmt.Errorf("re-reading partitions failed: %v", err) + } return nil }