zdrv evolution

I am continuing with a project that I have been gradually preparing the groundwork for.

Late last year, maybe September/October/November, I built an experimental Puppy with no zdrv file. Instead, all the modules were in the initial ramdisk. I then moved them all across to the main filesystem before the switch_root -- so they ended up getting saved in the pup_save file.

There were some stumbling blocks with that concept. One was the internal format of the zdrv file itself -- but a few months ago, in one of the 4.00 alphas, I redesigned the layout of the zdrv file, such that the firmware packages were kept in /lib/all-firmware directory. This was one stumbling block removed in my plan to return to putting the zdrv file inside the initial ramdisk (initramfs).

Right now I'm running another such experimental build. The modules are all inside 'initrd.gz', so it is mighty big -- 20MB. The modules are all compressed, so it doesn't get much bigger than that when loaded into RAM.

The big advantage is that the complete set of modules are present right at that first stage of booting, including the massive complete set of Sage's treasured SCSI drivers.

All the modules are moved to the main filesystem just before the switch_root, so they are all there when the boot scripts are running.

Another thing that has motivated me to return to this idea, is the automatic module probing performed by the kernel. The kernel probes, that is, calls modprobe, typically passing an alias, querying whether there is a matching module. The problem with this is that modprobe is only able to match an alias to a module if the module is already present. The fetching system from the zdrv file does not work in this situation.
Note, having all the dependency files does not help, the actual module has to be there for modprobe to match an alias to a module.

Having all modules present greatly simplifies the /sbin/modprobe script. Which I have done. The script still does the job it was mainly written for, to load the firmware of a module the first time it loads.

The question then is, what to do with the modules after that? We probably don't want to leave them taking up 18MB of RAM or pup_save space. This is what I have been contemplating. The experimental build I'm running right now has them sitting in the pup_save file.

There are various possibilities:

1. One somewhat inflexible solution is to simply delete them all after it has been decided all required modules are loaded. Not so good if you want to load another module after bootup.

1b. Same as above, except if a module is requested post-bootup, it can be registered as required in (say) /etc/MODULESCONFIG and you are then asked to reboot Puppy and the boot scripts will load it. A bit round-about but workable if such post-bootup modules are a rarity -- well it would be a once-off thing for each module anyway.

2. A boot script can create a zdrv file, at /mnt/home/zdrv_xxx.sfs, with all modules and firmware. The modprobe script can still fall back to fetching from a zdrv file. So, Puppy has easy access to the complete set of modules during bootup, and if any stray module is needed after bootup then modprobe will fetch it from the zdrv file in the normal way of previous puppies.

3. Just leave them all in the pup_save file. very convenient, and 18MB is not much space if you have a 1GB pup_save.

3b. Leave them in the pup_save, except delete a big chunk of them that are unlikely to be needed after bootup -- which would be the majority.

A note about something related: the idea of mounting and unmounting zdrv as a unionfs layer, on-the-fly. I have played with that, and found it very troublesome.
There is also a catch-22 situation with that -- in the initial ramdisk, if the zdrv file is on the boot media, you may have to load a special module (for example one of the many SCSI drivers) to access the drive, meaning they all have to be there in the initial ramdisk anyway.

Posted on 6 May 2008, 23:05


Comments:

Posted on 6 May 2008, 24:38 by Bosco Bearbank
Does this make sense?
I don't know about we, but I really don't want to leave them taking up 18MB of RAM or pup_save space. My preference, if possible, is option 2b: A boot script can create a zdrv file, at some user-unmountable place, with all modules and firmware...? This combines the best of 1 and 2 without needlessly taking up RAM or pup_save space.



Posted on 7 May 2008, 2:44 by kirk
zdrv
I like option 3, copy it to the pup_save file. 18MB is just not that much in a pup_save file and I doubt many users run RAM-only on low RAM computers. Simple solutions lead to less problems. How much does the big initrd effect your boot time?

A side note about copying the pup_4xx.sfs to ram. Unless the pup_4xx.sfs file is on CD or we have LOTS of RAM, probably should not copy to RAM. Really need the RAM to run programs.


Posted on 7 May 2008, 3:18 by pakt
Good idea :-)
Barry, thanks for sharing your ideas with us.

Option 3 sounds best to me - leave the modules in the pup_save file. This must be the simplest, most efficient solution.

The only gotcha would be when running in RAM - with no pup_save file the modules would have to stay in RAM. Otherwise, move the modules to pup_save directly after boot to free RAM.

Besides making Sage happy ;-), it would also solve a minor inconvenience I have. I have a PCMCIA USB adapter in my laptop replacing a defective USB port. My USB keyboard and mouse are connected to this adapter. Since the PCMCIA module is not in initrd.gz but in rc.modules which runs later on, my USB keyboard cannot be used to choose a pup_save file.

Your solution would also allow booting (USB harddisk, USB CD/DVD drive, Flash drive, etc) through a PCMCIA USB adapter ;-)


Posted on 7 May 2008, 5:12 by ANOSage
To scsi or not to scsi?
Sorry, Barry! Never intended it to become a cause celebre. Out of my depth with you guys , anyway; the only coding I understand is CGAT of DNA.


Posted on 7 May 2008, 8:09 by BarryK
Zdrv in nitramfs
Yes, having the complete set of modules in the initramfs means we can boot from anything, no worries about whether the correct module is there or not.

Someone mentioned to me awhile back that they had experimented with mounting the zdrv file in the initramfs -- that is, it's still a file. Who was that?

But that does take us back to that catch-22 situation, where the initramfs may need a special driver to access the boot device.

Yes, it takes longer to load initrd.gz. On the first boot, this is compensated by the modules loading quicker.


Posted on 7 May 2008, 8:32 by BarryK
Option 3c
There is another option, 3c.

Put the modules into the pup_save, but then progressively delete them as the pup_save gets full. The daemon that monitors free space can do that.

The free memory applet in the taskbar could even take them into account, calculate the free space, add on 18MB (or whatever), so the user won't even know that they are taking up space.

How about that for an interesting solution?

Then the init script in the initiramfs can restore them if there is sufficient free space in the pup_save!


Posted on 7 May 2008, 8:42 by jamesbond
Option 3d
3c is definitely interesting. How about doing it manually instead?

Leave them in pup_save. But give a shortcut / button / menu-item to:
1. delete all the excess modules from pup_save
2. restore the modules from initramfs (after reboot) back to pup_save if (1) is accidentally executed.

With this, those who doesn't like it can delete it (e.g. ppl running in RAM etc), those who prefer it will have it by default, and those who accidentally / mistakenly delete it can recover.

Complexity-wise, I think it's simpler this way than 3c, lesser chance of bugs doing something funny behind our back :)


Posted on 7 May 2008, 8:45 by urban soul
3c
Spending the whole day hacking pwireless.. these are welcome fundamental thoughts. Don't get away from treating the user as 'major' or 'root' or fully responsible or whatever. Foolproof design can be achieved nevertheless.
I vote for option 3b with a transition phase beginning with option 2... (because 3b needs some intelligent decisions which may become known later on)


Posted on 7 May 2008, 8:59 by crafty-one
zdrv in intramfs
@Barry
Needed to change my login to this blog - last one won't let me in..!!

zdrv -
I think 3c is workable - however I also think you need to possibly look at a script that tries to detect what type of motherboard/processor combo the user is loading Puppy into - then remove from those modules from zdrv that will never be used for the users' motherboard/processor combo..!

e.g.. my combo= VIA m/b with AMD Duron CPU..

so won't need to keep any INTEL or ARM or PPC - etc.. modules in the zdrv..!

Hopefully you get my drift with this..?

crafty.
.
.


Posted on 7 May 2008, 10:28 by CHLee
Boot from USB
I like option 3d.
I only worry booting time too long for USB boot, currently the initrd.gz plus vmlinuz size only 2MB.
My PC need about one minute to load this two files.
If the initrd.gz size 18MB, then need 9 minutes to load them. Can we speed up the loading time?
Thanks Barry!



Posted on 7 May 2008, 10:35 by CHLee
Boot from USB
Correction! The initrd.gz plus vmlinuz size are 3MB.
So,18MB initrd.gz need 6 minutes. Sorry!


Posted on 7 May 2008, 13:45 by GeorgR
Boot from USB
I like option 3a.
After first experiences we will see whether we need to optimize memory usage with 3b or 3d.

I like the chance for better hardware recognition and perhaps even speeding up overall booting time.
But I see the point of CHLee and the risk of long booting times on mainboards with bios handling usb ports only at slow speed even with usb 2.0 chipsets.

