Fix MBR offset and add some comments to explain

This commit is contained in:
Anders Ingemann 2014-05-04 12:16:25 +02:00
parent 3e4882128e
commit 2ebacf6a3a
2 changed files with 12 additions and 6 deletions

View file

@ -48,12 +48,12 @@ class GPTPartitionMap(AbstractPartitionMap):
# We need to move the first partition to make space for the gpt offset # We need to move the first partition to make space for the gpt offset
gpt_offset = Bytes('17KiB') gpt_offset = Bytes('17KiB')
self.partitions[0].offset = gpt_offset self.partitions[0].offset += gpt_offset
if hasattr(self, 'grub_boot'): if hasattr(self, 'grub_boot'):
# grub_boot should not increase the size of the volume, # grub_boot should not increase the size of the volume,
# so we reduce the size of the succeeding partition. # so we reduce the size of the succeeding partition.
# gpt_offset is included here, because of the offset we added above # gpt_offset is included here, because of the offset we added above (grub_boot is partition[0])
self.partitions[1].size -= self.grub_boot.get_end() self.partitions[1].size -= self.grub_boot.get_end()
else: else:
# Avoid increasing the volume size because of gpt_offset # Avoid increasing the volume size because of gpt_offset

View file

@ -40,11 +40,17 @@ class MSDOSPartitionMap(AbstractPartitionMap):
# Mark boot as the boot partition, or root, if boot does not exist # Mark boot as the boot partition, or root, if boot does not exist
getattr(self, 'boot', self.root).flags.append('boot') getattr(self, 'boot', self.root).flags.append('boot')
# If we are using the grub bootloader, we will need to create a 2 MB offset at the beginning # If we are using the grub bootloader, we will need to add a 2 MB offset
# of the partitionmap and steal it from the first partition # at the beginning of the partitionmap and steal it from the first partition.
# The MBR offset is included in the grub offset, so if we don't use grub
# we should reduce the size of the first partition and move it by only 512 bytes.
if bootloader == 'grub': if bootloader == 'grub':
self.partitions[0].offset = Bytes('2MiB') offset = Bytes('2MiB')
self.partitions[0].size -= self.partitions[0].offset else:
offset = Bytes('512B')
self.partitions[0].offset += offset
self.partitions[0].size -= offset
super(MSDOSPartitionMap, self).__init__(bootloader) super(MSDOSPartitionMap, self).__init__(bootloader)