--- a/ocaml/xapi/xapi.ml
+++ b/ocaml/xapi/xapi.ml
@@ -563,9 +563,10 @@
 (* Read the free memory on the host and record this in the db. This is used *)
 (* as the baseline for memory calculations in the message forwarding layer. *)
 let record_boot_time_host_free_memory () =
-	if !Xapi_globs.on_system_boot then begin
+	if not (Unixext.file_exists Xapi_globs.initial_host_free_memory_file) then begin
 		try
 			let free_memory = calculate_boot_time_host_free_memory () in
+                        Unixext.mkdir_safe (Filename.dirname Xapi_globs.initial_host_free_memory_file) 0o700;
 			Unixext.write_string_to_file
 				Xapi_globs.initial_host_free_memory_file
 				(Int64.to_string free_memory)
--- a/ocaml/xapi/xapi_globs.ml
+++ b/ocaml/xapi/xapi_globs.ml
@@ -105,7 +105,7 @@
 let simulator_config_file = ref "/etc/XenServer-simulator.conf"
 let pool_config_file = "/etc/xensource/pool.conf"
 let cpu_info_file = "/etc/xensource/boot_time_cpus"
-let initial_host_free_memory_file = "/etc/xensource/boot_time_memory"
+let initial_host_free_memory_file = "/var/run/xapi/boot_time_memory"
 let using_rrds = ref false
 
 let ready_file = ref ""
