[GUIDE] Using ImDisk to set up RAM disk(s) in Windows with no limit on disk size

Discussion in 'Operating Systems' started by k1net1cs, Dec 21, 2011.

  1. k1net1cs

    k1net1cs Ancient Guru

    Messages:
    3,783
    Likes Received:
    0
    GPU:
    Radeon HD 5650m (550/800)
    Ever since I have 8GB of RAM (yes, hi, I'm late to the party... =b), I've been looking for ways to actually use the extra resource properly.
    AFAIK, most people use Dataram RAMDisk (which I'll call 'DR' from this point onward), which is limited to 4GB a disk and doesn't support multiple RAM disks at once.

    And that is where ImDisk comes into play.
    Also, this guide is about a 'RAM disk', not DR a.k.a. 'RAMDisk' which is another software to create RAM disks; just to clarify things. =b

    Yes, I do realize that most people with 8GB or more RAM don't need a RAM disk more than 4GB nor even multiple RAM disks, and I'm not suggesting that you should, but this is just to show that it's possible, and how to do it.

    In short, it's because we can, not necessarily because it's better. ;)

    Before we start, I'd like to point out that I use Windows 7 Home Premium 64-bit.
    So, Vista 64-bit users may also follow the same steps.
    XP users...well, seriously, why bother having more than 4GB? :3eyes:


    Installation

    In case you haven't visited the ImDisk link above, go here.
    Download the installer, and then run it; pretty self-explanatory.
    ImDisk, like DR, runs in background by installing itself as a device driver.


    Setting up a RAM disk

    You can either use the command prompt (cmd) and then run imdisk, or from the ImDisk panel in Control Panel; you might have to set the Control Panel view from Category to icons to find it.
    But this guide is all about using the command-line version a.k.a. imdisk.

    Remember, you have to run cmd with an administrative privilege.
    This also goes for when you're deleting a RAM disk.
    The easiest way is to type cmd at the Start Menu search box and then press Ctrl+Shift+Enter.
    And no, Ctrl+Shift+Enter doesn't work on Win+R a.k.a. Run box.

    Now that you've installed ImDisk, open up cmd as described above.
    To make a 512MB disk on drive X: using NTFS, type this :

    imdisk -a -s 512M -m X: -p "/fs:ntfs /q /y"

    • -a initializes the virtual disk.
    • -s 512M is the size, 512 MegaBytes.
      The full choices are b, k, m, g, t, K, M, G, or T.
      These denote a number of 512-byte blocks, thousand bytes, million bytes, billion bytes, trillion bytes, KB, MB, GB, and TB, respectively.
    • -m X: sets up the mount point a.k.a. the drive letter, X:.
    • -p "fs:ntfs /q /y" formats the drive.
      -p's parameters are actually for Windows' format program.
      So, if you want the RAM disk in a different filesystem, just change ntfs to fat (FAT16) or fat32 (FAT32).
    After you run that command, you should be able to see it with Windows Explorer, formatted and ready to be used.
    Any additional disks can be made by simply changing -m's parameter to another letter, changing the size & filesystem parameters if you want to, and run it again.


    Deleting a RAM disk

    Run imdisk -d -m X:, or imdisk -D -m X: to force a removal.
    X: is of course the drive letter of the RAM disk you want to detach/delete/remove.


    Setting up RAM disk(s) automatically when Windows starts

    The surefire way to do this without using Group Policy Editor (gpedit.msc, which only exists in Professional version and up) is to define a task in Task Scheduler (taskschd.msc).
    As usual, Start Menu's search box should make it easy to find and start Task Scheduler.

    But before creating a schedule, it's advisable to create a command script first a.k.a. .cmd file, especially if we're going to start multiple RAM disks.

    For example, we want to create 3 RAM disks with drive letters X:, Y:, and Z:.
    X: is 1GB in NTFS, Y: is 256MB in FAT16, and Z: is 768MB in FAT32.
    Therefore, we need to create a simple text file (Notepad will do fine) and put this :

    Code:
    imdisk -a -s 1G -m X: -p "/fs:ntfs /q /y"
    imdisk -a -s 256M -m Y: -p "/fs:fat /q /y"
    imdisk -a -s 768M -m Z: -p "/fs:fat32 /q /y"
    ...then save it as imdisk-start.cmd, or any other name as long as it ends with .cmd.
    Personally, I'd save the file inside a directory I created under C: or system drive.
    i.e C:\ImDisk\ directory.

    When that is done, let's go back to Task Scheduler.
    Using the left-most pane, browse to Task Scheduler Library -> Microsoft -> Windows.

    [​IMG]

    Like so.

    Then right-click on the upper middle pane (which is usually empty) and Create New Task....
    I'll explain what to do in each tab.

    • General

      Name
      The name of your schedule; I named mine 'ImDisk Start'.

      Description
      Leaving it blank is fine.

      Security options
      Click Change User or Group.
      Enter the object name SYSTEM, all capitals, then click OK.
      The user account should now read NT AUTHORITY/SYSTEM.
      Turn on Run with highest privileges.​
      Turn on Hidden, then choose the OS you're currently using in Configure for:.
    • Triggers

      Click New....
      On Begin the task:, choose At startup.
      Click OK.​
    • Actions

      Click New....
      Click Browse....
      Look for the .cmd file you created earlier to start the RAM disks; i.e imdisk-start.cmd.
      Double-click the file, then click OK.​
    • Conditions

      Turn off Start the task only if the computer is on AC power.
    • Settings

      Turn on Run task as soon as possible after a scheduled start is missed.
    Click OK to create the schedule.

    That's it!


    Setting up a page file in a RAM disk when Windows starts

    For this, we need an extra tool called swapadd.
    We need to go back to the website where we downloaded ImDisk, but to its command-line utilities section.
    Look for swapadd.zip, and download that.
    Extract the content to C:\Windows\System32\ to make things easier.

    Remember that .cmd file we created earlier?
    We're going to edit it a bit.
    Say we want to have 1GB of RAM disk dedicated for a page file formatted in NTFS assigned to W:.
    Then we need to add these two lines.

    Code:
    imdisk -a -s 1G -m W: -p "/fs:ntfs /q /y"
    swapadd W:\pagefile.sys 990M 990M
    First line, by now, is self-explanatory.
    The second line is basically adding pagefile.sys to the RAM disk in W:, sized 990MB.
    The first 990M is the minimum size, or lower limit.
    The second is the maximum size for the page file.
    When you set both to the same number, it sets a page file with a static size.
    Similar to imdisk, you can set the size to KB, MB, or GB, by using K, M, or G after the number, respectively.


    Setting a persistent RAM disk across restarts and shutdowns

    Now, what if we want to set a RAM disk as a browser cache, but we don't want it getting 'reset' every time we start Windows?
    Or maybe even our account's temporary folder (which is different from Windows' temporary folder)?

    As before, we need to visit here again.
    Look for rawcopy.zip, and extract its content to C:\Windows\System32\ directory.

    Now, for this, we need to create both a new .cmd file and a new schedule.
    This is because we need to run the command(s) when Windows is shutting down in order to restart or shutdown, which requires a separate schedule along with a different trigger.
    Then, edit the imdisk-start.cmd to reflect these changes.

    First, the new .cmd file.
    Say we're planning to preserve Y: and Z: contents.
    We need to put this in the .cmd file :

    Code:
    rawcopy -mld \\.\Y: "C:\RAM disks\Y.img"
    rawcopy -mld \\.\Z: "C:\RAM disks\Z.img"
    ...and then save it as, for example, imdisk-save.cmd.
    You can save it in the same directory as where you've saved imdisk-start.cmd.
    As for the parameters, you only need to understand the last two.
    \\.\Z: is the drive letter of the RAM disk which contents we want to preserve.
    "C:\RAM disks\Z.img" means that rawcopy will write the image file (named Z.img; it's up to you, though) in a directory called C:\RAM disks\.

    Next, setting up the schedule.
    Aside from the schedule name (I named mine 'ImDisk Save'), the steps and settings are similar to when we created the schedule for starting the RAM disks.
    Except that at :

    • Triggers

      Click New....
      On Begin the task:, choose On an event.

      Settings
      On Log:, choose System.
      On Source:, choose USER32.
      On Event ID:, type 1074.

      Click OK.​
    • Actions

      Click New....
      Click Browse....
      Look for the .cmd file you created earlier to save the RAM disks; i.e imdisk-save.cmd.
      Double-click the file, then click OK.​
    • Settings

      Turn off If the running task does not end when requested, force it to stop.
      Don't forget turn on Run task as soon as possible after a scheduled start is missed.
    Click OK to create the new schedule, and that's it.

    If you're wondering why the trigger is like that, open up Event Viewer (eventvwr.msc).
    Navigate to Windows Logs -> System, then look for events with the source USER32.
    And the reason we need to turn off 'If the running task does not end when requested, force it to stop' option is to prevent Windows from prematurely ending imdisk-save.cmd, which could make rawcopy stopping halfway or not starting at all.

    Lastly, we need to edit the imdisk-start.cmd file again.
    Replace these lines :

    Code:
    imdisk -a -s 256M -m Y: -p "/fs:fat /q /y"
    imdisk -a -s 768M -m Z: -p "/fs:fat32 /q /y"
    ...with these :

    Code:
    imdisk -a -t vm -f "C:\RAM disks\Y.img" -m Y:
    imdisk -a -t vm -f "C:\RAM disks\Z.img" -m Z:
    The new codes are basically telling imdisk to make RAM disks using the image files that were saved when Windows was shutting down.
    Of course, the directory and image file names should be according to what you've set in imdisk-save.cmd before.


    Closing notes

    This is about as 'advanced' as I can explain, since my own usage is basically what I've written above.
    If you have any questions about things I've not covered, it's better to consult with ImDisk's author in this forum.
    Most of the explanations I have here are also from there, including ImDisk settings (parameters and whatnots).
    The only thing I thought up myself was the task scheduling, along with the triggers.

    It also goes without saying that the storage device you're saving the RAM disk image(s) into shouldn't be external storage devices like thumb drives or external HDDs.
    Aside from a noticeable slow down when saving the image(s) due to USB's transfer speed (which is still slower than SATA even with USB 3.0), we have no way to ensure that at Windows start up the external storage device is ready when our schedule runs imdisk-start.cmd to load the images.
    This is why it's better to save the image(s) on an internal HDD/SSD.

    And in case you haven't noticed, creating those two little .cmd files saves you from having to create a schedule in Task Scheduler for each and every command you're trying to run at Windows startup or shutdown.

    With that said, have fun trying ImDisk.
    Just don't hold me responsible when your PC implodes or anything. :p
    And if you could, donate to ImDisk's author. ;)

    Thanks for reading this colorful wall of text. :)
    And so much for using the 'DR' abbreviation.
     
    Last edited: Dec 22, 2011
  2. gammelhat

    gammelhat Active Member

    Messages:
    96
    Likes Received:
    0
    Is your logic not a bit faulty? You take away usable memory from Windows to store a page file in...
     
  3. Black_ice_Spain

    Black_ice_Spain Guest

    Messages:
    4,584
    Likes Received:
    17
    GPU:
    5700XT
    its windows logic what's faulty, it uses pagefile even when RAM is not full...

    altho idk if this actually degrades performance, never experienced any speedup when disabling PF
     
  4. k1net1cs

    k1net1cs Ancient Guru

    Messages:
    3,783
    Likes Received:
    0
    GPU:
    Radeon HD 5650m (550/800)
    Which part of "it's because we can, not necessarily because it's better" did you not understand?
    And when I have 8GB of RAM on my laptop and 16GB of RAM on my desktop, worrying about memory usage is a bit moot.


    I also didn't feel any difference with page file on or off with 16GB of RAM.
    But since I have the spare RAM space, then I guess why not.

    Putting the page file on RAM is purely out of curiosity, not practicality. =b
     
    Last edited: Dec 22, 2011

  5. Lethal Abz

    Lethal Abz Maha Guru

    Messages:
    1,181
    Likes Received:
    0
    GPU:
    Geforce GTX 470
    Nice article easy to follow and very technical!. I use Ramdisk too and been testing it for a while and I havent noticed a big difference with PF on and off,
     
  6. gammelhat

    gammelhat Active Member

    Messages:
    96
    Likes Received:
    0
    Disabling it would benefit you more.
     
  7. Zer0K3wL

    Zer0K3wL Banned

    Messages:
    3,073
    Likes Received:
    0
    GPU:
    gtx 480 850/1700/2000 h2o
    should use it to store temp files saves the hasle off cleaning up every time :D
     
  8. CPC_RedDawn

    CPC_RedDawn Ancient Guru

    Messages:
    10,390
    Likes Received:
    3,064
    GPU:
    PNY RTX4090
    So technically, please correct me if I am wrong here, RAMdisk simply lets you disable PF in Windows and create your own PF using HDD space... This seems a little silly as this is what PF already does...

    I am so confused! :S lol
     
  9. k1net1cs

    k1net1cs Ancient Guru

    Messages:
    3,783
    Likes Received:
    0
    GPU:
    Radeon HD 5650m (550/800)
    And enabling it on a RAM disk doesn't make any difference nor makes it slower, so I can't see why I should disable it.
    It's not like DDR3 RAM is slow or anything.


    The problem with 'resetting' temp files is that some apps do store regularly used or log files there that they use from time to time.
    Some installer that asks for a restart also usually relies on a copy of the installer inside the user's temp directory to continue the installation post-restart, so if the directory is 'emptied' on a restart, 'hilarity' ensues.
    This is why I need the RAM disk(s) to be persistent through restarts and shutdowns.


    No, RAM disk is not the one disabling the page file.
    Any Windows user can disable it via System Properties in Control Panel.

    A RAM disk is basically a formatted amount of space in your RAM that Windows sees as a disk drive.
    So, 1GB of RAM disk means it's using 1GB of your RAM and nothing of your HDD/SSD.

    So, this guide is about one of the many ways (read: the cheap-ass way, since most other RAM disk software are priced ridiculously) to create a page file without wasting any HDD/SSD space, because it uses a RAM disk. :)
     
  10. gammelhat

    gammelhat Active Member

    Messages:
    96
    Likes Received:
    0
    You lower the amount of memory Windows can use. When you get to the point where Windows needs the extra amount of memory, it will need to access it through your page file in memory (instead of accessing the memory directly). This is what is called a large overhead = slower.
     

  11. Pill Monster

    Pill Monster Banned

    Messages:
    25,211
    Likes Received:
    9
    GPU:
    7950 Vapor-X 1100/1500
    What's the difference between moving the PF to a Ram disk and disabling the PF?
     
  12. gammelhat

    gammelhat Active Member

    Messages:
    96
    Likes Received:
    0
    A lot of overhead. Data must to be moved around, before the memory can be used, and access must go through the ram disk.

    It should be clear that direct access to memory and no movement of data is faster.
     
  13. gammelhat

    gammelhat Active Member

    Messages:
    96
    Likes Received:
    0
    The primary reason why some use a ram disk for a page file is because they use 32bit Windows and have more than 4GB RAM. The memory above 4G can then be made of use for a page file.
     
  14. Pill Monster

    Pill Monster Banned

    Messages:
    25,211
    Likes Received:
    9
    GPU:
    7950 Vapor-X 1100/1500
    A ram disk is made of ram which means the PF is located in memory, so can you explain why data needs to be moved around before the PF can be accessed?

    When the PF is disabled, virtual memory is moved from the HDD into ram, so to me this seems no different than storing the PF on a Ram disk...
     
  15. gammelhat

    gammelhat Active Member

    Messages:
    96
    Likes Received:
    0
    For a memory management point of view there is no difference between a page file in memory and on the hard drive.

    When you are low on memory, data must be moved to the page file (data must be moved around in memory), before new data can be stored in the same place in memory.

    The point is: If you don't reserve memory for a ram disk/page file then you have that much more usable memory.

    The entire process of moving data to a page file is no longer in effect when you disable it.
     
    Last edited: Dec 22, 2011

  16. k1net1cs

    k1net1cs Ancient Guru

    Messages:
    3,783
    Likes Received:
    0
    GPU:
    Radeon HD 5650m (550/800)
    It's exactly what I'm trying to do.

    [​IMG]

    And that is with multiple RAM disks worth 3GB in total.

    'When' is the keyword here.
    One of the many ways I could ever run out of 16GB of RAM is to run multiple VMs or run Notmyfault, in which I don't.

    My Firefox usage tops at around ~2GB because of it being 'awesome', and whenever I play a game I usually close it down.
    Putting it on SSD and its caches on a RAM disk makes it a snap to restart it after a game.
    Even if I decided to run both at the same time (FF and a game), how much a game would use at max in average? 2GB? 4GB?

    0.1 m/s slower than speed of light is also slower, but would we notice it?
    Now, if you could provide concrete numbers for comparison purposes, that'd be great.
    Personally I'd like to see how much does this 'large' overhead affects anything.

    Depending on a user need(s), it's not the primary reason, just one of the many reasons.
    ImDisk can also be used for that purpose, though it may not be as robust a solution compared to paid software.
    And since I don't use it for that purpose, I didn't put it in my guide, in which I already noted in the 'Closing notes' section.

    And the point of my guide is to show how to use those useable memory.

    Look at it this way.
    You can talk about MPG all you want in a supercar thread, but how should that matter when what's more important is maximum speed?
    It'd be more relevant if you talk about MPG in a city car thread.

    And I hate car analogies. =/
     
  17. gammelhat

    gammelhat Active Member

    Messages:
    96
    Likes Received:
    0
    You missed the point. Why remove memory to use it for a page file?

    The purpose of the page file is to increase the commit limit. You lower the limit by reserving ram for a ram disk. You then increase it again by putting a page file on that ram disk - but now you have introduced a large overhead when that ram needs to be used.

    How much slower it is, is not relevant. The relevant part is that it is faster to use the memory directly.
     
  18. k1net1cs

    k1net1cs Ancient Guru

    Messages:
    3,783
    Likes Received:
    0
    GPU:
    Radeon HD 5650m (550/800)
    No, you missed the point of my guide.
    How many times should I reiterate it to you that, in my guide, performance is not the goal?
    That I only wanted to show what we could do with RAM disks provided we have the extra amount of memory available for use?
    Do I really have to explain it slower with a wall of text?

    Then show me, with numbers, where that large overhead affects a system's performance if you really want to make a point.

    If how much it being slower is not relevant, then why how much it being faster is relevant?
    They aren't exactly two mutually exclusive things.
    And how are you going to show the relevancy of how much faster it is to use the memory directly if you're not going to post some numbers?

    If you need me to run some benchmarks on my system to prove your point, then by all means.
    Just show me what tools I'd need and how I should run it.
    Since in this case you are in the know more than me, then I assume you're also better than me at knowing which and what parts to test, and how.

    Don't worry, I'll wait.
     
  19. gammelhat

    gammelhat Active Member

    Messages:
    96
    Likes Received:
    0
    I am not sure how to explain it to you. You accomplish nothing but an overhead. Why do something, if all you get is an overhead?

    I understand the need to experiment and that your guide is not about performance, but others reading this are obviously confused about the part with a page file on a ram disk (I think you are also).

    A ram disk can be good for many things, but a page file?
     
  20. Pill Monster

    Pill Monster Banned

    Messages:
    25,211
    Likes Received:
    9
    GPU:
    7950 Vapor-X 1100/1500
    That doesn't make sense...the amount of usable memory will be the same whether a PF is created in Ram or not...
    If a 2GB PF is allocated to a Ram disk it's still a portion of the total amount of memory available to the system.

    Example: 8GB of ram with 2GB allocated as a PF is still 8GB of usable memory, not 6GB.


    You misunderstood me, I'm saying the whole thing is moved to ram - I didn't mean data constantly moves between the HDD and RAM.

    TBH I think you're splitting hairs in relation to the overhead, we're talking nano-seconds not seconds....

    I don't see the point in a PF in ram myself, but I can appreciate why the OP brought it up...it's food for thought, nothing more...
     
    Last edited: Dec 22, 2011

Share This Page