From e3beb0710836deab2f4e366b4681e5a04c1107a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 9 May 2017 18:56:26 +0100 Subject: [PATCH] systemd-boot: sync efi filesystem after update Since fat32 provides little recovery facilities after a crash, it can leave the system in an unbootable state, when a crash/outage happens shortly after an update. To decrease the likelihood of this event sync the efi filesystem after each update. --- .../boot/loader/systemd-boot/systemd-boot-builder.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py index 704c574b822e..804b710f3759 100644 --- a/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py +++ b/nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py @@ -2,12 +2,15 @@ import argparse import shutil import os +import sys import errno import subprocess import glob import tempfile import errno import warnings +import ctypes +libc = ctypes.CDLL("libc.so.6") def copy_if_not_exists(source, dest): if not os.path.exists(dest): @@ -145,5 +148,9 @@ def main(): if os.readlink(system_dir(gen)) == args.default_config: write_loader_conf(gen) + rc = libc.syncfs(os.open("@efiSysMountPoint@", os.O_RDONLY)) + if rc != 0: + print("could not sync @efiSysMountPoint@: {}".format(os.strerror(rc)), file=sys.stderr) + if __name__ == '__main__': main()