diff --git a/defs.h b/defs.h
index d528246..56f6890 100644
--- a/defs.h
+++ b/defs.h
@@ -5529,6 +5529,7 @@ void kdump_backup_region_init(void);
 int is_ramdump(char *pattern);
 char *ramdump_to_elf(void);
 void ramdump_elf_output_file(char *opt);
+void ramdump_cleanup(void);
 
 /*
  *  diskdump.c
diff --git a/help.c b/help.c
index 00843aa..a35ba9c 100644
--- a/help.c
+++ b/help.c
@@ -47,9 +47,9 @@ char *program_usage_info[] = {
     "",
     "USAGE:",
     "",
-    "  crash [OPTION]... NAMELIST MEMORY-IMAGE  (dumpfile form)",
-    "  crash [OPTION]... NAMELIST MEMORY-IMAGE@ADDRESS...  (dumpfile form)",
-    "  crash [OPTION]... [NAMELIST]             (live system form)",
+    "  crash [OPTION]... NAMELIST MEMORY-IMAGE  		(dumpfile form)",
+    "  crash [OPTION]... NAMELIST MEMORY-IMAGE@ADDRESS...	(dumpfile form)",
+    "  crash [OPTION]... [NAMELIST]             		(live system form)",
     "",
     "OPTIONS:",
     "",
@@ -71,9 +71,10 @@ char *program_usage_info[] = {
     "    CONFIG_STRICT_DEVMEM, then /proc/kcore will be used.  It is permissible",
     "    to explicitly enter /dev/crash, /dev/mem or /proc/kcore.",
     "    @ADDRESS is used along with MEMORY-IMAGE when the dumpfile is a raw dump",
-    "    which needs a conversion to kernel core dump format. Multiple",
-    "    MEMORY-IMAGE@ADDRESS ordered pairs can be used, each representing a",
-    "    memory node. ADDRESS is the physical start address of the node",
+    "    which needs a conversion to kernel core dump format. If -o option is not",
+    "    used, the kdump ELF file is created in /var/tmp/ and is unlinked on crash",
+    "    exit. Multiple MEMORY-IMAGE@ADDRESS ordered pairs can be used, each",
+    "    representing a memory node. ADDRESS is the physical start address of the node",
     "",
     "  mapfile",
     "    If the NAMELIST file is not the same kernel that is running",
@@ -145,8 +146,9 @@ char *program_usage_info[] = {
     "    very rare circumstances:",
     "",
     "  -o file",
-    "  Can be used when the MEMORY-IMAGE@ADDRESS format is used, to specify",
-    "  the path and name of the kdump ELF generated.",
+    "  Can be used with the MEMORY-IMAGE@ADDRESS format, to specify",
+    "  the path and name of the kdump ELF generated. The file thus generated",
+    "  will not be unlinked on crash exit, and can used as kdump input to crash.",
     "",
     "    X86_64:",
     "      phys_base=<physical-address>",
diff --git a/main.c b/main.c
index 0bd6575..e948529 100644
--- a/main.c
+++ b/main.c
@@ -1723,6 +1723,7 @@ clean_exit(int status)
 	if (pc->cleanup && file_exists(pc->cleanup, NULL))
 		unlink(pc->cleanup);
 
+	ramdump_cleanup();
 	exit(status);
 }
 
diff --git a/ramdump.c b/ramdump.c
index a09af7b..f20e356 100644
--- a/ramdump.c
+++ b/ramdump.c
@@ -20,8 +20,6 @@
 #include "defs.h"
 #include <libelf.h>
 
-#define ELF_DEFAULT_FILE "ramdump_elf"
-
 struct ramdump_def {
 	char *path;
 	ulong start_paddr;
@@ -31,6 +29,7 @@ static struct ramdump_def *ramdump;
 static int nodes;
 static char *user_elf;
 static char *pattern;
+static char elf_default[] = "/var/tmp/ramdump_elfXXXXXX";
 
 static void alloc_elf_header(char *e, ushort e_machine)
 {
@@ -149,29 +148,36 @@ static char *write_elf(ushort e_machine, void *load, char *e_head,
 #define CPY_BUF_SZ 4096
 	int fd1, fd2, i, err = 1;
 	char *buf;
-	char *out_elf = ELF_DEFAULT_FILE;
+	char *out_elf;
 	size_t rd, len, offset;
 	struct ramdump_def *r = ramdump;
 
 	buf = (char *)GETBUF(CPY_BUF_SZ);
 
-	if (user_elf)
-		out_elf = user_elf;
-
-	error(NOTE, "Creating kdump ELF %s\n", out_elf);
-
 	offset = data_offset;
 
-	fd2 = open(out_elf, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR);
-	if (!fd2) {
-		error(INFO, "%s open error\n", out_elf);
-		goto end1;
+	if (user_elf) {
+		fd2 = open(user_elf, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR);
+		if (fd2 < 0) {
+			error(INFO, "%s open error, %s\n", user_elf, strerror(errno));
+			goto end1;
+		}
+		out_elf = user_elf;
+	} else {
+		fd2 = mkstemp(elf_default);
+		if (fd2 < 0) {
+			error(INFO, "%s open error, %s\n", elf_default, strerror(errno));
+			goto end1;
+		}
+		out_elf = elf_default;
 	}
 
+	error(NOTE, "Creating kdump ELF %s\n", out_elf);
+
 	while (offset > 0) {
 		len = write(fd2, e_head + (data_offset - offset), offset);
 		if (len < 0) {
-			error(INFO, "ramdump write error\n");
+			error(INFO, "ramdump write error, %s\n", strerror(errno));
 			goto end;
 		}
 		offset -= len;
@@ -184,15 +190,15 @@ static char *write_elf(ushort e_machine, void *load, char *e_head,
 			offset = ((Elf64_Phdr *)load)[i].p_offset;
 
 		fd1 = open(r[i].path, O_RDONLY, S_IRUSR);
-		if (!fd1) {
-			error(INFO, "%s open error\n", r[i].path);
+		if (fd1 < 0) {
+			error(INFO, "%s open error, %s\n", r[i].path, strerror(errno));
 			goto end;
 		}
 
 		lseek(fd2, (off_t)offset, SEEK_SET);
 		while ((rd = read(fd1, buf, CPY_BUF_SZ)) > 0) {
 			if (write(fd2, buf, rd) != rd) {
-				error(INFO, "%s write error\n", r[i].path);
+				error(INFO, "%s write error, %s\n", r[i].path, strerror(errno));
 				close(fd1);
 				goto end;
 			}
@@ -358,3 +364,9 @@ void ramdump_elf_output_file(char *opt)
 {
 	user_elf = opt;
 }
+
+void ramdump_cleanup(void)
+{
+	if (!user_elf)
+		unlink(elf_default);
+}
