RAM Disk contents advice: what to put inside / when to save it

Started by jose hidalgo

Hello everybody, I'd like to have your thoughts and advices on my planned system, please. :)

I'm considering creating two RAM Disks on my Windows computer (currently running W7, will be running W10 x64 as soon as RAM Disk is updated ;) ).
I'm a power-user but I'm not a gamer. My daily use is Internet (Firefox, heavy user, lots of tabs, lots of RAM) and Email (Thunderbird). My occasional use is some Word/Excel/Photo retouching/etc., but nothing too important.

I would have 12 GB RAM, and use 8 GB for general usage and 4 GB for RAM Disks :

- RAM Disk #1 (R:) would be dedicated to non-critical data : pagefile.sys, and various caches (Firefox, Thunderbird)
- R: size would be of 2 GB
- pagefile.sys would be about 1.5 GB, the rest being taken by both caches
- R: contents would be saved to my slow storage disk (HDD)
- R: contents would not be saved often (maybe once a day or so ?)
- If R: contents were lost/corrupted, it wouldn't really matter

- RAM Disk #2 (S:) would dedicated to critical data : Firefox folder (100-300 MB) and Thunderbird folder (1,2 GB)
- S: size would be of 2 GB
- S: contents would be saved to my fast system disk (SSD)
- S: contents would be saved often (every few mins)
- If R: contents were lost/corrupted, it would be catastrophic, so I'm considering an additional automatic daily backup of S:'s image using appropriate backup software

Here are my questions :

1. What do you think of this strategy ? Can it be improved in any way ? How would you do it ?
2. Are there other files that could effectively be put in a RAM Disk in order to speed up my system / avoid unnecessary writes to HDD / SSD ?
3. When the contents of a RAM Disk are saved to HDD or SSD, are they saved in incremental mode or in dump mode ? For RAM Disk #2, I'd hate to have 2 GB of data written to my SSD every few mins !


Many thanks in advance for your help. :)
SoftPerfect Support forum - Andrew avatar image

Re: what to put inside / when to save it   03 August 2015, 12:45

It looks good. But here's a few things to consider:
  • Using a RAM Disk for the swap file. It may not be such a good idea and this article explains why.
  • Saving the non-critical data from R: perhaps it shouldn't be saved at all? The caches are re-created automatically if they are gone after a reboot. You would save time on reading/writing the image file.
  • Windows %TEMP% folder may be put on a RAM disk as well. A few installation programs don't handle this correctly (and may also fail if they run out of TEMP space) but the majority works okay.
  • RAM Disk image writes are incremental, but a pitfall here may be that the disk is locked when the writing is done. Some software may have troubles with this, in which case you could probably try file-level sync utilities like rsync or Unison.
Hope this helps :-)

Re: RAM Disk contents advice: what to put inside / when to save it   03 August 2015, 13:27

Thanks Andrew, your reply is most interesting. smile

About the linked article, it's funny because I had read it before creating this topic (yes, the 30 pages, lol). I still think that when you have enough RAM there are no downsides in creating a RAM Disk for pagefile. A number of people in that long thread have found it useful, probably because of Windows flaws that make the pagefile be written even when the RAM is far from being full. And since I don't want to disable the pagefile completely for compatibility issues, I may as well put it in a RAM Disk.

About R:, yes, I was thinking about not saving it at all. Saving the pagefile would be useless, right ?

The caches on the other hand would be useful, since their purpose is to speed up navigation. So why not have 3 RAM Drives ?
- R: for the swap file, never saved
- S: only for the caches, saved once a day or so to HDD (BTW maybe an additional option like "save on exit" or "save on reboot" or whatever would be nice, don't you think ?)
- T: for the critical data, saved very often to SSD

%TEMP% folder : Sounds nice indeed. Would you rather put it in R:, S: or T: ? wink

About the drive being locked when the writing is done, have you heard of problems when it happens to be the system drive ? Another solution would be to just use the secondary drive (HDD). Problem solved I guess, no need for additional software like rsync or Unison.
SoftPerfect Support forum - Andrew avatar image

Re: RAM Disk contents advice: what to put inside / when to save it   03 August 2015, 16:14

Yes, saving the page file is useless. In fact in Windows there is even an option to clear the page file for security reasons (which is obviously not needed if it's on a RAM Disk).

For %TEMP% I personally use a volatile RAM disk where everything is gone after a reboot. Many programs don't delete their temporary files and this helps reduce the amount of junk files. On the other hand, some installers expect to find files in this folder for an installation involving a reboot, in other words, those installers assume %TEMP% is persistent.

Regarding the locking, I meant the actual RAM disk is locked when its contents is saved to an image file. Programs that write to the RAM disk may not be able complete an operation if it happens to be during saving the drive's contents to an image file. This is done to prevent storing an inconsistent file system.

Re: RAM Disk contents advice: what to put inside / when to save it   03 August 2015, 22:36

Great ! So what do you think of these two additional options to fix the %TEMP% problem ?
- "Save only on exit / reboot"
- "Don't save files older than..."
This would allow the %TEMP% folder to remain almost empty ("Don't save files older than..."wink, but it would also allow its contents to be saved on exit/reboot, for those programs who need a reboot to finish their install.

About the locking, that makes sense. I understood it the wrong way, sorry. But I guess programs that write to the RAM Disk when it's locked may be designed to retry several times before giving up, right ?

Otherwise, why not add a "temporary RAM cache" ? (if a program can't write to a RAM Disk because it's temporarily locked, have it write to "temporary RAM cache" instead, then write the "temporary RAM cache" into the RAM Disk as soon as it's not locked anymore).
SoftPerfect Support forum - Andrew avatar image

Re: RAM Disk contents advice: what to put inside / when to save it   05 August 2015, 17:25

The Save on Exit / Reboot option already exists when an image is attached - that's what Save Contents to Image does.

Storing or not storing older files is not really possible in the current design. The RAM disk engine operates with disk blocks, it has no idea about files or folders stored on it, pretty much like a HDD in RAM.

Whether the programs are designed or not to write to locked devices, I'd assume most are not designed this way. They would just fail when this happens. A separate buffer for write operations while a RAM disk is being saved could be a solution, but it's not trivial to implement.

Re: RAM Disk contents advice: what to put inside / when to save it   06 August 2015, 03:21

Quote

Andrew

The Save on Exit / Reboot option already exists when an image is attached - that's what Save Contents to Image does.

Oh, I get it now ! laugh So I guess I'll have this :
- R: for the swap file (contents never saved)
- S: for all the caches ("save contents to image" so they only get saved on exit/reboot to HDD), maybe also for %TEMP%, and then I'll clean %TEMP% from time to time with a batch script or something
- T: for the critical data (contents saved very often to SSD in an incremental way)

Quote

Andrew

A separate buffer for write operations while a RAM disk is being saved could be a solution, but it's not trivial to implement.

Well, I'm glad to maybe have given you such a challenge for future versions (if you find another core developer to pursue RAM Disk development of course wink ).
SoftPerfect Support forum - Andrew avatar image

Re: RAM Disk contents advice: what to put inside / when to save it   06 August 2015, 13:16

Just a final word of caution: do backup the image files regularly as we've seen reports where they ended up being damaged and it's unclear how it happened.

Re: RAM Disk contents advice: what to put inside / when to save it   12 August 2015, 04:12

Hi Jose,

I use a ram disk for %TEMP% and %TMP% files too but I use it selectively on a per program basis using variations of the following batch file script (for example):

set TEMP=W:\TEMP
set TMP=W:\TMP
start "" "C:\Program Files (x86)\Microsoft Office\OFFICE11\OUTLOOK.EXE"
exit

The above would launch Microsoft Office Outlook and have it write its temporary files into the ramdisk (whereas normally they get written into the default %TEMP%).

set TEMP=W:\TEMP
set TMP=W:\TMP
start "" "E:\PORTABLES\INTERNET\PeerBlock\peerblock.exe"
ping -n 31 127.0.0.1 >NUL
start "" "E:\PORTABLES\INTERNET\uTorrent\uTorrent.exe"
exit

The above would launch PeerBlock, then after a 30 second 'pause' to let PeerBlock update its block-lists, it would launch uTorrent and have both of them write any temp files they would normally write into the ramdisk.

set TEMP=W:\TEMP
set TMP=W:\TMP
start "" "C:\Program Files (x86)\INTERNET\Mozilla Firefox\firefox.exe"
exit

The above would launch Firefox and have it write any temp files into the ramdisk.

From this you should see that you can create batch files on a per program basis and just have a shortcut to the *.bat in your Start Menu that you use for launching whatever program you want to write temporary files into the ramdisk.

You should also be aware that using these batch files will not globally reset your %TEMP% and %TMP% files for all programs after any one of the batch files has been run. The change in path only gets applied to the program(s) that are launched from within the batch file. Also, though, you should know that for any program you've launched using a batch file like those above then if one of those programs calls (launches) another program (as a sub-process, so to speak) then that new process will also write its temp files into the ramdisk - really this is the only potential pitfall you need to be aware of if using batch files like these.

The real advantage of these batch files is that other processes that write temporary files and expect to find them after a reboot (e.g. Win Update and installers) can carry on writing to %TEMP% and %TMP% as normal so you don't risk messing up your system at some critical point in the future.

Hope this is of help. smile

Re: RAM Disk contents advice: what to put inside / when to save it   25 August 2015, 02:44

radish, I've just read your method, and I think it's AMAZING ! laugh

This is exactly what I was looking for, and I'll make sure to implement this in my fresh Windows 10 install (which has been delayed a bit, it shall take place around september 20th, just in time for Firefox 64 bit ! Yay ! laugh ).

Thank you so much, and feel free to share other tips if you have them ! These are really useful for everybody ! ok, yes, thumb up

Re: RAM Disk contents advice: what to put inside / when to save it   25 August 2015, 06:09

Thanks for the thanks, Jose - appreciated. Glad you find the information helpful though, alas, I have to admit I got it myself from elsewhere (mentioned below) but then how else do we learn. I have to say that I don't know if it will work on Windows 10 (I have Windows 7). Obviously you would need to test it out for yourself on Windows 10 (and report the results of your test back into this forum to help others).

Don't have any other tips except for this one on how to deal with the Firefox cache if you don't want to retain it between Firefox sessions and system restarts. I don't so I use this method myself. Remember that the cache keeps a record of the websites you visited and even if you do delete it from your HDD then it is possible for the information to be recovered by using an 'undelete' tool. You could, of course, erase the cache (instead of just deleting it) but it is a pain having to do that and wearing on the HDD/SSD.:

  1. In Firefox, on a new tab, type in the address bar "about:config" (without the quote marks) and then hit 'enter'.
  2. Click the warning page that shows up, saying you will be careful. (That should get you to a page showing Firefox's 'preferences'.)
  3. In the 'Search' bar (at the top of the page) type the following without the quotes "browser.cache". That will reduce the number of preferences displayed to just those that have 'browser.cache' as part of their titles.
  4. Look for a preference titled browser.cache.disk.parent_directory. It might not exist (it didn't on my system).
  5. If it doesn't exist then right-click on an empty space in the preferences listing and select New > String (from the menu). In the dialogue window that opens type (or paste) the preference name browser.cache.disk.parent_directory. And then click 'okay'.
  6. A new dialogue will appear asking for a value for the preference you've just created. The value you enter will be the path to which you want Firefox to write the cache data to in the future. On my system I set the path to "W:\\TMP\\Firefox\\" (without the quotes) - enter a path that you want to be valid for your own system. (Note it is very important that for each directory in the path you enter double back-slashes "\\", not single.) If the preference already existed in your "about:config" then you would just need to double-click on it to enter in the path of your choice.
  7. Having done all that close the tab you were working in then restart Firefox. You should now find that Firefox is writing the "cache2" data and its subfolders into your ramdisk.
  8. If you are happy with the result then on your system drive you can drill to the path where your cache2 data used to be stored for your user account. On my system this is "C:\Users\Radish\AppData\Local\Mozilla\Firefox\Profiles\odj8wnq7.default\cache2". That 'cache2' folder will contain whatever cache2 data there was before you changed the cache over to the ramdisk path you set. If you don't want all that old cache data on the system drive then it is safe to delete/erase that 'cache2' folder (and its subfolders). It won't be recreated because the data is now being written to the ramdisk.
  9. If ever you want to undo having set the preference to your ramdisk path then just go into "about:config" again. Find the value you created, right-click on it and select "Reset" from the menu. The path data will disappear but the preference itself will remain. Now just close the "about:config" tab and restart Firefox. On restart you should now see that the preference no longer exists (and Firefox will default back to writing the cache2 data in your %USERPROFILE% location as indicated above).

I would add that elsewhere on the internet I have seen instructions that allow a different way of forcing the cache into memory (not into a ramdisk). You can see the instructions here: [Tutorial] How To Move Your Mozilla Firefox Cache Into Memory However, having experimented with that way of doing it I have to say that some cache2 data was still being written into my %USERPROFILE% cache2 location, even though the article suggests that all of the cache will be written to memory - so that method isn't as foolproof as the method I detail above and I certainly wouldn't recommend it. But you could always try it out for yourself if you wanted to.

If you want to mess around with moving your Firefox User Profile into a ramdisk then I would recommend you study the following post elsewhere on the internet and you will get information on how to do that: [SOLVED] Force Folder "mozilla-temp-files" to a Ramdisk?. I haven't tried moving the Firefox Profile to ramdisk, and have no intention of doing so, but it's useful to know that such a thing can be done if you ever have a mind to.

That's all from me, Jose. Good deed done for today! Hope it helps. smile

Re: RAM Disk contents advice: what to put inside / when to save it   26 August 2015, 03:05

In step 8 of my instuctions on how to deal with the Firefox cache I wrote:

Quote

radish

It [cache2] won't be recreated [on the HDD] because the data is now being written to the ramdisk.


I made a mistake there. The "cache2" folder will be recreated. However, nothing will be written into it - the cache is now being written to the ramdisk. Just to clear up any misunderstanding.

Re: RAM Disk contents advice: what to put inside / when to save it   20 March 2016, 02:59

radish, I hope you're still listening. smile

My RAM Disk is now up and running, and so far everything is working perfectly, partly thanks to you! laugh
I'm using the .bat files like you suggested. Actually I am using .bat files (e.g. word.bat) AND shortcuts to them (e.g. "Word" shortcut with the right icon, since icons can be changed easily on shortcuts). I have added "explorer" to the beginning of each shortcut path, so each shortcut can be considered as an executable.
Example:
- I have a word.bat file located in C:\Bat with all the other .bat files
- I have a "Word" shortcut located elsewhere, with the right icon
- The path within the "Word" shortcut looks like this : "explorer C:\Bat\word.bat"
Everything works perfectly. smile

But I have a question that puzzles me!

Let's assume that I have created a word.bat file for Word 2007:
set TEMP=R:\TEMP
set TMP=R:\TMP
start "" "C:\Program Files (x86)\Microsoft Office\Office12\WINWORD.EXE"
exit

And also a nice "Word" shortcut located elsewhere.

Clicking on the "Word" shortcut will launch the .bat perfectly setting the right TEMP directories. But... what if I click on any Word document? That will launch Word without setting the TEMP directories accordingly! And the same could be said for ALL APPS of course !

So my final question is : how should I do?

Thanks again for your valuable help. smile

Re: RAM Disk contents advice: what to put inside / when to save it   20 March 2016, 03:31

Hello Jose,

Sorry but I don't know the answer to your question. I would think that if you launch an instance of Word via clicking on a doc then any temp files will be placed according to your bat file settings (provided you've launched Word via the batch in the first instance) - but in saying that I am totally, absolutely only guessing. Only way to be sure is to experiment with it yourself and see what happens.

If you do experiment it would be good if you posted up here with the results (positive or negative). It would help others in the future. smile

Should add that I've moved from Windows over to Linux Mint so it's not practical for me to try the experiment myself. I would though still be interested in the result.
Sorry to bump an old thread, but the "*.bat" fix is too tempting.

@ Radish: Let me get this straight. If I start a program in RamDisk, ANY subsequent files that it opens will also be in RamDisk?
Re-installing an old system with 16 GB slow HDD. I tend to use portable apps nowadays. If I point the portable apps launcher with a batch file ... will then ALL portable apps launch in RamDisk? This would be AWSOME!

As to the question on double clicking, I would think we could direct it to the batch file as well ...
Unfortunately, I'm not seeing it transfer to the RamDrive.
Portable Apps Launcher is launching/working in the RamDisk; however, the "connecting" apps are not using the Temp and TMP re-direct in the batch file that launched the launcher.
This was tested with Picard MuzicBrainz Portable.
  • From Launcher, nothing
  • App inside of RamDisk and starting from there, a Temp and TMP folder are populated with new files.
I was hoping on leaving the global temp variables alone. The issue I have is that the apps are updated and I would lose the batch file settings. I'm not to good at this stuff

Reply to this topic

Sometimes you can find a solution faster if you try the forum search, have a look at the knowledge base, or check the software user manual to see if your question has already been answered.

Our forum rules are simple:

  • Be polite.
  • Do not spam.
  • Write in English. If possible, check your spelling and grammar.

Author:

Email:

Subject

A brief and informative title for your message, approximately 4–8 words:

     

Spam prevention: please enter the following code in the input field below.

 **         **    **  **      **   ******    **     ** 
 **    **   ***   **  **  **  **  **    **    **   **  
 **    **   ****  **  **  **  **  **           ** **   
 **    **   ** ** **  **  **  **  **   ****     ***    
 *********  **  ****  **  **  **  **    **     ** **   
       **   **   ***  **  **  **  **    **    **   **  
       **   **    **   ***  ***    ******    **     ** 

Message: