Allow swap creation to fail
This commit is contained in:
parent
1a39cffd68
commit
bbe928f340
@ -318,10 +318,19 @@ def main():
|
||||
|
||||
print("> Adding files")
|
||||
print("Creating swap ...")
|
||||
call(["dd","if=/dev/zero","of=" +ipth("swap"),"bs=1M","count=512","status=progress"])
|
||||
call(["chmod","600",ipth("swap")])
|
||||
call(["mkswap",ipth("swap")])
|
||||
call(["swapon",ipth("swap")])
|
||||
hasSwap = False
|
||||
try:
|
||||
call(["dd","if=/dev/zero","of=" +ipth("swap"),"bs=1M","count=512","status=progress"])
|
||||
call(["chmod","600",ipth("swap")])
|
||||
call(["mkswap",ipth("swap")])
|
||||
call(["swapon",ipth("swap")])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("Creating swap failed, skipping.")
|
||||
try:
|
||||
os.remove(ipth("swap"))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
print("Unpacking OS ...")
|
||||
call(["unsquashfs","-f","-d",ipth(),"/lib/live/mount/medium/live/filesystem.squashfs"])
|
||||
@ -347,7 +356,7 @@ def main():
|
||||
print("Writing fstab ...")
|
||||
fh = open(ipth("etc/fstab"),"w")
|
||||
fh.write('UUID=' +installPartitionUUID+ ' / ' +getPartitionType(installPartition)+ ' defaults 0 1\n')
|
||||
fh.write('/swap none swap sw 0 0\n')
|
||||
if hasSwap: fh.write('/swap none swap sw 0 0\n')
|
||||
fh.close()
|
||||
|
||||
print("Copying keyboard settings ...")
|
||||
@ -399,7 +408,7 @@ def main():
|
||||
chroot(ipth(),["update-grub"])
|
||||
|
||||
print("> Unmounting ...")
|
||||
call(["swapoff",ipth("swap")])
|
||||
if hasSwap: call(["swapoff",ipth("swap")])
|
||||
call(["umount",ipth()])
|
||||
os.rmdir(ipth())
|
||||
if encrypt: call(["cryptsetup","luksClose","system"])
|
||||
|
Loading…
Reference in New Issue
Block a user