Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (2) </ [1] 2 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Boot sorting the KNOPPIX image, Making DSL boot faster with a mod toQEMU< Next Oldest | Next Newest >
Fordi Offline





Group: Members
Posts: 90
Joined: April 2004
Posted: Mar. 17 2005,07:10 QUOTE

I've been (scatterbrainedly) working on a new linux distro based on  DSL and Knoppix ideas, but I've found something that would definately work for DSL.

In my search for ways to optimize performance from a LiveCD, I developed a small mod to QEMU.

Essentially, it logs the sector-level reads from all emulated storage devices.

Code Sample
block.c
//Just after the #includes:
FILE* AccessLog;
//In raw_open:
int64_t size;
char logfile[1024];
sprintf(&logfile[0],"%s.log",filename);
AccessLog=fopen(&logfile[0],"wb");
fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
// raw_read:
int ret;
fprintf(AccessLog,"Disk read at sector %x\n", sector_num/4);
lseek(s->fd, sector_num * 512, SEEK_SET);
//finally, last line of raw_close:
fclose(AccessLog);


Case in point:
extract the DSL "KNOPPIX" from the DSL iso, along with linux24 and minirt24.gz

extract the internal ISO from KNOPPIX using cloop_extract_fs
extract the files within the ISO to a temporary directory.

start qemu with the following command line:
qemu -cdrom knoppix.iso -kernel linux24 -initrd minirt24.gz

Boot fully into X, and close QEMU.  You'll have an knoppix.iso.log that contains the sector-level reads of the CD.  rename this to access.log.
type "isoinfo -l -i knoppix.iso > isodata.txt"

put the following PHP script in a file and run it:
Code Sample
<?php
function isogettoc($isofile) {
$tocdata=file($isofile);
echo sizeof($tocdata)." entries found...";
$listmat="/Directory listing of ([^\s]*)/i";
$cwd="/";
$ret=Array();
for ($i=0; $i<sizeof($tocdata); $i++) {
$line=$tocdata[$i];
if (strtolower(substr($line,0,9))=="directory") {
$cwd=trim(substr($line,21));
continue;
}
if (strlen($line)>10) {
$size=trim(substr($line,25,15));
$loc=trim(substr($line,54,7));
$name=trim(substr($line,67,12));
if (($name!=".")&&($name!=".."))
$ret[$loc]=$cwd."$name";
}
}
echo "\n";
$ret[0]="!preboot";
return $ret;
}
function getOrder($access, $iso) {
$accessdata=file("access.log");
$id=isogettoc($iso);
$ct=0;
for ($i=0; $i<sizeof($accessdata); $i++) {
$a=$accessdata[$i];
if (strtolower(substr($a,5,4))=="read") {
$sector=hexdec(trim(substr($a,20)))*1;
$fd="";
$s=$sector;
while ($fd=="") {
if (!empty($id[$s]))
$fd=$id[$s];
else
$s--;
}
if ($fd!="") {
if ($fd=="!preboot") continue;
if (empty($GotitArray[$fd])) {
$GotitArray[$fd]=1;
echo str_replace("/", "\\", $fd." ".(9999-$ct)."\n");
$ct++;
}
}
}
}
}
$ret=getOrder("access.log", "isodata.txt");
?>


If you've done everything right, php should start spitting out the optimal order for the files on the CD.  Run it again, directing it into a file called "sortie.txt".
rebuild the ISO:
mkisofs -l -r -no-pad -hide-rr-moved -sort sortie.txt -o knoppix_optimized.iso knoppix_contents

and recompress with cloop_create_compressed_fs.  Replace the KNOPPIX in your DSL ISO with this file.  You now have a mostly optimized boot for DSL.

Mostly.  When you go to make your shiny new ISO, you should have the following boot order:
Code Sample

\BOOT\ISOLINUX\BOOT.CAT 9998
\BOOT\ISOLINUX\ISOLINUX.BIN 9997
\BOOT 9996
\BOOT\ISOLINUX 9995
\BOOT\ISOLINUX\ISOLINUX.CFG 9994
\BOOT\ISOLINUX\BOOT.MSG 9993
\BOOT\ISOLINUX\LOGO.16 9992
\BOOT\ISOLINUX\LINUX24 9991
\BOOT\ISOLINUX\MINIRT24.GZ 9990
\KNOPPIX 9989
\KNOPPIX\KNOPPIX 9988


You'll note that boot.cat and isolinux.bin are before their directories.  This is because they are directly referred to by the El Torito data.  Thus, they don't need to have the folders defined before them.

This order will ensure that any myDSL stuff (in the rot folder) won't slow down access of the Important stuff.  That should optimize the pre-kernel stuff so that getting to the linux screen and loading the kernel is nice and speedy.
Back to top
Profile PM 
lunatec Offline





Group: Members
Posts: 2
Joined: Mar. 2005
Posted: Mar. 18 2005,19:27 QUOTE

Is there an iso I can download?   I love the idea of not needed to reboot.
Paul
Back to top
Profile PM 
cbagger01 Offline





Group: Members
Posts: 4264
Joined: Oct. 2003
Posted: Mar. 18 2005,23:53 QUOTE

Sombody stop this guy before he figures out a way to launch the nukes from a wristwatch...

This is way outta my league here.

Fordi, it sounds like if you were bored you would probably keep yourself stimulated by rewriting QEMU to include direct access to Win32 hardware devices or something crazy like that.

Nice work, by the way.
Back to top
Profile PM 
lunatec Offline





Group: Members
Posts: 2
Joined: Mar. 2005
Posted: Mar. 19 2005,17:11 QUOTE

Slashdot had an srticle early in the week about a knoppix distro you can run on windows http://www.knoppix.net/forum/viewtopic.php?p=78849
It runs slow, but DSL should be much quicker
Back to top
Profile PM 
gunnix
Unregistered






Posted: Mar. 20 2005,09:25 QUOTE

nah, DSL is slow in emulation under windows as well. But what can you expect..?
Back to top
6 replies since Mar. 17 2005,07:10 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (2) </ [1] 2 >/
reply to topic new topic new poll
Quick Reply: Boot sorting the KNOPPIX image

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code