Too Much RAM -> RAMdisk?

tinfoil-hat

Active Member
Joined
Oct 24, 2021
Messages
408
Reaction score
209
Credits
2,840
Hi, I have 64GB of RAM and actually need only 32GB. What and how can I run software in a RAMdisk? Which program would you use? How would you accomplish this? I am ln LMDE6, if that helps. Maybe I can run Brave in RAM? If yes, how?
 


Frankly, I don't understand why you would want to do such a thing. If you didn't WANT that much RAM, then why did you install it?

The more RAM you have available, the more you can multi-task anyway, so......I really don't see the issue.

(scratches head...)


Mike.
confused-small.gif
 
Frankly, I don't understand why you would want to do such a thing. If you didn't WANT that much RAM, then why did you install it?

The more RAM you have available, the more you can multi-task anyway, so......I really don't see the issue.

(scratches head...)


Mike.
confused-small.gif
I wanted a futureproof PC. also I use a lot VMs and Docker Containers and Local Language Models / Stable Diffusion. But when I was powering all my VMs, i noticed that I don't need so much ram. Since unused RAM is wasted RAM, I tought about tinkering with RAMdisk. I kinda like the Idea, to run my Browser completly in RAM, since I use it daily for several hours
 
...unused RAM is wasted RAM, I tought about tinkering with RAMdisk. I kinda like the Idea...
It makes sense to me who depended on a RAMDisk just to get network drivers loaded: mechanical disk access was quite too slow in PC-XT/DOS days... And now that flash memory is around as replacement we may want to question its use in terms of long-term reliability, while the RAMDisk boot options of a few Linux spins do offer a viable alternative already it seems.

:cool:
 
Hi, I have 64GB of RAM and actually need only 32GB. What and how can I run software in a RAMdisk? Which program would you use? How would you accomplish this? I am ln LMDE6, if that helps. Maybe I can run Brave in RAM? If yes, how?
I don't know why would you even say such a thing. If you believe you have too much ram, sell half of it. If you think 64GB is too much, why did you go about having it in the first place?
 
Back in the day...I had 512MB of Ram and could install only a total of 3GB as it was 32bit.

My Tower now has 16GB of Ram but the most I've used at one time was 7GB...it's better to have more than less. My Motherboard can run heaps more Ram but for what I do...16GB is enough.
1721369495370.gif


As for Ramdisk...do you know there are pros and cons and the cons outweigh the pros from what I've read...enjoy what you have.

1721370524053.gif
 
The more memory you have, the more the kernel can cache data in memory. So it pretty much is like a ram drive, but not really. And it doesn't matter too much if you have a fast drive.

Yes, you can put any program you want. But, you should really try to put bundled programs on it, like AppImages, snaps, flatpaks, giant binaries, etc., because the more bundled they are, the more data they will use will be along with them on the ram drive. Whereas if you install normal program on it the normal way, it might have many files to access which is scattered all over, on your main drive as well, which will create a bottleneck. But many bundled packages like snaps are compressed and have to be mounted, and so they are slow in their own way.

To actually a create RAM drive, I prefer the brd kernel module way.
sudo modprobe brd rd_nr=1 rd_size=$((1024*1024))
"rd_nr" is the argument to specify how many ram drives we want. You can make multiple ram drives this way. "rd_size" is the size of the ram drive(s). The command above allocates a ram drive of 1 GiB (the argument is taken in KB). You can multiply the expression to create a higher size ram drive. Make sure you hands don't slip, or you will crash the system if you allocate memory than you have!

After creating the RAM drive, you will have /dev/ram<num>, for example /dev/ram0. You can access your RAM drive here.

After creating the RAM drive, you might notice your memory usage hasn't gone up. That is because the space for the RAM drive isn't pre-allocated. I like to pre-allocate the space, but you can skip this if you want the size of the RAM drive to grow as it fills. You can use dd for that.
sudo dd if=/dev/zero of=/dev/ram0 bs=1GiB status=progress
"if" stands for input file. /dev/zero gives an infinite amount of zeroes. "of" stands for output file. Replace /dev/ram0 for whatever your RAM drive is called. "bs" stands for bullshit block size. Use a smaller block size if your ram drive is smaller than 1 GiB. "status=progress" updates the progress in real time.

To actually use the RAM drive, you have to format it.
sudo mkfs.ext4 /dev/ram0
This formats /dev/ram0 with ext4. Replace /dev/ram0 with your RAM drive, and you can also use a different format than ext4.

After formatting it, you can use it by mounting your RAM drive.
sudo mount /dev/ram0 /mnt/
You can mount it anywhere you want. Now you can put any data you want on our RAM drive.
 
