Page 1 of 1

command line boot + tmpfs + ram disk/cache

Posted: Sun Jun 28, 2020 1:03 am
by 22over7
I'm new to the pi world. While waiting for my 8gb pi4 to arrive, I've been reading up the online documentations and I have several questions about setup/config.

(1) I plan to use the pi sometimes in the headless mode, and sometimes with full desktop. One of the forum member mentioned that I can first install the desktop raspberry OS, and then upon login, config the pi to CLI (and then run startx as needed). But

https://www.raspberrypi.org/documentati ... xt/boot.md

does not seem to mention that. Did I overlook something obvious or should I proceed differently?

(2) I recall reading somewhere that one can change a setting so pi does not write log files/write them to the ram to save the sdcard. Unfortunately I can't find that post and

https://www.raspberrypi.org/documentati ... /memory.md

don't seem to mention this. Again, did I overlook something obvious or should I proceed differently?

(3) I came across several references to "ram disk" or "ram cache" to spend up programs. I assume that means by loading a big program (e.g. mathematica) into the ram once per session, we save time by no longer having to load it again, right? Or perhaps there's a way to use the ram to speed up the execution of the program? In any case, where I can find out more about it (what ram disk does and how to set up it).

(4) On a related note: Is there a way to setup gcc/make etc so that intermediate files/outputs are stored in the ram, both to save the sdcard and to help speed things up? Where can I find out more (about setting this up)? And how do I save the file executable in the sdcard?

Thanks!

Re: command line boot + tmpfs + ram disk/cache

Posted: Sun Jun 28, 2020 1:35 am
by kerry_s
your over thinking it.

1. you just need to unplug the monitor, it's that simple.
2. no, leave it alone.
3. no & maybe, really depends on the app. for example i start the browser with the " --headless " command to load the parts in to memory at startup, which just gives a bit quicker first start. not truly a big as i don't turn off my system.
4. no

Re: command line boot + tmpfs + ram disk/cache

Posted: Sun Jun 28, 2020 1:58 am
by 22over7
First, thanks for your help. A couple of follow-up questions:
kerry_s wrote:
Sun Jun 28, 2020 1:35 am
your over thinking it.

1. you just need to unplug the monitor, it's that simple.
2. no, leave it alone.
3. no & maybe, really depends on the app. for example i start the browser with the " --headless " command to load the parts in to memory at startup, which just gives a bit quicker first start. not truly a big as i don't turn off my system.
4. no
(1) re headless: For my usage scenario there will be times where I will take my pi on the road and run it without monitor, so I do need to figure out how to run the pi truly headless (with the option to run startx). With that said let me repeat/rephrase my question: After I install the desktop raspberry OS, how should I edit rasp.config (or some other settings) so that subsequent boot goes into text mode (headless or otherwise) with the option to run startx?

(3) Is the "--headless" option specific to the browser (chromium?), or can I use it for any program? And I assume that it is specific to raspberry OS? I've used ubuntu (desktop) for years and I've never heard of this option (which doesn't mean it's not there!).

THANKS!

Re: command line boot + tmpfs + ram disk/cache

Posted: Sun Jun 28, 2020 2:03 am
by jahboater
22over7 wrote:
Sun Jun 28, 2020 1:03 am
(2) I recall reading somewhere that one can change a setting so pi does not write log files/write them to the ram to save the sdcard.
Yes. Add this line to /etc/fstab

Code: Select all

tmpfs /var/log tmpfs defaults,noatime,nosuid,size=16m 0 0
Note that the log files are cleared when the Pi is rebooted.
22over7 wrote:
Sun Jun 28, 2020 1:03 am
(3) I came across several references to "ram disk" or "ram cache" to spend up programs. I assume that means by loading a big program (e.g. mathematica) into the ram once per session, we save time by no longer having to load it again, right? Or perhaps there's a way to use the ram to speed up the execution of the program? In any case, where I can find out more about it (what ram disk does and how to set up it).
No need - it is done automatically. The OS will cache programs and data as needed. Try running a large program twice, it will be much faster to start the second time. The 8GB Pi has plenty of spare memory for this.
22over7 wrote:
Sun Jun 28, 2020 1:03 am
(4) On a related note: Is there a way to setup gcc/make etc so that intermediate files/outputs are stored in the ram, both to save the sdcard and to help speed things up? Where can I find out more (about setting this up)?
Yes. Like (2), simply add this line to /etc/fstab to put /tmp in memory.

Code: Select all

tmpfs /tmp tmpfs defaults,noatime,nosuid 0 0
There is also the -pipe option for GCC that uses pipes for intermediate stuff.
22over7 wrote:
Sun Jun 28, 2020 1:03 am
And how do I save the file executable in the sdcard?
What do you mean? Files are just written in the normal way.
If you mean "how do I install my new program so that it can used anywhere" then you may use the "install" command:

Code: Select all

sudo install -C -o bin -g bin myprog /usr/local/bin
This will install your new program called "myprog" into a public place. Any user may just type myprog to execute the program.

Please note that the OS (Raspberry Pi OS) is Linux just like Ubuntu, so most of it should be familiar.

Finally, for the 8GB model, I suggest using the new 64-bit Raspberry Pi OS.
http://downloads.raspberrypi.org/raspio ... 020-05-28/
It is still in beta, but it works very well.

Re: command line boot + tmpfs + ram disk/cache

Posted: Sun Jun 28, 2020 2:20 am
by kerry_s
1. like i said best to not mess with it, if there is no monitor connected, it does not turn on the hdmi/gui. a console is a console it looks exactly the same headless, when you ssh in.

3. it's a linux option, i used it in ubuntu & currently use it on pop!_os. for both chrome/chromium & firefox, it's a little different with firefox.