Repzilon
11-22-2003, 01:30 AM
I downloaded and booted PCLinuxOS 2004 preview 3 live CD and its hardware detection system is very fast! It is faster than my port of Knoppix auto-configuration on my main Mandrake system (For your information: I still work on it, but the project stalled for a month because of data destruction brought to you by Microsoft Windows 98).
I was curious. I needed to know why it is so fast. I found.
Auto-configuration in Knoppix and PCLinuxOS
Knoppix relies on a custom written Bash boot script, knoppix-autoconfig, which calls many other Bash scripts, like scanpartitions, rebuildfstab, hotplug-knoppix, mkxf86config, alsa_autoconfig and a libkudzu powered program, hwsetup. On the other hand, PCLinuxOS uses a Perl script, called hwdetect, placed in the initrd. It uses the HardDrake library Perl bindings, and does not call other scripts. Yes I know, there is also a custom linuxrc in the Knoppix initrd, but only to probe SCSI devices.
Why PCLinuxOS detection is fast?
Part of the answer is in Perl. Most of the scripts called by knoppix-autoconfig are used to generate configuration files. Reading and writing files is not Bash speciality, but Perl's. Also, Bash is a slow interpreter, it is written in its manual page. Moreover, Knoppix scripts often uses regular expressions via external programs (grep, awk) and the few support Bash provides built-in (case conditions). Regular expressions are built-in in Perl (and probably one of its most powerful and frightening features), hence faster.
Also, external calls cause performance hits and increase memory usage. hwdetect does not have this problem as it does not call external programs or scripts.
HardDrake? I'm not sure. I admit that I am not a big fan of it, even if I still use Mandrake 9.0 as my main Linux system. It's because of my disappointment about HardDrake that I started to port Knoppix auto-configuration after all.
Suggested ideas
I suggest to proceed by two parallel ways: a incremental rewrite of the current scripts in Perl and a complete rewrite. There is also the idea of using hwdetect, but it raises two problems. Is HardDrake available for Debian? Would Klaus Knopper be furious knowing his efforts going to garbage?
I prefer to work on the incremental rewrite path, because of the maintenance of the port. I would
Release Knoppix autoconfig port 0.2.5 .
merge scanpartions and rebuildfstab into rebuildfstab.pl
edit rebuildfstab.pl to detect removable drives (Installed distros port specific. At this moment, I use updfstab utility from Kudzu)
merge mkxf86config and ktbl2xkbd.sh into mkxf86config.pl (Port specific. ktbl2xkbd.sh converts keytable code in /etc/sysconfig/keyboard into a XFree86 Keyboard code, because lang= does not make sense for an installed distro)
convert alsa_autoconfig in Perl
convert my xfrepzi.sh to xfrepzi.pl (this is my XFree86 configuration utility)
move hardware detection handling parts from knoppix-autoconfig to a Perl script.
as I move along more code to the Perl script, merge the other Perl scripts in it.
Configuration files should be written to a ramdisk first, then copied to their final locations.
I need that Camel book fast!
I was curious. I needed to know why it is so fast. I found.
Auto-configuration in Knoppix and PCLinuxOS
Knoppix relies on a custom written Bash boot script, knoppix-autoconfig, which calls many other Bash scripts, like scanpartitions, rebuildfstab, hotplug-knoppix, mkxf86config, alsa_autoconfig and a libkudzu powered program, hwsetup. On the other hand, PCLinuxOS uses a Perl script, called hwdetect, placed in the initrd. It uses the HardDrake library Perl bindings, and does not call other scripts. Yes I know, there is also a custom linuxrc in the Knoppix initrd, but only to probe SCSI devices.
Why PCLinuxOS detection is fast?
Part of the answer is in Perl. Most of the scripts called by knoppix-autoconfig are used to generate configuration files. Reading and writing files is not Bash speciality, but Perl's. Also, Bash is a slow interpreter, it is written in its manual page. Moreover, Knoppix scripts often uses regular expressions via external programs (grep, awk) and the few support Bash provides built-in (case conditions). Regular expressions are built-in in Perl (and probably one of its most powerful and frightening features), hence faster.
Also, external calls cause performance hits and increase memory usage. hwdetect does not have this problem as it does not call external programs or scripts.
HardDrake? I'm not sure. I admit that I am not a big fan of it, even if I still use Mandrake 9.0 as my main Linux system. It's because of my disappointment about HardDrake that I started to port Knoppix auto-configuration after all.
Suggested ideas
I suggest to proceed by two parallel ways: a incremental rewrite of the current scripts in Perl and a complete rewrite. There is also the idea of using hwdetect, but it raises two problems. Is HardDrake available for Debian? Would Klaus Knopper be furious knowing his efforts going to garbage?
I prefer to work on the incremental rewrite path, because of the maintenance of the port. I would
Release Knoppix autoconfig port 0.2.5 .
merge scanpartions and rebuildfstab into rebuildfstab.pl
edit rebuildfstab.pl to detect removable drives (Installed distros port specific. At this moment, I use updfstab utility from Kudzu)
merge mkxf86config and ktbl2xkbd.sh into mkxf86config.pl (Port specific. ktbl2xkbd.sh converts keytable code in /etc/sysconfig/keyboard into a XFree86 Keyboard code, because lang= does not make sense for an installed distro)
convert alsa_autoconfig in Perl
convert my xfrepzi.sh to xfrepzi.pl (this is my XFree86 configuration utility)
move hardware detection handling parts from knoppix-autoconfig to a Perl script.
as I move along more code to the Perl script, merge the other Perl scripts in it.
Configuration files should be written to a ramdisk first, then copied to their final locations.
I need that Camel book fast!