Added is_4k_aligned_macos()
This commit is contained in:
parent
5d6b7578d3
commit
d25b341eb3
1 changed files with 20 additions and 1 deletions
|
|
@ -265,7 +265,9 @@ class Disk():
|
||||||
def is_4k_aligned(self):
|
def is_4k_aligned(self):
|
||||||
"""Check that all disk partitions are aligned, returns bool."""
|
"""Check that all disk partitions are aligned, returns bool."""
|
||||||
aligned = True
|
aligned = True
|
||||||
if platform.system() == 'Linux':
|
if platform.system() == 'Darwin':
|
||||||
|
aligned = is_4k_aligned_macos(self.details)
|
||||||
|
elif platform.system() == 'Linux':
|
||||||
aligned = is_4k_aligned_linux(self.path, self.details['phy-sec'])
|
aligned = is_4k_aligned_linux(self.path, self.details['phy-sec'])
|
||||||
#TODO: Add checks for other OS
|
#TODO: Add checks for other OS
|
||||||
|
|
||||||
|
|
@ -455,6 +457,23 @@ def get_ram_list_macos():
|
||||||
return dimm_list
|
return dimm_list
|
||||||
|
|
||||||
|
|
||||||
|
def is_4k_aligned_macos(disk_details):
|
||||||
|
"""Check partition alignment using diskutil info, returns bool."""
|
||||||
|
aligned = True
|
||||||
|
|
||||||
|
# Check partitions
|
||||||
|
for part in disk_details.get('children', []):
|
||||||
|
offset = part.get('PartitionMapPartitionOffset', 0)
|
||||||
|
if not offset:
|
||||||
|
# Assuming offset couldn't be found and it defaulted to 0
|
||||||
|
# NOTE: Just logging the error, not bailing
|
||||||
|
LOG.error('Failed to get partition offset for %s', part['path'])
|
||||||
|
aligned = aligned and offset >= 0 and offset % 4096 == 0
|
||||||
|
|
||||||
|
# Done
|
||||||
|
return aligned
|
||||||
|
|
||||||
|
|
||||||
def is_4k_aligned_linux(dev_path, physical_sector_size):
|
def is_4k_aligned_linux(dev_path, physical_sector_size):
|
||||||
"""Check partition alignment using lsblk, returns bool."""
|
"""Check partition alignment using lsblk, returns bool."""
|
||||||
aligned = True
|
aligned = True
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue