{"id":6281,"date":"2026-05-09T05:29:51","date_gmt":"2026-05-09T05:29:51","guid":{"rendered":"https:\/\/www.voodoo.business\/blog\/?p=6281"},"modified":"2026-05-10T06:38:55","modified_gmt":"2026-05-10T06:38:55","slug":"ram-disk-on-boot","status":"publish","type":"post","link":"https:\/\/www.voodoo.business\/blog\/2026\/05\/09\/ram-disk-on-boot\/","title":{"rendered":"RAM disk on boot"},"content":{"rendered":"\n<p>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<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The easy way (<strong>tmpfs<\/strong>)<\/h3>\n\n\n\n<p>Start by creating a directory to mount the ram disk onto<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo mkdir -p \/hds\/ram<\/code><\/pre>\n\n\n\n<p>Then just add a line like the following to the \/etc\/fstab file<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tmpfs \/hds\/ram tmpfs defaults,size=80G 0 0<\/code><br>Or, the more elaborate<br><code>tmpfs \/hds\/ram tmpfs rw,noatime,nosuid,nodev,noexec,size=80G,mode=0755 0 0<\/code><\/pre>\n\n\n\n<p>Now mount it<br><code>sudo mount -a<\/code> (To avoid having to restart)<\/p>\n\n\n\n<p>If you have a dual CPU setup, I recommend you check out NUMA tuning before playing with this<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The other way (ramfs)<\/h2>\n\n\n\n<p>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<br>If you must, it is the same as above, but the line in fstab is the following instead<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ramfs \/hds\/ram ramfs rw,noatime,nodev,nosuid,noexec 0 0<\/code><br><\/pre>\n\n\n\n<p>Notes:<\/p>\n\n\n\n<p>1- &#8220;df -h&#8221; will report an 80 GB disk, even though they are not missing from ram, it is an upper limit, not a pre-alocated space<\/p>\n\n\n\n<p>2- <code>noatime<\/code> doesn\u2019t 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<\/p>\n\n\n\n<p>3- <code>noswap<\/code> : swapping a ram disk is probably the worst idea ever ! so you may want to consider <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tmpfs \/hds\/ram tmpfs rw,noatime,nosuid,nodev,noexec,noswap,size=80G,mode=0755 0 0<\/pre>\n\n\n\n<p>4- NUMA tuning<\/p>\n\n\n\n<p>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 !<\/p>\n\n\n\n<p>Here is an example, if you intend to use the disk with MySQL, you would do as follows<\/p>\n\n\n\n<p>1- Make sure the daemon is called mysql<\/p>\n\n\n\n<p><code>systemctl status mysqld<\/code> <\/p>\n\n\n\n<p>2- Create an override file<br><code>sudo systemctl edit mysql<\/code> <\/p>\n\n\n\n<p>3- Add NUMA binding (Empt line means &#8220;Clear the existing startup command first&#8221;)<br>[Service]<br>ExecStart=<br>ExecStart=\/usr\/bin\/numactl &#8211;cpunodebind=1 &#8211;preferred=1 \/usr\/sbin\/mysqld <\/p>\n\n\n\n<p><code>sudo systemctl daemon-reload<\/code><\/p>\n\n\n\n<p><code>sudo systemctl restart mysql<\/code><\/p>\n\n\n\n<p><code>ps aux | grep mysqld<\/code><\/p>\n\n\n\n<p>An alternative to all the above would be to pin it to CPUs !<\/p>\n\n\n\n<p>[Service]<br>CPUAffinity=16-31<\/p>\n\n\n\n<p>The rest is just like the other method<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,156],"tags":[],"class_list":["post-6281","post","type-post","status-publish","format-standard","hentry","category-linux","category-storage"],"_links":{"self":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/6281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/comments?post=6281"}],"version-history":[{"count":6,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/6281\/revisions"}],"predecessor-version":[{"id":6290,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/posts\/6281\/revisions\/6290"}],"wp:attachment":[{"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/media?parent=6281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/categories?post=6281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.voodoo.business\/blog\/wp-json\/wp\/v2\/tags?post=6281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}