mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-22 18:00:35 +00:00
Fix MBR offset and add some comments to explain
This commit is contained in:
parent
3e4882128e
commit
2ebacf6a3a
2 changed files with 12 additions and 6 deletions
|
@ -48,12 +48,12 @@ class GPTPartitionMap(AbstractPartitionMap):
|
|||
|
||||
# We need to move the first partition to make space for the gpt offset
|
||||
gpt_offset = Bytes('17KiB')
|
||||
self.partitions[0].offset = gpt_offset
|
||||
self.partitions[0].offset += gpt_offset
|
||||
|
||||
if hasattr(self, 'grub_boot'):
|
||||
# grub_boot should not increase the size of the volume,
|
||||
# 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()
|
||||
else:
|
||||
# Avoid increasing the volume size because of gpt_offset
|
||||
|
|
|
@ -40,11 +40,17 @@ class MSDOSPartitionMap(AbstractPartitionMap):
|
|||
# Mark boot as the boot partition, or root, if boot does not exist
|
||||
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
|
||||
# of the partitionmap and steal it from the first partition
|
||||
# If we are using the grub bootloader, we will need to add a 2 MB offset
|
||||
# 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':
|
||||
self.partitions[0].offset = Bytes('2MiB')
|
||||
self.partitions[0].size -= self.partitions[0].offset
|
||||
offset = Bytes('2MiB')
|
||||
else:
|
||||
offset = Bytes('512B')
|
||||
|
||||
self.partitions[0].offset += offset
|
||||
self.partitions[0].size -= offset
|
||||
|
||||
super(MSDOSPartitionMap, self).__init__(bootloader)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue