From 922b530f845138ba4558ca627c33020ab318f210 Mon Sep 17 00:00:00 2001 From: Julian Liu Date: Thu, 1 Jun 2017 17:23:41 +0800 Subject: [PATCH] Call sgdisk only on GPT partition type otherwise sgdisk will fail with exit status 3 on MBR partition --- cmd/ubuntu-recovery-image/main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/ubuntu-recovery-image/main.go b/cmd/ubuntu-recovery-image/main.go index e0557c9..ba8851e 100644 --- a/cmd/ubuntu-recovery-image/main.go +++ b/cmd/ubuntu-recovery-image/main.go @@ -64,8 +64,10 @@ func setupLoopDevice(recoveryOutputFile string, recoveryNR string, label string) //copy partition table log.Printf("Copy partitition table") rplib.Shellcmd(fmt.Sprintf("sfdisk -d %s | sfdisk %s", configs.Configs.BaseImage, recoveryOutputFile)) - log.Println("[recover the backup GPT entry]") - rplib.Shellexec("sgdisk", recoveryOutputFile, "--randomize-guids", "--move-second-header") + if configs.Configs.PartitionType == "gpt" { + log.Println("[recover the backup GPT entry]") + rplib.Shellexec("sgdisk", recoveryOutputFile, "--randomize-guids", "--move-second-header") + } var last_end int const PARTITION = "/tmp/partition.txt"