Added 4K alignment check to disk reports

* Addresses issue #73
This commit is contained in:
2Shirt 2019-05-13 18:23:47 -06:00
parent 6fe273cf8b
commit 51b6bd0fdf
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -319,6 +319,11 @@ class DiskObj():
attr_type=self.attr_type, **COLORS))
report.extend(sorted(self.nvme_smart_notes.keys()))
# 4K alignment check
if not self.is_4k_aligned():
report.append('{YELLOW}Warning{CLEAR}'.format(**COLORS))
report.append(' One or more partitions are not 4K aligned')
# Tests
for test in self.tests.values():
report.extend(test.report)
@ -422,6 +427,26 @@ class DiskObj():
'self_test', {}).get(
k, {})
def is_4k_aligned(self):
"""Check if partitions are 4K aligned, returns bool."""
cmd = [
'sudo',
'sfdisk',
'--json',
self.path,
]
aligned = True
# Get partition details
json_data = get_json_from_command(cmd)
# Check partitions
for part in json_data.get('partitiontable', {}).get('partitions', []):
aligned &= part.get('start', -1) % 4096 == 0
# Done
return aligned
def safety_check(self, silent=False):
"""Run safety checks and disable tests if necessary."""
test_running = False