From 5fce81aeda6498425772d3af2bfa858ba8923140 Mon Sep 17 00:00:00 2001 From: Yuhang Wei Date: Tue, 5 Sep 2023 17:01:41 +0800 Subject: [PATCH 2/3] KubeOS: fix label changed after upgrade When upgrading, the label of the new root partition are changed to the original disk information Signed-off-by: Yuhang Wei --- cmd/agent/server/utils.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/agent/server/utils.go b/cmd/agent/server/utils.go index d2d0946..b4a19ff 100644 --- a/cmd/agent/server/utils.go +++ b/cmd/agent/server/utils.go @@ -75,6 +75,9 @@ func deleteNewline(out string) string { } func install(imagePath string, side string, next string) error { + if err := modifyImageLabel(imagePath, side, next); err != nil { + return err + } if err := runCommand("dd", "if="+imagePath, "of="+side, "bs=8M"); err != nil { return err } @@ -370,3 +373,10 @@ func getOCIImageDigest(containerRuntime string, imageName string) (string, error } return imageDigests, nil } + +func modifyImageLabel(imagePath, side, next string) error { + if err := runCommand("e2label", imagePath, "ROOT-"+next); err != nil { + return err + } + return nil +} -- 2.34.1