Add special case for BTRFS when creating swap

This commit is contained in:
Fierelier 2023-04-22 17:22:43 +02:00
parent bbe928f340
commit a1abd04580

View File

@ -320,8 +320,14 @@ def main():
print("Creating swap ...") print("Creating swap ...")
hasSwap = False hasSwap = False
try: try:
call(["dd","if=/dev/zero","of=" +ipth("swap"),"bs=1M","count=512","status=progress"]) if formatPartition == "btrfs":
call(["chmod","600",ipth("swap")]) call(["truncate","-s","0",ipth("swap")])
call(["chattr","+C",ipth("swap")])
call(["fallocate","-l","512M",ipth("swap")])
else:
call(["dd","if=/dev/zero","of=" +ipth("swap"),"bs=1M","count=512","status=progress"])
call(["chmod","0600",ipth("swap")])
call(["mkswap",ipth("swap")]) call(["mkswap",ipth("swap")])
call(["swapon",ipth("swap")]) call(["swapon",ipth("swap")])
except Exception as e: except Exception as e: