From 2acaf32699af6ac49bb9dc0f4deab9e1a0c62dbf Mon Sep 17 00:00:00 2001 From: Kai Lueke Date: Fri, 29 Sep 2023 18:15:13 +0200 Subject: [PATCH] Run partprobe after Ignition partition changes This adds https://github.com/coreos/ignition/pull/1717 as downstream patch to fix https://github.com/flatcar/Flatcar/issues/1194 --- .../bugfixes/2023-09-29-ignition-partition.md | 1 + ...un-partprobe-after-partition-changes.patch | 67 +++++++++++++++++++ ....0-r3.ebuild => ignition-2.15.0-r4.ebuild} | 0 .../sys-apps/ignition/ignition-9999.ebuild | 1 + ...20.ebuild => bootengine-0.0.38-r21.ebuild} | 0 .../bootengine/bootengine-9999.ebuild | 2 +- 6 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 changelog/bugfixes/2023-09-29-ignition-partition.md create mode 100644 sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/files/0022-sgdisk-Run-partprobe-after-partition-changes.patch rename sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/{ignition-2.15.0-r3.ebuild => ignition-2.15.0-r4.ebuild} (100%) rename sdk_container/src/third_party/coreos-overlay/sys-kernel/bootengine/{bootengine-0.0.38-r20.ebuild => bootengine-0.0.38-r21.ebuild} (100%) diff --git a/changelog/bugfixes/2023-09-29-ignition-partition.md b/changelog/bugfixes/2023-09-29-ignition-partition.md new file mode 100644 index 00000000000..b92e78bbe86 --- /dev/null +++ b/changelog/bugfixes/2023-09-29-ignition-partition.md @@ -0,0 +1 @@ +- Triggered re-reading of partition table to fix adding partitions to the boot disk [scripts#1202](https://github.com/flatcar/scripts/pull/1202) diff --git a/sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/files/0022-sgdisk-Run-partprobe-after-partition-changes.patch b/sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/files/0022-sgdisk-Run-partprobe-after-partition-changes.patch new file mode 100644 index 00000000000..06901f2a20b --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/files/0022-sgdisk-Run-partprobe-after-partition-changes.patch @@ -0,0 +1,67 @@ +From e5c4e6bd9f3bad3b27e338e4da2f3b0b53ab1599 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. +--- + dracut/30ignition/module-setup.sh | 1 + + internal/distro/distro.go | 2 ++ + internal/sgdisk/sgdisk.go | 5 +++++ + 3 files changed, 8 insertions(+) + +diff --git a/dracut/30ignition/module-setup.sh b/dracut/30ignition/module-setup.sh +index ad7e80fd..3cdcb631 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 61ca87ae..c1c13b62 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 29915809..e70a3881 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, "re-reading of %d deleted partitions and %d created partitions on %q", len(op.deletions), len(op.parts), op.dev); err != nil { ++ return fmt.Errorf("re-reading partitions failed: %v", err) ++ } + + return nil + } +-- +2.41.0 + diff --git a/sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/ignition-2.15.0-r3.ebuild b/sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/ignition-2.15.0-r4.ebuild similarity index 100% rename from sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/ignition-2.15.0-r3.ebuild rename to sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/ignition-2.15.0-r4.ebuild diff --git a/sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/ignition-9999.ebuild b/sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/ignition-9999.ebuild index 8a91aa6418d..6c53d9c7eca 100644 --- a/sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/ignition-9999.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/sys-apps/ignition/ignition-9999.ebuild @@ -63,6 +63,7 @@ PATCHES=( "${FILESDIR}/0019-docs-Add-re-added-platforms-to-docs-to-pass-tests.patch" "${FILESDIR}/0020-usr-share-oem-oem.patch" "${FILESDIR}/0021-internal-exec-stages-mount-Mount-oem.patch" + "${FILESDIR}/0022-sgdisk-Run-partprobe-after-partition-changes.patch" ) src_compile() { diff --git a/sdk_container/src/third_party/coreos-overlay/sys-kernel/bootengine/bootengine-0.0.38-r20.ebuild b/sdk_container/src/third_party/coreos-overlay/sys-kernel/bootengine/bootengine-0.0.38-r21.ebuild similarity index 100% rename from sdk_container/src/third_party/coreos-overlay/sys-kernel/bootengine/bootengine-0.0.38-r20.ebuild rename to sdk_container/src/third_party/coreos-overlay/sys-kernel/bootengine/bootengine-0.0.38-r21.ebuild diff --git a/sdk_container/src/third_party/coreos-overlay/sys-kernel/bootengine/bootengine-9999.ebuild b/sdk_container/src/third_party/coreos-overlay/sys-kernel/bootengine/bootengine-9999.ebuild index 7cb9c3debda..fa2d604d2fd 100644 --- a/sdk_container/src/third_party/coreos-overlay/sys-kernel/bootengine/bootengine-9999.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/sys-kernel/bootengine/bootengine-9999.ebuild @@ -10,7 +10,7 @@ CROS_WORKON_REPO="https://github.com" if [[ "${PV}" == 9999 ]]; then KEYWORDS="~amd64 ~arm ~arm64 ~x86" else - CROS_WORKON_COMMIT="2c0968a0c26a3f39721e76fb99368ee0fabffc7c" # flatcar-master + CROS_WORKON_COMMIT="9eaeae2fbbdef1d6364a95192bf8e5b35dca8ed1" # flatcar-master KEYWORDS="amd64 arm arm64 x86" fi