The laptops owned by SOI have 8 GB of RAM, and live systems running on them sometimes run out of memory. To mitigate this, find and enable the swap partition of the installed OS on the internal SSD.
13 lines
442 B
Python
13 lines
442 B
Python
#!/usr/bin/python3
|
|
|
|
import subprocess
|
|
import json
|
|
|
|
SD_GPT_SWAP = '0657fd6d-a4ab-43c4-84e5-0933c84b4f4f'
|
|
|
|
lsblk_result = subprocess.run(['lsblk', '--json', '--output=PATH,PARTTYPE'], check=True, stdout=subprocess.PIPE)
|
|
lablk_out = json.loads(lsblk_result.stdout)
|
|
for block in lablk_out['blockdevices']:
|
|
if block['parttype'] == SD_GPT_SWAP:
|
|
print('Enabling swap on', block['path'])
|
|
subprocess.run(['swapon', block['path']])
|