Lets test it!


Posted on 7 May 2008, 17:30 by Wosh
Basic Modules only
I am thinking a bit against main stream. 95% of the modules won't be needed if the PC has been configured. Only load the most important modules to establish an internet connection at first boot up. Load the rest via internet like the locales. For those without net-connection, provide a separate modules file, that can be downloaded separately or stay on CD. Why waste place in hard disk or ram?


Posted on 7 May 2008, 18:14 by JB
Combine it with pup_XXX.sfs
Maybe it would just be simpler to just combine the zdrv with the pup_XXX.sfs (like it used to be?) This way, the modules would be there when they are needed. If ram usage was a concern, the user could always select the "noram" option.


Posted on 7 May 2008, 18:36 by Raffy
rebuild initramfs
(Don't know initramfs :) but here's my 002c.

Over 90% of the time the basic kernel modules do the trick and load other drivers successfully. For this, we can keep the status quo.

However, for the exceptional cases, could the boot script that encounters a "no-driver" situation produce a report of what hardware are without ready drivers? Then the user can shop for supplemental init-PETs that contain his/her needed drivers?

Easy remastering and package creation are some of Puppy's strengths. Maybe we can apply this to distribute supplemental initramfs packages? For example, for rebuilding your initrd.gz?



Posted on 7 May 2008, 18:54 by tronkel
zdrv modules
How about making a list of the modules actually used and then merging them with the pup_xxx.sfs file on the fly, if requested by the user. Then the big zdrv.sfs can be deleted. Next time the system boots, it could look at the pup_XXX.sfs and use the same modules as previously.




Posted on 7 May 2008, 20:38 by HairyWill
removing the zdrv
I'm not sure how Tronkel's solution above would work. Squash files are readonly.

How about an option to rewrite initrd.gz after installing to reduce boot time. If the user choose to they could replace an installed initrd.gz with a version that only contained the drivers for the system they had installed on. It would also be possible for something like a pendrive install to have multiple copies of initrd.gz with different driver sets for different hardware.


Posted on 7 May 2008, 23:36 by pizzasgood
sfs
"editing" a .sfs file involves just building a new one. For zdrv_xxx.sfs that doesn't take very long, but it can be really slow for pup_xxx.sfs, and for large derivatives of Puppy it can take over fifteen minutes.

The other problem with modifying pup_xxx.sfs, or initrd.gz for that matter, is that if the user was booting from CD, he'd have to burn a new disk.

I do like the idea of an "optimize my initrd.gz" button though, for the people who have an hd or usb install, or don't mind burning another disk (or the same one if rw). But that's just a happy extra, not a solution, IMHO.


I like either jamesbond's idea of letting the user opt to delete/restore the unused modules, or else just keeping them all in the pup_save.2fs file. They're nice and simple, and don't involve things happening behind the user's back. The idea of having Puppy delete modules incrementally would lead to never being sure exactly what modules are installed, or how much space you really have (as though THAT problem needs to be expanded...).


Posted on 8 May 2008, 2:02 by tronkel
zdrv
Although sfs files are read-only, a script could mount and open them and then add the reduced module set. They could be held if necessary in a temporary pup_save file.

The script could then re-squash the amended sfs file. Something along the lines of MU's SFS-Combiner script. Then the temp files could be deleted

Since it could be somewhat slow operation, the user could have the choice to perform this task at will - by clicking on an option in the WizardWizard for example.


Posted on 8 May 2008, 2:42 by ANOSage
Whatever.....
...you guys decide, I hope it won't compromise the ability to swap HD installations around between different systems? Having access to the right drivers in the right place at the right time is mission critical to hobbyists and users.


Posted on 8 May 2008, 2:46 by ANOSage
Whatever.....
That's FULL installations, I mean, in which the required drivers have already been selected, but the pool is still available for re-detection of new HW.


Posted on 8 May 2008, 11:05 by SouthPaws
PC Profile
Hey Barry...Keep up the good work!

HairyWill touched upon something I've wondered about. Would it hinder or hurt for Puppy to yield two save files, one being specifically hardware related: a PC-Profile along with the pupsave...
All your data in the pupsave...could be used worry-free with multiple pcs...
Plug in your usb drive, choose your profile...home,work,friends pc,test pc,etc...and off you go!!!