diff --git a/lib/utils.py b/lib/utils.py
index 193fde8123ad4d24a5d3d167025417936575e4be..53fa6f26c87905e458701865f75c0adfe708cfc5 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -775,6 +775,7 @@ def SetEtcHostsEntry(file_name, ip, hostname, aliases):
         out.write('\n')
 
         out.flush()
+        os.fsync(out)
         os.rename(tmpname, file_name)
       finally:
         f.close()
@@ -810,6 +811,7 @@ def RemoveEtcHostsEntry(file_name, hostname):
           out.write(line)
 
         out.flush()
+        os.fsync(out)
         os.rename(tmpname, file_name)
       finally:
         f.close()