Last edited:
Actually using RamDisks are (were) common in some situations.

  1. Decrypting files without touching a magnetic drive which the data can remain even after deleting the file
  2. Especially before flash SSD flash drives, spindles are relatively slow. You can create a ramdisk and drop files on it for extremely fast access. We used to do this with sqlite databases and used it as a caching service.
  3. In docker containers for temporarily high speed access to non-persistent data.

What we used to do was create a directory on your filesystem, then mount a tmpfs filesystem to it.

Something like:
Code:
# Create the directory to mount it to
sudo mkdir -p /some/location/ramdisk
# Mount a tmpfs to that location
sudo mount -t tmpfs -o size=XXXXXM tmpfs /some/location/ramdisk

Don't shoot me if that isn't exactly right, but for the mount command here are the parms.

  • -o # You are about to specify an options list (like size=4096M or 4GB)
  • -t tmpfs # You are telling it to mount a filesystem of type tmpfs. (temporary filesystem)
  • size=XXXXM # The size of the disk you are making. The M at the end means megabytes. The Xs are numeric values representing the size
  • tmpfs # The second one is the device is a tmpfs (temp filsystem)
  • /some/location/ramdisk # The path in your normal filesystem where the tmpfs is mounted / accessible

My current primary desktop has 32GB. My home lab as 128GB, but it runs multiple virtual machines and a Kubernetes cluster.

Good luck
Dave
 
@tinfoil-hat
You don't have too much RAM, but too few software that requires a lot of ram.
I have games which require 64GB RAM, and I know of software that requires 64GB RAM too.

As for VM's, your RAM is useless because how many VM's you can run is limited not only by RAM but also by count of CPU cores.
 
Which games, I haven't come across one that had that as the recommended requirement?
Games which require that much RAM are strategy games which provide options to use extra huge world maps.
The bigger the map and the more AI's you add the more RAM and CPU cores it demands.

A few examples with maxed out world map for which I'm sure it takes 64GB RAM are:
1. Galactic Civilizations 3 & 4
2. Distant Worlds 2
3. Rise of Industry

I currently don't have those 3 installed but if you don't believe me I have them on my HDD and I'll install them now and take a screenshot and share it here.
Because all 3 games show how much resources they will take if you set the biggest map with maxed out AI's.
 
1. Galactic Civilizations 3 & 4
Recommend amount of ram on Steam.
  • 3: 6G
  • 4: 16G
2. Distant Worlds 2
Recommend amount of ram on Steam.
- 16G
3. Rise of Industry
Recommended amount of ram on Steam is.
- 8G

If it's actually that bad, I would expect the ram recommendation to be way higher on the Steam game page.
I currently don't have those 3 installed but if you don't believe me I have them on my HDD and I'll install them now and take a screenshot and share it here.
Because all 3 games show how much resources they will take if you set the biggest map with maxed out AI's.
That would be interesting to actually see what that looks like.
 
@f33dm3bits
Steam recommended does not account for gigantic maps, I guess because they don't want to chase people away from buying.

Actually maybe I overstated that, see here:

This is minimum for early game, but as the game progresses toward the end it requires progressively more RAM.
Rise of Industry is know to require insane amounts.

I'll go install those games and share screenshots to be sure.
 
@f33dm3bits
OK, here is how much GalCiv 3 takes at maximum map size, 32GB RAM:
This is with minimum count of players though because didn't install DLC's and also at later stages it would require more CPU\RAM

galciv3.png


Here is what it takes for Distant Worlds 2 for the biggest map, 48GB RAM:

DW2.png


In any case 48GB RAM recommended requirement means you need 64GB RAM installed and minimum 48GB RAM, as the screenshot description above shows the game requires more in later stages and that this is "recommended" but it depends on how much AI's you play against as well.

12 CPU cores is also not low requirement.
Steam "recommended" requirements is in any case false statement and only accounts for default map sizes.

I also don't know how much much VRAM it would take at maxed video settings but that's another thing.
 
Linux does automaticly use your ram to cache your files. So in normal cases you have nothing to do.
is this the reason, my htop displays the RAM as "full" (in yellow)?
Bildschirmfoto vom 2024-07-23 15-25-58.png
 
is this the reason, my htop displays the RAM as "full" (in yellow)?View attachment 21303
Yellow bar is "cached" RAM, as there is need for more RAM by any program the cached RAM (yellow) gets swapped to disk to release RAM for actual needs.

This means your RAM is used at the maximum needed and as needed, caching as much into RAM as possible and only caching to disk if there is demand.
 

Staff online


Latest posts

Top