I will come back and provide some context about why i need this later, for now, if you want your PC to take away some ram and make a RAM disk, you have two ways, I would go with the first
The easy way (tmpfs)
Start by creating a directory to mount the ram disk onto
sudo mkdir -p /hds/ram
Then just add a line like the following to the /etc/fstab file
tmpfs /hds/ram tmpfs defaults,size=80G 0 0
Or, the more elaborate
tmpfs /hds/ram tmpfs rw,noatime,nosuid,nodev,noexec,size=80G,mode=0755 0 0
Now mount it
sudo mount -a (To avoid having to restart)
If you have a dual CPU setup, I recommend you check out NUMA tuning before playing with this
The other way (ramfs)
You will not see real world gains in speed, they are super marginal, and you lose a lot of features like swapping ! Also, it eats up all the ram in advance, ram that could have been used for caching
If you must, it is the same as above, but the line in fstab is the following instead
ramfs /hds/ram ramfs rw,noatime,nodev,nosuid,noexec 0 0
Notes:
1- “df -h” will report an 80 GB disk, even though they are not missing from ram, it is an upper limit, not a pre-alocated space
2- noatime doesn’t matter much, on a ram disk, it is a neglegible load, I add it anyways because none of my applications can make use of ti
3- noswap : swapping a ram disk is probably the worst idea ever ! so you may want to consider
tmpfs /hds/ram tmpfs rw,noatime,nosuid,nodev,noexec,noswap,size=80G,mode=0755 0 0
4- NUMA tuning
Now, to keep all the ram on one CPU, while still allowing it to spill over to the ram from th other CPU when needed, you can pin the process to a CPU and make the ram of that CPU preferred !
Here is an example, if you intend to use the disk with MySQL, you would do as follows
1- Make sure the daemon is called mysql
systemctl status mysqld
2- Create an override file
sudo systemctl edit mysql
3- Add NUMA binding (Empt line means “Clear the existing startup command first”)
[Service]
ExecStart=
ExecStart=/usr/bin/numactl –cpunodebind=1 –preferred=1 /usr/sbin/mysqld
sudo systemctl daemon-reload
sudo systemctl restart mysql
ps aux | grep mysqld
An alternative to all the above would be to pin it to CPUs !
[Service]
CPUAffinity=16-31
The rest is just like the other method