From 2ff03360ed60e1ff3b64b31add941c0ed2503a40 Mon Sep 17 00:00:00 2001
From: Hermann Huy <hermann.huy@nsn.com>
Date: Mon, 5 Mar 2012 11:00:36 +0100
Subject: [PATCH] added bios_grub partition

---
 scripts/storage.py |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/scripts/storage.py b/scripts/storage.py
index cf8da35..061a8a1 100644
--- a/scripts/storage.py
+++ b/scripts/storage.py
@@ -549,18 +549,25 @@ class Storage:
             # efi partition should at 0M
             if is_efi_boot():
                 efi_start = 0
+                parted_cmd = "parted \"" + self.ROOTDRIVE + "\" -s \"mkpart EFI " + str(efi_start) + "M " + str(self.EFI_SIZE)+"M\""
+                logger.debug(parted_cmd)
+                system(parted_cmd)
             else:
                 efi_start = 1
-            parted_cmd = "parted \"" + self.ROOTDRIVE + "\" -s \"mkpart EFI " + str(efi_start) + "M " + str(self.EFI_SIZE)+"M\""
-            logger.debug(parted_cmd)
-            system(parted_cmd)
+                # create partition labeled bios_grub
+                parted_cmd = "parted \"" + self.ROOTDRIVE + "\" -s \"mkpart primary " + str(efi_start) + "M " + str(self.EFI_SIZE)+"M\""
+                logger.debug(parted_cmd)
+                system(parted_cmd)
+                parted_cmd = "parted \"" + self.ROOTDRIVE + "\" -s \"set 1 bios_grub on\""
+                logger.debug(parted_cmd)
+                system(parted_cmd)
             parted_cmd = "parted \"" + self.ROOTDRIVE + "\" -s \"mkpart primary ext2 "+str(self.EFI_SIZE)+"M "+ str(self.Root_end)+"M\""
             logger.debug(parted_cmd)
             system(parted_cmd)
             parted_cmd = "parted \""+self.ROOTDRIVE+"\" -s \"mkpart primary ext2 "+str(self.Root_end)+"M "+str(self.RootBackup_end)+"M\""
             logger.debug(parted_cmd)
             system(parted_cmd)
-            parted_cmd = "parted \""+self.ROOTDRIVE+"\" -s \"set 1 boot on\""
+            parted_cmd = "parted \""+self.ROOTDRIVE+"\" -s \"set 2 boot on\""
             logger.debug(parted_cmd)
             system(parted_cmd)
             # sleep to ensure filesystems are created before continuing
@@ -575,8 +582,9 @@ class Storage:
                 partefi = self.ROOTDRIVE + "p1"
                 partroot = self.ROOTDRIVE + "p2"
                 partrootbackup= self.ROOTDRIVE + "p3"
-            system("ln -snf \""+partefi+"\" /dev/disk/by-label/EFI")
-            system("mkfs.vfat \""+partefi+"\" -n EFI -F32")
+            if is_efi_boot():
+                system("ln -snf \""+partefi+"\" /dev/disk/by-label/EFI")
+                system("mkfs.vfat \""+partefi+"\" -n EFI -F32")
             system("ln -snf \""+partroot+"\" /dev/disk/by-label/Root")
             system("mke2fs \""+partroot+"\" -L Root")
             system("tune2fs -c 0 -i 0 \""+partroot+"\"")
-- 
1.7.7.6

