WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: ultrafast startup  (Read 10768 times)

Offline julianb

  • Newbie
  • *
  • Posts: 41
ultrafast startup
« on: December 05, 2009, 03:17:15 PM »
one of my desires in using tinycorelinux is to have an ultra-quick boot. on the machine I installed it on (eee pc 900a, install on 4gb ssd) the fresh install boot-time was quick, probably less than 20 seconds. after i installed applications, the boot became much slower. (maybe 40 seconds) i'm still a newb with this tinycore stuff.

so anyway, i'm interested in making the machine keep extensions sitting on disk, ready to load, but have them only load when i open up an app that uses them.

neat thing about tiny core linux, if startup and shutdown are ultra-quick, there isn't a lot of need for a sleep mode. minimizing energy used at startup and shutdown is also desirable for me, because i am setting these machines up to be used in an off-grid environment where power is from solar panels and a solar charged battery bank.

Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: ultrafast startup
« Reply #1 on: December 05, 2009, 04:45:38 PM »
A trick I use, is to put only the extensions that are absolutely necessary in/tce, and the rest that I need as occasion arises, I put in /tce/optional. Importantly, you need to take care of dependencies as well, so all those extensions that are in tce, must be there with their dependencies, and all the rest you can also move to /tce/optional.

I built a custom wbar config file and load this instead of the one that is contructed at every boot. I use the boot time code 'noicons' to disable the starting of default wbar. The custom wbar config stuff, I put in a separate home folder which I call /.mywbar. I copy all the extensions' icons to this folder. I write brief scripts that will load the extension on invoking the wbar icon press. The loading first checks to see if the extension is already loaded.

Code: [Select]
#!/bin/sh
[ ! -f /usr/local/tce.installed/OSS ] && tce-load -i /mnt/sda7/tce/optional/OSS.tczm
[ ! -f /usr/local/tce.installed/flash10 ] && tce-load -i /mnt/sda7/tce/optional/flash10.tcz
[ ! -f /usr/local/tce.installed/opera10 ] && tce-load -i /mnt/sda7/tce/optional/opera10.tcz
opera &

Here is a typical wbar config file entry:
Code: [Select]
i: /home/tc/.mywbar/opera10.png
t: Opera
c: exec /home/tc/.mywbar/opera.sh

(Note that the Opera example Flash does not work, I need to debug it.)

Using this, I have turbo-charged my boot, and in most cases, no noticeable penalty when invoking apps for the 1st time. There may be half a seconbd lag the fist time I call Opera which is a big app, but in most of the others there is almost nothing.

The stuff I have in /tce are jwm and the wireless network drivers, along with their dependencies.

To update extensions that are in /tce/optional, use jpeters' update extension script. Find it in
http://forum.tinycorelinux.net/index.php?topic=1698.0

Using the above, my boot times are essentially the same as a raw tc.
« Last Edit: December 05, 2009, 04:49:48 PM by jur »

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Re: ultrafast startup
« Reply #2 on: December 05, 2009, 04:51:47 PM »
Having them load only when used means the system must be able to detect when they are needed, but how would you communicate to the system you want to use them (ones without an icon or menu entry)?

For your situation, I'd suggest adding lines to /opt/bootlocal.sh to load the extensions. It is executed in the background as TC boots. With loop mounting there is no memory overhead, so you can load up to 255 extensions if desired and it won't slow down your boot.

Something like:

#!/bin/sh
# Wait for init to finish

wait $PPID
# Load extensions
for e in /mnt/sda1/extensions/*; do
su -c "tce-load -i $e" tc
done

if your extensions are stored in /mnt/sda1/extensions/.
« Last Edit: December 05, 2009, 05:25:00 PM by danielibarnes »

Offline frimical

  • Jr. Member
  • **
  • Posts: 75
Re: ultrafast startup
« Reply #3 on: December 05, 2009, 05:30:14 PM »
julianb said something I  was looking for from the start:

"so anyway, i'm interested in making the machine keep extensions sitting on disk, ready to load,
but have them only load when i open up an app that uses them."

 that TC doesn't do  it simply  yet (  especially the loading on  demand )

-download once,  use many times and on demand.

appbrowser loads/install but  doesn't launch an app.

What julianb is talking about I guess, is simply something like 'clicking on  the app's icon' will load-launch or just launch the app (as jur did in  his scripts)
and this is THE moment when the system reacts to the user demand; no guessing no detection.

 
 

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Re: ultrafast startup
« Reply #4 on: December 05, 2009, 05:40:20 PM »
Quote
so anyway, i'm interested in making the machine keep extensions sitting on disk, ready to load,
but have them only load when i open up an app that uses them.

Since no resources (except loop devices) are consumed by a loaded extension, there is no benefit to waiting until the app is used to load it. Loading them in the background at startup becomes the simplest solution.

Offline julianb

  • Newbie
  • *
  • Posts: 41
Re: ultrafast startup
« Reply #5 on: December 05, 2009, 05:51:06 PM »
danielibarnes, thanks for responding. When I first installed  the system, i didn't realize that it might be beneficial to AVOID using the "install" option in the application browser, for each app I wanted.

What i'm gathering from your post is taht you recommend following the "third mode of installation ( TCE/Mount ) " mentioned at the tinycore linux core concepts page ( http://www.tinycorelinux.com/concepts.html ) because that keeps your system capable of booting essentially equally quickly with extensions as with no extensions.

is that right?
julian

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: ultrafast startup
« Reply #6 on: December 05, 2009, 06:12:19 PM »
If you want to change to "mount" just edit or delete the file tcz2ram.lst in yout tce directory.
No need to re-download anything.
10+ Years Contributing to Linux Open Source Projects.

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Re: ultrafast startup
« Reply #7 on: December 05, 2009, 06:30:57 PM »
Quote
you recommend following the "third mode of installation ( TCE/Mount ) "
Yes. "TCE/Install" will consume memory when installed because extensions are copied to memory instead of mounted. This is really only useful if the extensions are stored on a medium which might need to be removed, like an CD-ROM or USB drive. If they are stored on a hard drive (like your SSD) then "TCE/Mount" is the best solution.

Quote
just edit or delete the file tcz2ram.lst in yout tce directory.
You'll want to rename your tce directory as well because the startup will automatically load all extensions in any top-level directory named tce.

Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: ultrafast startup
« Reply #8 on: December 05, 2009, 07:53:53 PM »
For your situation, I'd suggest adding lines to /opt/bootlocal.sh to load the extensions. It is executed in the background as TC boots. With loop mounting there is no memory overhead, so you can load up to 255 extensions if desired and it won't slow down your boot.
I'm not sure you are correct. If you have a lot of extensions especially big ones (say 10M typically, such as Thunderbird, Opera, wine-gl and so on, then there is a lot of symlinks to be made and it takes time. I know because I already tried something very similar to what you suggest. There is no getting away from that. It is either wait a long time till all the extensions are loaded at once, or spread that loading time around into small almost imperceptible little bits.

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Re: ultrafast startup
« Reply #9 on: December 05, 2009, 08:36:30 PM »
Quote
If you have a lot of extensions ... then there is a lot of symlinks to be made and it takes time.

Definitely true, but at least the system doesn't pause during startup to load extensions. If you find that it slows the system down even when running in the background, then you can try to nice the process:
su -c "nice tce-load -i $e" tc

Offline jur

  • Hero Member
  • *****
  • Posts: 863
    • cycling photo essays
Re: ultrafast startup
« Reply #10 on: December 05, 2009, 09:19:06 PM »
Nice - I'll have to look into that.

But running stuff in the background is no magic bullet. The processor still has to do the same work. Even if you have multiple processors there is still only one disk and only one data bus so it of necessity is a serial process. Putting stuff into the background merely means it will be processed when higher priority stuff is done.

The problem with booting is that all the stuff effectively has the same priority if you are waiting for access to the OS.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: ultrafast startup
« Reply #11 on: December 06, 2009, 05:58:17 AM »
About on demand loading, to create the icon/menu entry one would need to mount, read, and umount the extension, to copy the icon and other necessary info. This wouldn't really make sense, since doing the work at once is faster in total.
The only barriers that can stop you are the ones you create yourself.

Offline u54749

  • Jr. Member
  • **
  • Posts: 70
Re: ultrafast startup
« Reply #12 on: December 06, 2009, 09:00:39 AM »
It is possible to build hyper fast-booting hyper-performant setups using Tiny Core

This is the way I do it
1. first I create a loop-mountable ext2 filesystem, that will receive the resources from extensions I do not want to keep in RAM. Then I loopmount it in the core file system.
2. Then I start with temporarily installing all extensiont I want in RAM.
3. Next step is moving all files/directories that I do not want to be in RAM in the definitive system to the loopmount, leaving behind a symlink to the file.  For performance and debug  reasons I leave every file needed to boot to the desktop in RAM + ROX filer + Leafpad, so I can debug when there is something wrong with the loopmount during development.
4. Last step is to remaster all what is left in the root filesystem, including the symlinks to the loopmount, into a big initrd.
5. I do not compress the remaster result to tinycore.gz but leave the file uncompressed - this boots faster.  The uncompressed remastered initrd  is currently 65 M.

Of course I have a build script that does the hard work.  I can rebuild a system in a couple of minutes.

During boot, I loopmount (Read-Only) the file system with the resources in the bootlocal script.

Advantages
-  system has no work during boot time, everything is prepared
-  only one loopmount covering all apps (actually I have two loopmounts, the second one being persistent home)
-  boot is essentally one sequential read of a big file - very fast - you don't hear your disk heads rattling
-  extremely reponsive system as all essential files are pre-loaded in RAM
-  Basic Tinycore "engine" is untouched - you still have all the features, can use Appbrowser etc. etc.
-  System is pristine after boot as writes to the root file system are discarded after boot and the resources loopmount is Read-Only.

Disadvantages
-  more maintenance, especially tweaking and hand-optimizing the build script
-  only way to de-install an app is to rebuild the system
-  higher RAM consumption but this is a trade-off with reponsivity.  My system uses 105M when booted to the ROX desktop.  This is not a setup for memory-challenged systems (it's already very usable with 512 M, but 1G recommended)


Results
My setup consists of a 100% pure NTFS Windows XP system without any Linux partitions, booting TC 2.6 with GRUB4DOS.   For maximum performance it is best to defragment your Windows filesystem when your system is definitive.

My TC build has Xorg, SLIM logon manager (it's a multi-user setup), JWM, ROX Filer and pinboard, OSS sound, Leafpad, Xarchiver, Firefox browser with Flash, Thunderbird e-mail client, WINE, MPlayer, XMMS stuffed with codecs and a DVD playback module, SuperTux and a couple of other games, epdfview PDF Reader, galculator, gpicview applet to display photos and some stuff I probably forgot. So it's not really a "tiny" Tiny Core system.

My boot time from first kernel message to the logon screen is about 12 seconds on my seven year old 2.4 Ghz Pentium IV system with 512M RAM.  After logging on the desktop appears quasi-immediately.  Firefox starts in 3 seconds.  Most other apps start instananeously.  On my son's system (five year old - 1G RAM - single user setup) boot time is ten seconds.

It is my daily system since last Spring. I need to boot Windows only a couple of times per month. It is very stable but memory contention is a problem when loading extremely heavy Web pages (I have no swap file and my system has only 512M).  It works so well that even my wife has switched to it instead of Windows (I have given the system an XP-like theme for her).

Offline Lee

  • Hero Member
  • *****
  • Posts: 645
    • My Core wiki user page
Re: ultrafast startup
« Reply #13 on: December 06, 2009, 12:35:51 PM »
Of course I have a build script that does the hard work.

Hmmm... Any chance you could post that in the programming/scripting area?
32 bit core4.7.7, Xprogs, Xorg-7.6, wbar, jwm  |  - Testing -
PPR, data persistence through filetool.sh          |  32 bit core 8.0 alpha 1
USB Flash drive, one partition, ext2, grub4dos  | Otherwise similar

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: ultrafast startup
« Reply #14 on: December 06, 2009, 03:59:40 PM »
For fast boot why not just use "suspend" (hibernate) ?
big pc man