self.__disks = {}
self.__disk_format = "raw"
self._disk_names = []
+ self._ptable_format = self.ks.handler.bootloader.ptable
self.vmem = 512
self.vcpu = 1
self.checksum = False
boot = p.active,
align = p.align)
- self.__instloop.layout_partitions()
+ self.__instloop.layout_partitions(self._ptable_format)
# Create the disks
self.__imgdir = self._mkdtemp()
loopdev = self.__disks[name].device
i =i+1
- msger.debug("Installing syslinux bootloader to %s" % loopdev)
-
(bootdevnum, rootdevnum, rootdev, prefix) = \
self._get_syslinux_boot_config()
#Set MBR
- mbrsize = os.stat("%s/usr/share/syslinux/mbr.bin" \
- % self._instroot)[stat.ST_SIZE]
- rc = runner.show(['dd',
- 'if=%s/usr/share/syslinux/mbr.bin' % self._instroot,
- 'of=' + loopdev])
+ mbrfile = "%s/usr/share/syslinux/" % self._instroot
+ if self._ptable_format == 'gpt':
+ mbrfile += "gptmbr.bin"
+ else:
+ mbrfile += "mbr.bin"
+
+ msger.debug("Installing syslinux bootloader '%s' to %s" % \
+ (mbrfile, loopdev))
+
+ mbrsize = os.stat(mbrfile)[stat.ST_SIZE]
+ rc = runner.show(['dd', 'if=%s' % mbrfile, 'of=' + loopdev])
if rc != 0:
raise MountError("Unable to set MBR to %s" % loopdev)
d = self.disks[dev]
msger.debug("Initializing partition table for %s" % \
(d['disk'].device))
- self.__run_parted([ "-s", d['disk'].device, "mklabel", "msdos" ])
+ self.__run_parted(["-s", d['disk'].device, "mklabel",
+ d['ptable_format']])
msger.debug("Creating partitions")
parted_fs_type, p['start'], p['size'])
if p['boot']:
- msger.debug("Set boot flag for partition '%s' on disk '%s'" % \
- (p['num'], d['disk'].device))
+ if d['ptable_format'] == 'gpt':
+ flag_name = "legacy_boot"
+ else:
+ flag_name = "boot"
+ msger.debug("Set '%s' flag for partition '%s' on disk '%s'" % \
+ (flag_name, p['num'], d['disk'].device))
self.__run_parted(["-s", d['disk'].device, "set",
- "%d" % p['num'], "boot", "on"])
+ "%d" % p['num'], flag_name, "on"])
def __map_partitions(self):
"""Load it if dm_snapshot isn't loaded. """