WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Does TC run 100% in RAM?  (Read 7652 times)

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Does TC run 100% in RAM?
« on: March 28, 2013, 12:54:10 PM »
Hi

Does TC run 100% in RAM, even the files or folders one might have added and made persistent which are not shown to be mounted as RO in tc/loop?

The reason I ask is that my intentions are to use TC for "embedded" or stand-alone "appliance" applications.
In these kind of applications, the user simply switches power off to the unit instead of doing a proper shutdown
so I'm wondering what possible effect (if any) it may have on the FAT32 formatted USB stick that TC boots off.

Thanks.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11581
Re: Does TC run 100% in RAM?
« Reply #1 on: March 28, 2013, 01:07:01 PM »
Hi Paulo
While it's always nicer to do a proper shutdown, as long as you don't need to do writes to the stick, you should be OK.

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Does TC run 100% in RAM?
« Reply #2 on: March 28, 2013, 01:20:44 PM »
Hi Rich

Thanks.
Yes, I don't intend on writing anything back to the USB stick.

The first project I have in mind is a remote spectrum analyzer where a custom made box which is a small factor ATX mobo+PSU+TC running off a USB stick
plus integrated into the box will be my circuit that digitizes the I.F. output from a RF front-end.
The whole thing is connected via Ethernet to a user using only a web browser.

This remote box wil have apache running and when the users web browser requests a new scan (done periodically via a refresh meta tag), it posts
the request to a perl script which in turn calls a binary which I have compiled that sets the frequency of the RF front-end, waits for the PLL to stabilize
then samples the I.F. output (via an ADC connected to the LPT) and sends the value back to my executable which "prints" out a svg back to the perl script
via apache and onto the users web browser.
The whole process is repeated for the number of frequencies required for a scan which takes about 2.5 seconds.

So no saving is required on the boxes USB stick as everything is done on-the-fly.

TC is perfect for this kind of thing as it's completely "modular" in the sense that one only adds what is needed.
« Last Edit: March 28, 2013, 01:23:49 PM by Paulo »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11581
Re: Does TC run 100% in RAM?
« Reply #3 on: March 28, 2013, 01:45:02 PM »
Hi Paulo
If you are writing anything to /home/tc, don't use a persistent  home. If you are using persistent storage for your
web pages, like  /mnt/sda1/www  or something, make sure apache doesn't need to write to those directories.

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Does TC run 100% in RAM?
« Reply #4 on: March 28, 2013, 01:51:58 PM »
Hi Rich

Thanks for the tip.
The way I designed it is that Apache, the Perl script and my executable don't write anything back to any directory or file, instead it only
"prints" svg lines to a html page which is sent directly to the users web browser.
Each of these lines represent the amplitude of each frequency in the scan.

However it does bring up another question, Apache logs every access to a log file.
Can I assume that this log file exists in RAM and that it's not writing to the actual USB stick?

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11581
Re: Does TC run 100% in RAM?
« Reply #5 on: March 28, 2013, 02:04:15 PM »
Hi Paulo
Most likely it's in RAM in some standard location, like /var or /tmp. You can probably control how logging is handled
by a config file, possibly under usr/local/apache2/conf/

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11043
Re: Does TC run 100% in RAM?
« Reply #6 on: March 28, 2013, 02:58:40 PM »
If you intend for it to lose power, make sure your drive is mounted read-only. Even without writes a RW mount may cause corruption on power loss.

Even better is not mounted at all, see the copy2fs options for loading extensions to RAM.
The only barriers that can stop you are the ones you create yourself.

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Does TC run 100% in RAM?
« Reply #7 on: March 28, 2013, 03:14:18 PM »
Hi curaga

I am a bit confused now.
I thought that extensions are by default mounted as RO in separate tcloop(s).
Can I issue a command like this for the boot drive:
Code: [Select]
mount -r -o remount

But that surely would fail as there are processes running.

As regards copy2fs, this according to the website, involves using Copy Mode, how does one check if TC is running in this mode?
It also mentions the Appsaudit program, where does one find this?
« Last Edit: March 28, 2013, 03:23:08 PM by Paulo »

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Does TC run 100% in RAM?
« Reply #8 on: March 28, 2013, 03:41:12 PM »
boot drive as such never gets mounted.
If a drive gets mounted for some reason as e.g. persistence or swap space and happens to be on boot drive, then that is purely coincidental.

http://tinycorelinux.net/concepts.html
« Last Edit: March 28, 2013, 03:45:35 PM by tinypoodle »
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Does TC run 100% in RAM?
« Reply #9 on: March 28, 2013, 03:52:21 PM »
@tinypoodle

Quote
boot drive as such never gets mounted.
If a drive gets mounted for some reason as e.g. persistence or swap space and happens to be on boot drive, then that is purely coincidental.

My boot drive does get mounted as /mnt/sdb1 type vfat (rw,relatime, ........) so surely according to curaga this could mean possible data corruption on power interruption.

Now according to the wiki, the TC kernel also supports boot options like 'ro' (see page 13 of http://files.kroah.com/lkn/lkn_pdf/ch09.pdf
Would this help?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11043
Re: Does TC run 100% in RAM?
« Reply #10 on: March 28, 2013, 03:54:50 PM »
I am a bit confused now.
I thought that extensions are by default mounted as RO in separate tcloop(s).

The extensions are mounted RO. The drive they are on is mounted RW.

You are correct that remounting doesn't work when a process is running there (loop mounts count as that).

Quote
As regards copy2fs, this according to the website, involves using Copy Mode, how does one check if TC is running in this mode?
It also mentions the Appsaudit program, where does one find this?

When fully in copy mode, no loops are visible in "mount". All extensions are loaded to RAM.

Appsaudit was unified into Apps. See the "toggle copy2fs mode" option in Apps' menu.
The only barriers that can stop you are the ones you create yourself.

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Does TC run 100% in RAM?
« Reply #11 on: March 28, 2013, 04:15:31 PM »
OK I tried adding 'ro' as a boot option and TC complained (several times) about a revalidation error (error num -5 and -16) then continued to boot
and my boot drive is still 'rw'.

Basically what I'm after is setting up TC on a USB stick with all the required extensions, apps and scripts I need for a specific purpose then I need to set
it as 'ro' as no saving/writing/backup/persistence to the boot drive will be required during normal use, but it must be able to survive power interruptions with no
possibilities of data corruption.
If I need to change/add something then ideally I should be able to do so (even if it means on another development machine) then once the changes have been made
then being able to set the whole drive back to 'ro'.

@curaga

There is no "toggle copy2fs mode" option in Apps menu, only "Toggle Default Install to File System Flag".

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11581
Re: Does TC run 100% in RAM?
« Reply #12 on: March 28, 2013, 04:20:08 PM »
Hi Paulo
You can just create an empty file called  copy2fs.flg  in your  tce  directory. That will load all your extensions into RAM
when you boot. Once booted, you should be able to unmount the drive.

Offline Paulo

  • Full Member
  • ***
  • Posts: 139
Re: Does TC run 100% in RAM?
« Reply #13 on: March 28, 2013, 04:36:33 PM »
Hi Rich

Quote
You can just create an empty file called  copy2fs.flg  in your  tce  directory. That will load all your extensions into RAM
when you boot. Once booted, you should be able to unmount the drive.

Didn't work.
It boots, says it's loading extensions then once it loads the desktop is there but wbar only has 1 entry which is the one I made for
my Ethernet Monitor script.
All the others are not there and the only things that work on the right click menu is to exit or drop down to cli which I did.
Once on the cli, there are a whole bunch of errors like so:

Code: [Select]
ls: /usr/local/share/applications/tinycore-scmapps.desktop: No such file or directory
Plus a whole lot more of similar ones for tinycore-screenshot.desktop, services.desktop and so on.
Doing a 'mount' command shows that the boot drive is still mounted as 'rw'.

However it seems that the extensions (at least some of them) are working although not accessable via X.
The extensions I tested were gtkdialog, bash, xdotool and elinks.
Obviously not being in X, xdotool and gtkdialog complained but that didn't matter as the mere fact that they did complain means
they were loaded and working.
« Last Edit: March 28, 2013, 04:50:10 PM by Paulo »

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Does TC run 100% in RAM?
« Reply #14 on: March 28, 2013, 04:49:52 PM »
Do NOT use the ro boot option.
That option is used by normal Linux systems to mount the root read only so that fsck can be run on it, and have it then be remounted rw.
Core uses a RAM based root file system.