In embedded Linux, memory is precious. In my case, I have an executable in a tmpfs ram-disk. In fact, the ram-disk contains only one file, the executable.
I want to run the executable for once only. That executable runs in a very long time. When it is running, I want to unmount the ram-disk, to release some memory. Thus I deleted the executable, and then umount the ram-disk. It just showed a device busy error message: the umount failed.
How can I achieve that? I am not talking about Lazy umount. I want a real unmount, to release the memory! It should be possible, since the running process already has its image loaded in RAM. It should not rely on the ram-disk file system.
If it is not possible for general Linux kernel for now, I welcome answers pointing me where I can hack the kernel to enable this feature.
If possible, answers in programmatic way are preferred. Though answers in script way are also welcome (I can convert scripts to some executable anyway, by looking at the shell script source code).
My kernel version is 3.10.14
--Update-- Another thought: My purpose is to release some memory, since my application is memory-hogging. Also the binary size is large, compared to the total RAM. My original thought is that, the ramdisk have a copy of the file, and the running image is another copy. But maybe Linux keep just one copy than two? Anyone knows how elf executables been kept in both file system and the running image? Does Linux just keep one copy, or perhaps some meta data + 1 copy, not really keep 2 copies? If that's true, I don't need to do the unmount.