Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: Stefann on August 24, 2024, 01:13:40 AM

Title: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 24, 2024, 01:13:40 AM
Hi,
Sorry if this common knowledge or if it is already described somewhere.
I’m trying to learn.

At this moment I have several apps installed as “mount at boot”. I DO understand that I could have chosen for “on demand” which would save mount time and maybe I will do that. At this moment I just want to understand.

What I see happening during startup is that the time spend “mounting all those packages” takes quite some time (I did not time it exactly but I guess 30..60 seconds).
In my (ignorant) assumption “mounting” is just setting some pointers and does not really actively “do” something. After all… the whole reason “not to choose copy mode” is to avoid taking time to load them in ram. If that is the case mounting of all applications together should take less than a second.

For that reason my question: “why is it taking considerable time”? And/or “any smart thoughts about the philosophy behind things” (because this choice between “on demand”/“on boot”/“copy” I consider a very core aspect of TC, i would not be surprised if there would be an untold “philosophy”/“deeper thought” on this).

Note. Practically speaking the boot time is no problem at all. I use tc as os behind a 24/7 home control computer. I boot it only in case of some maintenance. It’s just curiosity.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: curaga on August 24, 2024, 02:29:46 AM
The book contains a lot of info on this, on why symlinks vs unionfs etc.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 24, 2024, 04:31:51 AM
The book contains a lot of info on this, on why symlinks vs unionfs etc.
Thanks, I needed that pointer.
I had read the book already once but “message did not compute at that time”.
The “unionfs” pointer helpt me locating the chapter.
Please be aware I’m not a Linux expert. I’m learning.

I’m highly intrigued and impressed by the tiny core approach though. It is quite brilliant.
- the frugal approach keeps the os clean.
- the .filetool.lst file contains a highly transparent and simple overview of user modifications to the os.
- all in ram makes it super fast and keeps the flashdrive alive by not writing to it (unless specifically asked by the user application)
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 24, 2024, 05:01:23 AM
Ok… I studied the book “with red ears”.. wow  :)

I guess the answer to my question is:
- the tgz is a squashfs based compressed filesystem.
- on boot it creates several mount points in the main filesystem.
- squashfs needs “few blocks in ram” to do that.

So the time is consumed in:
- creating the several mount points in the main filesystem to begin with
- inserting the squashhfs overhead in ram needed to efficiently “make this work”

The method “maintains the original filestructure” of the application (which is good because the os than not generates unexpected omissions).
But that also means that complex applications (such as the gcc compiler) need some time to get mounted IF they need a lot of mountpoints.

>> makes perfect sense! Happy to have learned this.
(Including having broadened my general Linux knowledge)
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: CentralWare on August 24, 2024, 05:03:34 AM
What I see happening during startup is that the time spend “mounting all those packages” takes quite some time (I did not time it exactly but I guess 30..60 seconds).

@Stefann: Good morning!

It sounds to me as though you have a desktop environment and quite a few extensions loading during boot.
If boot time were a concern, you can delegate some extensions to load AFTER the desktop launches.

For example, let's say you had OpenSSH or Dropbear loading to give you remote shell access to the machine. This doesn't HAVE to be something that's done right this second while it's booting up as it'll delay getting to the desktop and it has nothing to DO with the desktop's operations. That said, you could take OpenSSH out of /etc/sysconfig/tcedir/onboot.lst and instead, load it later...  in the background... after your desktop is finished and operational.

The extensions you take out of onboot.lst...  move them into onlater.lst in the same location.  onlater.lst is just a name I came up with, it is not in the TCL text book.
Do not add drivers/firmware, Xorg support extensions or file systems to onlater.lst as it may have adverse results or even stop the desktop from loading.


Add a new line somewhere near the end of /opt/bootlocal.sh
Code: [Select]
/opt/bootlater.sh &
Then create /opt/bootlater.sh
Code: [Select]
#!/bin/sh
TCEDIR=/etc/sysconfig/tcedir
for EXT in $(cat $TCEDIR/onlater.lst)
do
     su -c "tce-load -i ${TCEDIR}/optional/${EXT}" tc
     sleep 1
done
Run backup if you are using backup to persist your changes so that /opt/bootlater.sh gets saved.
The extensions you load in the background, I would recommend limiting any extensions that add icons to the toolbar/wbar/etc. as too many of these being done at the same time can get odd results.
The sleep() call above slows down loading extensions in the background to help prevent some of these oddities.

Please be aware I’m not a Linux expert. I’m learning.
That is exactly why we do what we do here...
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 24, 2024, 07:11:57 AM
Thanks a lot,
that makes a lot of sense.

You are very right,...  I AM loading a lot of stuff I do not need directly.
Especially the c compiler gcc. Also "make" not directly needed.
Also I have feeling I have too much php booting
php-8.3-mod.tcz
php-8.3-fpm.tcz
php-8.3-dev.tcz
php-8.3-cli.tcz
php-8.3-cgi.tcz
while I only need simple php scripts called from apache... no worry, I'll figure out which I can remove by trial and error.
On the other hand I have not included python yet and that is on the todo list.

Not sure I will follow your suggestion (hope you don't mind),
My main question was on "understanding", not necessarily "changing".
Booting the computer is not something I do very often (main reason would be after a crash that only very rarely happens) so the inconvenience is very bearable.
Although clear instructions, I have a big preference to keep things close to standard. I have been running this thing on DSL (damn small linux) since 2008 and expect to run it on TC for an other 15..20 years (lets say... until I die, I'm 62 now). This means I will experience OS upgrades. I want to avoid "OS upgrades requiring work that I totally forgot how to do".

I'm happy I at least "understand" where the "on demand time" is spend on, I can than avoid overloading it.
Also "as the booting took so much time", I was a bit afraid the stuff would also bring cpu-load during normal operation (avoiding that IS a big priority). I now better understand the impact.
If boottime becomes very long I will do as you say.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: CentralWare on August 24, 2024, 11:33:53 AM
Not sure I will follow your suggestion (hope you don't mind),
Of course I don't mind!  In fact, this thread gives me an idea for a project we're working on. :)

Additionally, if you were to modify the list of boot codes you're using and add the code showapps, should you ever need to reboot, this code would display the progress of which extensions are loaded / being loaded and if there was one extension in particular that was taking a good deal of time loading, it would be visually apparent.

Good luck and take care!
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 25, 2024, 12:43:24 AM
Of course I don't mind!  In fact, this thread gives me an idea for a project we're working on. :)

Additionally, if you were to modify the list of boot codes you're using and add the code showapps, should you ever need to reboot, this code would display the progress of which extensions are loaded / being loaded and if there was one extension in particular that was taking a good deal of time loading, it would be visually apparent.

Good luck and take care!
Thanks!
That is actually what I did, and how I noticed that the mounting takes significant time.
I was under the impression that mounting would be similarly simple as creating some symbolic links so that long time surprised me (although I already wondered how “linking into a compressed file” would work).
With all of the knowledge I gathered over past few days I much better understand the concept.

Monitoring the boot- actions on a regular basis will not be possible. In principle I run the thing headless. It’s located in a utility room where hooking up a console is quite cumbersome. I had to do it to solve bios boot-order issues which allowed me to see all this happening. In normal operation I will not be able to see this.
Which actually is a reason to “like to understand this at this moment in time”. It will prevent me from going in wrong directions later.

One thing I WILL do to improve performance is getting rid of desktop/vnc.
At this moment I run fwlm desktop with vnc to access.
I have shh and samba fully functional which means I can actually do all my normal work without desktop/vnc. At this moment I’m still regularly reverting to some of the tiny core gui-based tools so I like the desktop for now.
Once all setup is robustly working without need for tweaks over a week or so I will insert the “text” boot-option and prevent fwlm en vnc from starting. This will improve startup but especially save cpu load in normal operation.
I’ll basically bring 2 labels in de extlinux.conf: one with and one without text-mode. That will allow me to change default label to text or non-text using nano and force that mode by a reboot.

Again, thanks for explaining/guiding me in directions. All ideas as brought are highly appreciated. Even if I don’t do them directly they will feed into my furture plans.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 26, 2024, 01:40:03 AM
@Stefann: Good morning!

It sounds to me as though you have a desktop environment and quite a few extensions loading during boot.
If boot time were a concern, you can delegate some extensions to load AFTER the desktop launches.

For example, let's say you had OpenSSH or Dropbear loading to give you remote shell access to the machine. This doesn't HAVE to be something that's done right this second while it's booting up as it'll delay getting to the desktop and it has nothing to DO with the desktop's operations. That said, you could take OpenSSH out of /etc/sysconfig/tcedir/onboot.lst and instead, load it later...  in the background... after your desktop is finished and operational.

The extensions you take out of onboot.lst...  move them into onlater.lst in the same location.  onlater.lst is just a name I came up with, it is not in the TCL text book.
Do not add drivers/firmware, Xorg support extensions or file systems to onlater.lst as it may have adverse results or even stop the desktop from loading.


Add a new line somewhere near the end of /opt/bootlocal.sh
Code: [Select]
/opt/bootlater.sh &
Then create /opt/bootlater.sh
Code: [Select]
#!/bin/sh
TCEDIR=/etc/sysconfig/tcedir
for EXT in $(cat $TCEDIR/onlater.lst)
do
     su -c "tce-load -i ${TCEDIR}/optional/${EXT}" tc
     sleep 1
done
Run backup if you are using backup to persist your changes so that /opt/bootlater.sh gets saved.
The extensions you load in the background, I would recommend limiting any extensions that add icons to the toolbar/wbar/etc. as too many of these being done at the same time can get odd results.
The sleep() call above slows down loading extensions in the background to help prevent some of these oddities.
@Centralware
Just rethinking this…
I not yet have figured out how to start an application that was “not on boot mounted”. Will need to wait until next weekend.
But.. having said that..
Instead of adding this extra script,…
Could I not just mount the delayed applications by calling them?
My main delayed time is gcc. Ik probably could just add a “make alert” call in the bootlocal.sh
And have a rule for “alert” that basically just calls gcc for a status message.

This would have the advantage that I don’t need to add an extra .sh file. Reason I am bit hesitant to add such file:
- if I do a tinycore upgrade (say) 4 years from now I may have forgotten about that and fail the upgrade running into a lot of trouble shooting (realistic,… I just upgraded from latest damn small Linux version-2008 to tinycore 15).
- I’m not really a bash-script wizard. I’m struggling enormously with the syntax. I have done a few but all either extremely simple (without variables, without conditional statements), or succeeding only after a lot of trial and error. So…. Of course it would be very nice if your script “just works”, but if I need to modify it 2 years from now that will cost me significant time.

Havingd said that…….I may end up doing it anyway. I like to learn, if I really did not have wanted this I would just have bought something instead of doing it all myself. My homecontrol system is programmed in C from scratch. Started the project before home assistant was a thing.
But… for something as “un-annoying as this” I prefer to keep things simple.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: CentralWare on August 26, 2024, 09:23:52 AM
@Stefann: Have you experimented with OnDemand?
I'm going through the steps right now while describing it to ensure I'm being as accurate as possible.

1. tce-load -wo curl
     This loads the extension curl as an OnDemand program; I just rebooted that machine.  Curl is NOT loaded.

2. curl http://www.google.com
     The curl extension is loaded/mounted and then launched. Google's heavily obfuscated javascript content is returned, as expected.

3. Until the machine is rebooted, the curl extension remains loaded.

I'd imagine this doesn't operate as expected on every extension, but for compiler tools and other things you may not use very often, this may be a way to speed up booting AND reduce memory usage AND in the process, reduce CPU during startup by reducing the number of extensions being dealt with at that time.  It should also be "upgrade" friendly.

Note: Upgrades to the operating system should never be affected by /opt scripts as your backups or persistent directories generally fall outside the core operation files and extensions.

REMEMBERING changes you've made, however, is another story.  It's always wise if you make changes and need to remember 5 years from now WHY you did something or what you did it for, in shell scripts like bootlocal.sh, bootsync.sh (and other .sh files) simply leave yourself detailed notes/comments preceded by a pound sign (#)
Code: [Select]
# put other system startup commands hereis a good example found at the start of /opt/bootlocal.sh  The "#" and everything that follows it on that line is ignored by the system.
This is a similar concept to the comments you're accustomed to in C.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Rich on August 26, 2024, 10:35:11 AM
Hi CentralWare
... I'd imagine this doesn't operate as expected on every extension, ...
It doesn't work for every extension. You don't want to use it for
libraries, kernel modules, or firmware.

It works for curl because a script that loads curl.tcz is created and that
script is called curl. It is found because $PATH includes the ondemand
directory:
Code: [Select]
tc@E310:~$ echo $PATH
/home/tc/.local/bin:/usr/local/sbin:/usr/local/bin:/apps/bin:/usr/sbin:/usr/bin:/sbin:/bin:/etc/sysconfig/tcedir/ondemand
tc@E310:~$

It will likely fail with tar.tcz because busybox /bin/tar will be found before
/etc/sysconfig/tcedir/ondemand/tar.

It will only work if the name of the extension exactly matches the name
of the program you want to run.

Anyone placing compiletc.tcz ondemand expecting gcc to magically
load and execute will be disappointed.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 26, 2024, 10:44:53 AM
@Stefann: Have you experimented with OnDemand?
I'm going through the steps right now while describing it to ensure I'm being as accurate as possible.

1. tce-load -wo curl
     This loads the extension curl as an OnDemand program; I just rebooted that machine.  Curl is NOT loaded.

2. curl http://www.google.com
     The curl extension is loaded/mounted and then launched. Google's heavily obfuscated javascript content is returned, as expected.

3. Until the machine is rebooted, the curl extension remains loaded.

I'd imagine this doesn't operate as expected on every extension, but for compiler tools and other things you may not use very often, this may be a way to speed up booting AND reduce memory usage AND in the process, reduce CPU during startup by reducing the number of extensions being dealt with at that time.  It should also be "upgrade" friendly.

Note: Upgrades to the operating system should never be affected by /opt scripts as your backups or persistent directories generally fall outside the core operation files and extensions.

REMEMBERING changes you've made, however, is another story.  It's always wise if you make changes and need to remember 5 years from now WHY you did something or what you did it for, in shell scripts like bootlocal.sh, bootsync.sh (and other .sh files) simply leave yourself detailed notes/comments preceded by a pound sign (#)
Code: [Select]
# put other system startup commands hereis a good example found at the start of /opt/bootlocal.sh  The "#" and everything that follows it on that line is ignored by the system.
This is a similar concept to the comments you're accustomed to in C.
Thanks,
That is indeed how I was hoping this would work.
No I did not try this yet. As I have a day job it will need to wait until Saturday.
And... even worse... today it became clear I will need to help my son with his business for some time. I'm afraid "tiny core time" will be very restricted in the weeks to come (but I will need some tiny core relax time now and than  :) ).
I'll keep you posted on progress.

Yes... indeed I make notes on how I configure things.
preferably as comments in the files I have as you say
I made a full text file that describes step-by-step the whole process that I went through to get tiny core working. Including sections and config info for each application I loaded.
For that reason I feel quite "fine" to add some lines to boot local.sh
But feel more reserved on adding an other script.sh file:
- extra lines in boot local.sh I can simply accompany by comment
- an extra script.sh file will need an extra section in my step-by-step documentation. Which makes it more cluttered. As said... I may still do it... but I have a basic reluctance against extra files, especially if the benefit is very marginal.

For info: I timed a reboot yesterday. The console is no longer there to monitor boot-steps but I can of course time between reboot-command & functional again. I am currently at 80 seconds (on a 500MHz single core 32bit ultra low power VIA EDEN processor). In principle "that is very acceptable", just enough to make a coffee.

It doesn't work for every extension. You don't want to use it for
libraries, kernel modules, or firmware.

Anyone placing compiletc.tcz ondemand expecting gcc to magically
load and execute will be disappointed.

Ah.. thanks for that update.
So... it will require testing. And it will need "retesting" for any application.
We'll see... as mentioned above, it looks like I will not have much time in coming weeks, I keep you guys posted.

And... main goal of the start of this tread is certainly achieved: I got guided into understanding things and I will built on that.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: CentralWare on August 26, 2024, 11:48:19 AM
@Stefann: The extra script isn't a requirement; the same content can be added to bootlocal.sh directly; it's merely my own practice to separate things for organizational reasons.
(bootlocal.sh is already run as a background task.)

@Rich: compiletc...  yes, I hadn't considered that one but can imagine the reaction!  Until recently, I didn't utilize macro extensions at all - nor did OnDemand seem useful for what I do on a day-to-day basis, so putting the two together wasn't going to come from experience :)  I do, however, miss the "TC" macro concept!  (TCL 8.x I believe - "instant desktop")
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Rich on August 26, 2024, 01:51:48 PM
Hi CentralWare
... Until recently, I didn't utilize macro extensions at all ...
I guess you are referring to  meta-extensions ?

Quote
- nor did OnDemand seem useful for what I do on a day-to-day basis, ...
I've never used OnDemand myself. I felt it was too easy to misuse. Though it's been
a while, there have been some occasions where a user saw OnDemand and assumed
it meant every command could be at your fingertips by placing extensions there
instead of OnBoot.

... It will only work if the name of the extension exactly matches the name
of the program you want to run.

Anyone placing compiletc.tcz ondemand expecting gcc to magically
load and execute will be disappointed.
Just to hammer the point home (or beat it to death), here are a handfull of
(non-meta extension) examples that are also not candidates for OnDemand:
Code: [Select]
ace-of-penguins.tcz
alsa.tcz
alsa-config.tcz
aoetools.tcz
apache2.4.tcz
bind.tcz
binutils.tcz
blueman.tcz
bluez.tcz
bluez5.tcz
cairo.tcz
cdrtools.tcz
connman.tcz
coreutils.tcz
cups.tcz
ffmpeg3.tcz
findutils.tcz
fox.tcz
freebasic.tcz
ijs.tcz
inetutils.tcz
inotify-tools.tcz
pci-utils.tcz
usbutils.tcz
util-linux.tcz

Also, most, if not all of the following:
Code: [Select]
*-dev.tcz
*-doc.tcz
*-icon*.tcz
lib*.tcz     # Plus library extensions by other names (cairomm.tcz, clucene.tcz, clutter.tcz, freeglut.tcz, glu.tcz, ... )
*-locale.tcz
*-theme*.tcz
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 26, 2024, 03:00:48 PM
@Stefann: The extra script isn't a requirement; the same content can be added to bootlocal.sh directly; it's merely my own practice to separate things for organizational reasons.
(bootlocal.sh is already run as a background task.)

Than actually makes a lot of sense.
I will try it.
As said… time will be bit of a problem upcoming weeks


Just to hammer the point home (or beat it to death), here are a handfull of
(non-meta extension) examples that are also not candidates for OnDemand…..

Shortened the quote… but you fully made your point.

Amen..

Will not go that route
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Leee on August 26, 2024, 03:23:43 PM
I've been following this thread and I've got to say, I just learned a -lot- about loading extensions ondemend.  I like to keep my toolbox well stocked, so to speak, so knowing some of the gritty details about ondemand is kind of satisfying.
Having said that, I've never actually used ondemand, nor do I expect to... but you never know. :)

Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: CentralWare on August 26, 2024, 03:33:41 PM
I guess you are referring to  meta-extensions ?
@Rich: LOL...  nah!
META="...to one's self" (like self-reflection) or showing or suggesting an explicit awareness of itself or oneself as a member of its category"
MACRO="a single instruction that expands automatically into a set of instructions to perform a particular task."

For example, the
META-TAG (in HTML) describes the page it lives within; sometimes more as an appendage as time progressed.
META-MUCIL...  doesn't get more "self aware" of what's "within" than that! :P
"eh...  whadda I know!?"

@Leee: I can imagine for those short on memory...  I mean RAM... loading things on-the-fly could really come in handy.
I'd imagine it being even more useful if those same items could be unloaded when they've completed their tasks...  but the argument would then be "...who is to say WHEN it's no longer needed?..."
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Rich on August 26, 2024, 05:10:16 PM
Hi CentralWare
I guess you are referring to  meta-extensions ?
@Rich: LOL...  nah!
META="...to one's self" (like self-reflection) or showing or suggesting an explicit awareness of itself or oneself as a member of its category"
MACRO="a single instruction that expands automatically into a set of instructions to perform a particular task." ...
So you weren't referring to extensions like  compiletc.tcz ?  ???
Quote
Title:          compiletc.tcz
Description:    compiletc metapackage
Version:        0.1
Author:         n/a
Original-site:  tinycorelinux.com
Copying-policy: n/a
Size:           4KB
Extension_by:   N. Carigon
Tags:           compiletc metapackage
Comments:       This is a meta-extension for a compile environment
 ----- Snip -----
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: CentralWare on August 27, 2024, 04:37:44 AM
@Rich: Sorry, was making fun of the "meta" name (per Webster's)
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Rich on August 27, 2024, 10:00:52 AM
Hi CentralWare
I know, I was just messing with you. ;D
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: yvs on August 28, 2024, 04:23:28 PM
Hi CentralWare
... I'd imagine this doesn't operate as expected on every extension, ...
It doesn't work for every extension.
I suppose that tips suggesting extensions containing some program (or might be even with a prompt to download/install them) can be done by shell hooks on user side (most of shells have some not_found hook).
Those handy tips are often used in many other distributions.

Something like
Code: [Select]
tc@tc-x86_64:~$ cc
cc found in 'gcc'

tc@tc-x86_64:~$ as
as found in 'binutils'

tc@tc-x86_64:~$ yacc
yacc found in 'bison'

tc@tc-x86_64:~$ locate
locate found in 'findutils'

tc@tc-x86_64:~$ hmm   
hmm: not found

The only thing that makes it a bit annoying it's manual support and update a list of those binaries because lack of centralized db/lists of packaged files (it's several shell lines but anyway it can easy forget to update those lists locally by end-user) and possible difference in naming of the same extensions among TCL for different architectures
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 29, 2024, 12:38:40 AM
Note… in response to my own original question:
Understanding tc: Why is “mount on boot” not super fast?
Where my initial objective was mostly “understanding”, not necessarily “solving”.
(For reason I intend to use this OS for 15+ year, I like to understand it)

I had a bit of a brainwave….
Mounting is probably reasonably fast,
But the full compressed archive will probably need a read


That would mean that the “on boot” startup time would be  proportional to the disk space of that all “on demand” .tcz files take.

And this is where I probably went wrong in very initial assumption:
- a normal mount just mounts from a location one can find in an instant
- this mounting of a compressed archive probably requires disk operation to read the full archive file.

In weekend I will see which package has a large footprint and see what happens if I exclude it from boot.
My thought is triggered because I notice the “disk activity” led showing lots of action during boot. That is not mounting…. That is reading.


Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Rich on August 29, 2024, 02:16:01 AM
Hi Stefann
... My thought is triggered because I notice the “disk activity” led showing lots of action during boot. That is not mounting…. That is reading.
The disk activity is likely from all of the links being created from
the filesystem to the files in each extension.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: curaga on August 29, 2024, 02:21:14 AM
@yvs: Personally that really annoys me on Ubuntu and others. When I make a typo, that hook causes significant delay, with cold caches the first time is several seconds.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: yvs on August 29, 2024, 05:07:16 AM
@yvs: Personally that really annoys me on Ubuntu and others. When I make a typo, that hook causes significant delay, with cold caches the first time is several seconds.
agree I usually disable it and use `apt-file search` when it's needed, it's slow there maybe because of enormous number of packages and files in that, or probably some compression to keep that info, I haven't dig into it.
In case of not so big number of TC extensions it doesn't look slow to become annoying, for example for the first time not installed gcc:
Code: [Select]
tc@tc-x86_64:~$ time gcc
gcc found in 'gcc'
                                                                               
real    0m0.009s
user    0m0.004s
sys     0m0.005s


it's in case of a simple bash hook (not tried busybox ash compiled with CONFIG_ASH_BASH_NOT_FOUND_HOOK yet)
Code: [Select]
# it can be boosted a bit using filelist on ramfs and pregrepping before sed

EXT_BIN_LIST="/etc/sysconfig/tcedir/not_found.aux"

function command_not_found_handle() {
  test -f "$EXT_BIN_LIST" && {
    bin="$1"; shift
    exts="$(sed -n "s,^\(.*\)[ ]\+.*/$bin/.*,\1,p" <"$EXT_BIN_LIST")"
    test -n "$exts" && echo "$bin found in '$exts'" || echo "$bin: not found"
  }
  return 127
}

and simple text format like
Code: [Select]
% grep '^gcc' /etc/sysconfig/tcedir/not_found.aux
gcc /c++/cc/cpp/g++/gcc/gcc-ar/gcc-nm/gcc-ranlib/gcov/gcov-dump/gcov-tool/lto-dump/x86_64-pc-linux-gnu-c++/x86_64-pc-linux-gnu-g++/x86_64-pc-linux-gnu-gcc/x86_64-pc-linux-gnu-gcc-13.2.0/x86_64-pc-linux-gnu-gcc-ar/x86_64-pc-linux-gnu-gcc-nm/x86_64-pc-linux-gnu-gcc-ranlib/

Anyway command_not_found_handle() can be set/unset by user, it's always good to have options
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: yvs on August 29, 2024, 05:35:48 AM
- this mounting of a compressed archive probably requires disk operation to read the full archive file.
Not sure if that's related: on Ubuntu with its squashfs use (for snaps) there were many discussions of use different compression formats (for example lzo zstd xz etc.) trading-of between size and performance
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: mocore on August 29, 2024, 08:16:36 AM
Ubuntu with its squashfs use (for snaps) there were many discussions of use different compression formats (for example lzo zstd xz etc.) trading-of between size and performance

 some perhaps (historically) relevant content on that subject linked in the below quote 


wrt squashfs and compression
iv just found this [linked below]  post lamenting the state of Ubuntu's Snap single-threaded decompression   
... "scripts to recreate these measurements are included" ! .. if any one with similar hw is interested in making comparison?
https://forum.snapcraft.io/t/squashfs-is-a-terrible-storage-format/9466
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 29, 2024, 03:17:39 PM
head of the optional folder sorted on size.

Indeed gcc is super big
-> I definitely can do with a later load of that.
Would not be surprised if that is eating 50% of boottime.

To my (kind of) surprise samba3 is also big
-> One of the first things I use, cannot load later.
>> guess samba did not succeed in "having small footprint" like many other apps.

mmmh... I did. not install perl. guess this is a dependancy somewhere

ouch... I have 2 pythons, I can get rid of one.

After that it becomes peanuts

Will need to find time in weekend to explore
 

Code: [Select]
tc@huis:/mnt/sda1/tce/optional$ ls -Sl
total 215860
-rw-rw-r--    1 tc       staff     61710336 Aug 17 06:26 gcc.tcz
-rw-rw-r--    1 tc       staff     35917824 Aug 17 06:25 samba3.tcz
-rw-rw-r--    1 tc       staff     16601088 Aug 17 06:25 perl5.tcz
-rw-rw-r--    1 tc       staff     16556032 Aug 17 06:25 python3.6.tcz
-rw-rw-r--    1 tc       staff     15740928 Aug 17 06:25 python3.9.tcz
-rw-rw-r--    1 tc       staff      6410240 Aug 17 06:25 binutils.tcz
-rw-rw-r--    1 tc       staff      4218880 Aug 17 06:25 php-8.3-dev.tcz
-rw-rw-r--    1 tc       staff      3239936 Aug 17 06:25 php-8.3-ext.tcz
-rw-rw-r--    1 tc       staff      3125248 Aug 17 06:25 glibc_base-dev.tcz
-rw-rw-r--    1 tc       staff      3063808 Aug 17 06:25 glibc_gconv.tcz
-rw-rw-r--    1 tc       staff      2994176 Aug 17 06:25 gcc_libs-dev.tcz
-rw-rw-r--    1 tc       staff      2834432 Aug 17 06:25 openssl.tcz
-rw-rw-r--    1 tc       staff      2764800 Aug 17 06:26 realvnc.tcz
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Rich on August 29, 2024, 04:13:27 PM
Hi Stefann
I don't think size is the main issue. I think it's the number
of symlinks that need to be created. That is a function of
how many files are in the extension.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 30, 2024, 12:38:46 AM
Hi @rich,
I think you are right,
I did do some reading on squashfs, it’s indeed intended to be a fast compressed filesystem (you of course knew that :) ), and what’s more… the meta data is kept in some special place. So.. not the full file needs to be read to identify all mount points.
Anyway… the practical implication is probably less.
Biggest file gcc is 61MB, 7th ranking big file is php with 4MB. I guess that the amount of mountpoints for php will be similarly smaller.
I will just do a test this weekend by removing gcc from the onboot list and see what happens.

Note: by now it’s just for fun and learning. There is hardly a real need to do this.
Having said that….  if it gives a significant gain.. I will probably remove gcc from the onboot list permanently and load it via bootlocal.sh as @centralware suggested. A single line in bootlocal.sh i probably consider worth the “clutter deviating it from standard”.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: CentralWare on August 31, 2024, 01:01:40 AM
@Rich: I was about to give a little advice regarding extension loading (ie: $platform/tcz/src build file examples) until it dawned on me, I don't have an answer on a piece or three of the puzzle.
tce, tce-load, etc. - I'm guessing all of these scripts assume $USER is a sudoer?

SO... to test the theory I created a test script to clone how tce might be doing its (-i)
Code: [Select]
#!/bin/sh
. /etc/init.d/tc-functions
clear; CUR=$(pwd)

### tcl-load -i theory:

# Gather our extension name from $1 (just for this test, loop from $@ normally)
EXT=$1
EXT=${EXT/.tcz/}
EXT=${EXT/KERNEL/$(uname -r)}
echo "${WHITE}Loading ${YELLOW}$EXT${NORMAL}"

# 1. Mount the extension $EXT in /tmp/tcloop2
if [ ! -d /tmp/tcloop2/$EXT ]; then
    echo "  ${WHITE}Mounting ${YELLOW}$EXT${NORMAL}"
    mkdir -p /tmp/tcloop2/$EXT
    sudo mount /etc/sysconfig/tcedir/optional/${EXT}.tcz /tmp/tcloop2/$EXT || $(echo "${RED}ERROR! ${WHITE}Failed to load ${YELLOW}${EXT}${NORMAL}" && exit 1) # <-- SUDO Unnecessary?
fi

# 2. Navigate to /tmp/tcloop2/$EXT
cd /tmp/tcloop2/$EXT

# 3. I'm seeing LINKS and FILES in tce.installed...  LINKS are from /tmp/tcloop/EXT, FILES are dummy/empty that didn't exist.
<skipped>

# 4. Use find -exec to mkdir all DIRECTORIES to /fake/*
sudo find * -type d -exec sudo mkdir -p /fake/{} \;                                                     # <-- SUDO

# 5. Use find to LINK all FILES into /fake/*
sudo find * -type f -exec sudo ln -s /tmp/tcloop2/${EXT}/{} /fake/{} \;                                 # <-- SUDO

# 6. I'm guessing HERE is a good place to launch /usr/local/tce.installed/$EXT
[ -e /usr/local/tce.installed/$EXT ] && sudo sh /usr/local/tce.installed/$EXT                           # <-- SUDO

# 7. I don't know if files are SCANNED (libraries) or if ldconfig is called "just in case"
sudo /sbin/ldconfig >/dev/null 2>&1                                                                     # <-- SUDO

# 8. I'm also guessing for hardware/firmware/modules we need to call udevadm - unsure of our trigger
# find * -type d -name modules?  Or -name modules* needed for x64/pi/etc?

UPDATE: Move #6 to the end

...it was quicker than dredging through TCE :)
Any insight from experience? (When you have a minute!)

Thanks!
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 31, 2024, 10:55:15 AM
Welll…. I did the test.. removed gcc from the onboot.lst.
No luck. Boot time exactly the same (within about a 1 second margin as I was just timing it with my phone, viusually watching the status leds).

I was able to cut 10 seconds by deleting a bunch of old error logs that were part of the backup.
I’m now at 100 seconds From “press physical start button to application running”.
That’s actually not real bad.
(In earlier post I said 80secs which was timed less accurate by simply counting)
Of course already 5 seconds get lost by “waitusb” and I feel the bios also eats 5 seconds as it takes 10 seconds to see any disk activity.
I think time is limited by disk access, I see the disk-led flashing constantly. It’s an old slow 500MHz processor, the 10 seconds I gained by deleting approximately 30MB of error logs, so yeahhhh… it’s slow. And that’s ok as it is also very low power.
As said earlier, the system is currently headless without console. I can only check the status leds.

It’s ok.
I consider the topic closed.
I learned a lot.
Application is running and controlling my home.
And it’s fun.
Thanks to all who put their thoughts in this.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Rich on August 31, 2024, 12:23:56 PM
Hi Stefann
... I was able to cut 10 seconds by deleting a bunch of old error logs that were part of the backup. ...
Backup/restore functions can really eat up time if many and/or
large files are involved.

Try to be selective by backing up individual files.

Avoid backing up entire directories when possible.

If your home directory has a lot of files, consider
switching to a persistent home. See the Wiki for
persistence.

Or you can try something like this:
Code: [Select]
mkdir "$(readlink /etc/sysconfig/tcedir)/../MyData"
ln -s "$(readlink /etc/sysconfig/tcedir)/../MyData" MyData

The first command finds the device your tce directory is located
on and creates a directory called MyData on it.

The second command creates a  link  (shortcut) in your home
directory that points to the MyData directory you created.

You can use that link like a regular directory. Copy or move
files to it, create sub-directories in it, etc. This would be a
place to keep some files you might otherwise place in your
home directory. When you run a backup, only the link gets
backed up, not the contents it's pointing to. That is fine
because the contents it's pointing to are on persitent
storage.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on August 31, 2024, 01:23:49 PM
Thanks,
And ehh… I already had that  :)
My home directory is really empty, merely administrative  stuff and profiles. The backup is now under 5 seconds.
I created 2 partitions on my disk, 1st with tc, and the 2nd partition with all my user data. Indeed in the bootlocal I create  a directory /work and mount that to the 2nd partition.
Actually I “mount” it to /work, not “link”. I’m always a bit confused about the pros and cons but i normally approach the machine as a network drive by the samba server. That works better with a mounted location than a link.

I did consciously chose NOT to use persistent opt and home.
By doing this I can always copy the tc and backup file to the 2nd partition and than do a complete whipe and reinstall of tinycore on the 1st partition.
In other words… I keep tinycore pristine on partition 1. Without snippets like “persistent home and opt” on partition 2.
All deltas from stock are in the backup file.
While partition 2 is fully for user data.

I thought long about this choice. On dams small Linux where I come from I DID have persistent home and opt but after few years both got polluted. Once they are polluted it becomes very difficult to separate OS content from self inserted content.

Note….
The tricky thing is that one “might” think about the home directory as a directory with user data only but that is completely  true. It is loaded with hidden files that configure the desktop and the login behaviors. So…
I consider the home directory as a directory that sure carries the preferences of the user but belongs to the OS, not to the “user space”.
(And by taking that approach the backup remains really really small)

Note…
As I said earlier. I started this in 2008 on damn small Linux. That was also my 1st experience with Linux which means that by the time all was working the thing was pretty cluttered.
Now I’m making a fresh start with tiny core I make sure I really really really have the concepts right.
(Which was the reason for the original question… wanting to understand to avoid going in a direction I would later regret).

And… but… having all said that….
I sure appreciate the inputs.
Some I already did. Others hint me.
And (as you I hope recognize) I’m sure interested to understand the concepts.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Rich on August 31, 2024, 01:40:11 PM
Hi CentralWare
... I'm guessing all of these scripts assume $USER is a sudoer?
Yes.

Quote
...it was quicker than dredging through TCE :)
Any insight from experience? (When you have a minute!)
There is a lot going on there.

#1 is actually:
Code: [Select]
# If load local or install then also check if already installed.
if [ "$INSTALL" ] && [ ! "$BOOTING" ]; then
        if [ -f "$TCEINSTALLED/$APPNAME" ]; then
                echo "$APPNAME is already installed!"
                continue
        fi

Quote
Code: [Select]
# 3. I'm seeing LINKS and FILES in tce.installed...
The links are post install scripts. The rest are empty files.
All entries in this directory match extension names without .tcz.
These are used by other script(s) to test if an extension is already installed.

Quote
Code: [Select]
# 4. Use find -exec to mkdir all DIRECTORIES to /fake/*
sudo find * -type d -exec sudo mkdir -p /fake/{} \;                                                     # <-- SUDO

# 5. Use find to LINK all FILES into /fake/*
sudo find * -type f -exec sudo ln -s /tmp/tcloop2/${EXT}/{} /fake/{} \;                                 # <-- SUDO
find  is only used to determine if an extension is empty (meta extension)
or contains kernel modules.
Files get linked in like this:
Code: [Select]
yes "$FORCE" | sudo /bin/cp -ais /tmp/tcloop/"$APPNAME"/* / 2>/dev/null
Quote
Code: [Select]
# 7. I don't know if files are SCANNED (libraries) or if ldconfig is called "just in case"
If $BOOTING ldconfig is called after all of onboot.lst is installed.
The rest of the time, it is called after each extensions is installed.

Quote
Code: [Select]
# 8. I'm also guessing for hardware/firmware/modules we need to call udevadm - unsure of our trigger
# find * -type d -name modules?  Or -name modules* needed for x64/pi/etc?
Right after creating links from extension into file system:
Code: [Select]
[ -n "`find /tmp/tcloop/$APPNAME -type d -name modules`" ] && MODULES=TRUEThen update_system gets called which includes this:
Code: [Select]
                if [ "$MODULES" ]; then
                        sudo /sbin/depmod -a 2>/dev/null
                        sudo /sbin/udevadm trigger

copy2fs.list, copy2fs.flg, and $BOOTING will also affect what happens.

Quote
Code: [Select]
# 6. I'm guessing HERE is a good place to launch /usr/local/tce.installed/$EXT
[ -e /usr/local/tce.installed/$EXT ] && sudo sh /usr/local/tce.installed/$EXT                           # <-- SUDO
It depends:
Code: [Select]
        if [ -x "$TCEINSTALLED"/$2 ]; then
                if [ "$BOOTING" ] ; then
                        echo "$TCEINSTALLED"/$2 >> /tmp/setup.lst
                else
                        sudo "$TCEINSTALLED"/$2
                fi
        else
                touch "$TCEINSTALLED"/$2
        fi
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: curaga on September 01, 2024, 03:04:15 AM
If you add the label or uuid option to waitusb, it will proceed as soon as the device shows up, with the 5 secs becoming the max value.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on September 01, 2024, 07:21:13 AM
If you add the label or uuid option to waitusb, it will proceed as soon as the device shows up, with the 5 secs becoming the max value.
Ahh.. thanks...
No: I did not know that
Sadly: it will not help as the uuid is already there (I created the install by using the tiny-core "create install gui"

I guess in that case the bios takes more time. I start seeing disk-activity after about 10secs

Note, its not really bad, the 100sec total start time includes starting the desktop and VNC and samba and ssh.
Like everything until my application starts.
On a 500MHz low power 1watt cpu from 2008. that's not bad.

Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Juanito on September 01, 2024, 08:03:51 AM
Sadly: it will not help as the uuid is already there (I created the install by using the tiny-core "create install gui"

You use the uuid already created - search these forums or see the wiki to see how to do it.
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: gadget42 on September 01, 2024, 08:20:53 AM
did a forum search for "waitusb=uuid" via the forum search page
(https://forum.tinycorelinux.net/index.php?action=search)
(change the search order to "most recent topics first")

and there are currently four results
Title: Re: Understanding tc: Why is “mount on boot” not super fast?
Post by: Stefann on September 01, 2024, 08:51:43 AM
did a forum search for "waitusb=uuid" via the forum search page
(https://forum.tinycorelinux.net/index.php?action=search)
(change the search order to "most recent topics first")

and there are currently four results
Sadly: it will not help as the uuid is already there (I created the install by using the tiny-core "create install gui"


You use the uuid already created - search these forums or see the wiki to see how to do it.

That's what I mean, I'm already doing that:

Code: [Select]
DEFAULT core

LABEL core
KERNEL /tce/boot/vmlinuz
INITRD /tce/boot/core.gz
APPEND quiet  host=huis syslog cron tz=CET-1CEST,M3.5.0,M10.5.0/3 waitusb=5:UUID="a6f362cf-6c77-4fb7-bb05-76724d3b8113" tce=UUID="a6f362cf-6c77-4fb7-bb05-76724d3b8113"