diff --git a/scripts/auto_setup.py b/scripts/auto_setup.py index 2d75585c..458d39c0 100644 --- a/scripts/auto_setup.py +++ b/scripts/auto_setup.py @@ -143,7 +143,7 @@ BASE_MENUS = { MenuEntry('Installed RAM', 'auto_show_installed_ram'), MenuEntry('Storage Status', 'auto_show_storage_status'), MenuEntry('Virus Protection', 'auto_show_installed_antivirus'), - MenuEntry('Partitions 4K Aligned', no_op), + MenuEntry('Partitions 4K Aligned', 'auto_show_4k_alignment_check'), ), 'Run Programs': ( MenuEntry('Device Manager', no_op), diff --git a/scripts/wk/os/win.py b/scripts/wk/os/win.py index 50ea654e..4d73c21e 100644 --- a/scripts/wk/os/win.py +++ b/scripts/wk/os/win.py @@ -152,6 +152,23 @@ def set_timezone(zone): # Info Functions +def check_4k_alignment(show_alert=False): + """Check if all partitions are 4K aligned, returns book.""" + cmd = ['WMIC', 'partition', 'get', 'StartingOffset'] + + # Check offsets + proc = run_program(cmd) + for offset in proc.stdout.splitlines(): + offset = offset.strip() + if not offset.isnumeric(): + continue + if int(offset) % 4096 != 0: + # Not aligned + if show_alert: + show_alert_box('One or more partitions are not 4K aligned') + raise GenericError('One or more partitions are not 4K aligned') + + def get_installed_antivirus(): """Get list of installed antivirus programs, returns list.""" cmd = [ diff --git a/scripts/wk/setup/win.py b/scripts/wk/setup/win.py index a10b2ec0..3cb1ff18 100644 --- a/scripts/wk/setup/win.py +++ b/scripts/wk/setup/win.py @@ -44,6 +44,7 @@ if platform.system() == 'Windows': from wk.os.win import ( OS_VERSION, activate_with_bios, + check_4k_alignment, get_installed_antivirus, get_installed_ram, get_os_activation, @@ -71,6 +72,7 @@ else: """No-op function.""" # wk.os.win activate_with_bios = no_op + check_4k_alignment = no_op get_installed_antivirus = no_op get_installed_ram = no_op get_os_activation = no_op @@ -570,6 +572,11 @@ def auto_restore_default_uac(): TRY_PRINT.run('User Account Control...', restore_default_uac) +def auto_show_4k_alignment_check(): + """Display 4K alignment check.""" + TRY_PRINT.run('4K alignment Check...', check_4k_alignment, show_alert=True) + + def auto_show_installed_antivirus(): """Display installed antivirus.""" TRY_PRINT.run('Virus Protection...', get_installed_antivirus)