Dummy USB re-compile for USB boot


Forum: DSL Tips and Tricks
Topic: Dummy USB re-compile for USB boot
started by: Juanito

Posted by Juanito on Nov. 29 2006,09:57
The idea behind this is to test whether you can re-compile your system (without changing anything) and then successfully reboot - if this works then you know that you are correctly set-up for the real thing. Thanks to ^thehatsrule^ for the help.

This was tested using DSL 3.0.1

Back-up your USB stick before proceeding at your own risk.


Materials required
-----------------
Download gcc-2.95.dsl, gcc1-with-libs.dsl & gnu-utils.dsl from the DSL repository
Download linux-2.4.26.tar.gz from "www.kernel.org" or mirror sites
Obtain knoppix 3.4 CD, download KNOPPIX_V3.4-2004-05-04-EN.iso from "http://www.pctips.pl/ftp/linux_342/Knoppix%203.4.html" or download kernelsource.dsl

Preparation
-----------
load required dsl packages:

# mydsl-load /path-to-file/gcc-2.95.dsl
# mydsl-load /path-to-file/gcc1-with-libs.dsl
# mydsl-load /path-to-file/gnu-utils.dsl

Create a directory for the kernel sources owned by user dsl:

# mkdir /usr/src
# chown dsl /usr/src

Copy the kernel sources to the new directory and un-pack them:

# cp /path-to-file/linux-2.4.26.tar.gz /usr/src/
# cd /usr/src
# tar -xzvf linux-2.4.26.tar.gz -C /usr/src
# rm linux-2.4.26.tar.gz

Copy the knoppix patch and configuration files from the CD or iso or dsl:

Either
# mkdir /ramdisk/image
# mount /path-to-file/KNOPPIX_V3.4-2004-05-04-EN.iso /ramdisk/image -t iso9660 -o loop,ro
# mkdir /ramdisk/unpack
# mount /ramdisk/image/KNOPPIX/KNOPPIX /ramdisk/unpack -t iso9660 -o ro,loop=/dev/cloop50
# cp /ramdisk/unpack/usr/src/* /usr/src
# cp /ramdisk/unpack/usr/src/linux-2.4.26/.* /usr/src
# umount /ramdisk/image
# umount /ramdisk/unpack
# rmdir /ramdisk/image
# rmdir /ramdisk/unpack

or
# mkdir /ramdisk/unpack
# mount /mnt/your-cd-drive/KNOPPIX/KNOPPIX /ramdisk/unpack -t iso9660 -o ro,loop=/dev/cloop50
# cp /ramdisk/unpack/usr/src/* /usr/src
# cp /ramdisk/unpack/usr/src/linux-2.4.26/.* /usr/src
# umount /ramdisk/unpack
# rmdir /ramdisk/unpack

or
# mkdir /ramdisk/unpack
# cp /path-to-file/kernelsource.dsl /ramdisk/unpack
# cd /ramdisk/unpack
# tar xvzf kernelsource.dsl
# cp /ramdisk/unpack/usr/src/* /usr/src
# cp /ramdisk/unpack/usr/src/linux-2.4.26/.* /usr/src
# rm -r /ramdisk/unpack

Apply the knoppix patch to the kernel sources:

# cd /usr/src
# patch -p1 -d linux-2.4.26 < knoppix-kernel.patch

Note that at this point in a "real re-compile" you would be ready to apply a kernel patch but, since this is a test, omit this step.

Recompile
---------
Prepare sources for re-compilation:

# cd /usr/src/linux-2.4.26
# make mrproper

Load the knoppix kernel configuration - note that at this point in a "real re-compile" you would be ready to change the kernel configuration, add modules, etc but, since this is a test, just load the knoppix kernel configuration and then save it.

# make menuconfig
Go to the last but one menu item <load an alternative configuration file>
tab to <select> and hit enter
replace text with "/usr/src/.config"
tab to <OK> and hit enter
tab to <exit> and hit enter (you will see "Do you wish to save your new kernel configuration?")
tab to <yes> and hit enter

Build dependencies and cleanup:

# make dep
# make clean

Build kernel boot image and copy to /boot:

# make bzImage
# make install

Note that at this point, if you had added additional loadable modules in a "real re-compile", you would issue the commands "make modules" and "make modules_install", but, since this is a test, omit this step.

Prepare to reboot
-----------------

copy kernel boot image to the root directory of your USB stick:

# cp /boot/vmlinuz-2.4.26 /path-to-boot-usb-root-dir/vmlinuz

make the boot image writeable (required for USB boot):

# rdev -R /path-to-boot-usb-root-dir/vmlinuz 0

Reboot
-------
Reboot as normal but when the first DSL screen appears requesting boot options, enter vmlinuz and hit enter.

If eveything went OK, DSL should now start up as usual.

If everything didn't go OK, then you could try deleting the boot option "quiet" from your syslinux.cfg file to get some clues as to what might have gone wrong...

Posted by ^thehatsrule^ on Nov. 29 2006,13:44
Your guide is pretty nicely written out :)

Just a couple comments...
Quote
Copy the kernel sources to the new directory and un-pack them:

# cp /path-to-file/linux-2.4.26.tar.gz /usr/src/
You don't necessarily need to use /usr/src/ here, esp. if that's on ramdisk or you don't have rw permissions (ie non-root user).  You'll only need to be a root user then when you `make install`

Code Sample
copy kernel boot image to the root directory of your USB stick:

# cp /boot/vmlinuz-2.4.26 /path-to-boot-usb-root-dir/vmlinuz

make the boot image writeable (required for USB boot):

# rdev -R /path-to-boot-usb-root-dir/vmlinuz 0
Did you try cp -a (archive mode)? It should preserve the permissions.

Posted by Juanito on Dec. 07 2006,05:05
Ref "Did you try cp -a (archive mode)? It should preserve the permissions"

As far as I know (and I could so easily be wrong), the vmlinuz file is created ro - in a standard HD boot, the vmlinuz file is opened ro, some file integrity checks performed and then it is set rw.

I got the rdev command from an example of a floppy boot (circa 1993...) which stated that vmlinuz needed to be rw in order to work - this could be something to do with the differences between a floppy/USB filesystem (FAT) and a HD filesystem (ext2), but then again /ramdisk is ext2.

Anyway in USB boot terms, rdev works, cp -a doesn't seem to work :)

Posted by ^thehatsrule^ on April 20 2007,16:03
More post-compilation steps discussed here: < http://damnsmalllinux.org/cgi-bin....28;st=0 >
Posted by curaga on April 20 2007,16:35
Many Knoppix sites state that the Knoppix patch is to be applied after make menuconfig because it modifies something menuconfig will overwrite....
Posted by WDef on April 21 2007,22:34
I've seen that too - there's an old rather messy web page about kernel compilation on Knoppix.  But I wonder if it's correct ...
Posted by kreon28 on May 19 2007,10:17
Well, I have HD-install and patched the kernel with supermount but after reboot all the modules are gone.
During compilation I did not change anything, only built to kernel supermount option.
I also did make modules and make modules_install
Now after reboot I got error: modprobe - module not found and my net, iso charset are gone...

p.s I did make modules install and kernel make install as root - if it could help

Posted by Juanito on May 19 2007,10:42
I don't know what the supermount module is called, but I guess the first thing to check would be if it was copied to somewhere in /lib/modules/2.4.26/

You could also try this after applying the supermount patch and making modules:
Code Sample
# make modules
# touch mymarker
# make modules_install
# find / -not -type 'd' -cnewer mymarker | grep -v "\/proc\/" | tee files
# beaver files

You should then see your module somewhere in the list of files.

Posted by kreon28 on May 19 2007,11:08
Quote (Juanito @ May 19 2007,06:42)
I don't know what the supermount module is called, but I guess the first thing to check would be if it was copied to somewhere in /lib/modules/2.4.26/

I checked /lib/modules/2.4.26 and it is almost empty. There are some modules but useless for me like wifi etc. Such thing as 8139too (my netcard) are gone....(The name I found in /etc/modules)
Supermount was built in kernel but it is not working.
Maybe I should compile it as module.
But what about the rest?

Posted by Juanito on May 19 2007,13:01
If you loaded the Knoppix/DSL .config file before compiling, then there should be plenty of modules in find /lib/modules/2.4/26 and its subdirectories.

If supermount can be compiled as a module, it might avoid needing to recompile the kernel image.

Edit
----
It's possible there might be a problem with the drmP.h file - see the modules section of the repository if you saw an error concerning this.

Posted by kreon28 on May 19 2007,15:55
Well - I don't know why but some of the kernel modules have to be built as a module and not to be built in kernel.
After recompiling the kernel and add e.g my network card as a module - it works.
But I don't know why I can't mount any dsl and uci files.
I got an error:
Code Sample

mydsl-load /home/dsl/openoffice-2.0.uci
/dev/cloop1: No such device or address


ps. I did not patch kernel with knoppix patch. Maybe that's why?

Posted by curaga on May 19 2007,17:22
No, cloop is it's own patch, which is added to knoppix kernels.
The sources can be gotten from < http://debian-knoppix.alioth.debian.org/sources/ >
the cloop 1.x versions are for 2.4 kernels, but building cloop requires debhelper...

Posted by kreon28 on May 19 2007,18:04
Quote (curaga @ May 19 2007,13:22)
the cloop 1.x versions are for 2.4 kernels, but building cloop requires debhelper...

So is there any place where I can read about building cloop?
Posted by Juanito on May 19 2007,18:51
I've recompiled the kernel image and built new modules and never had to worry about cloop, etc - admittedly with a frugal install - so I wonder why you have this error.

Are you sure you are using the correct .config file as a starting point?

Posted by kreon28 on May 19 2007,19:15
Quote (Juanito @ May 19 2007,14:51)
I've recompiled the kernel image and built new modules and never had to worry about cloop, etc - admittedly with a frugal install - so I wonder why you have this error.

Are you sure you are using the correct .config file as a starting point?

Well, honestly saying - no.
I haven't read anywhere about using config file as a starting point and missed that

Posted by ^thehatsrule^ on May 20 2007,01:50
Juanito: you can still use the same cloop module that's included in current DSL... I suppose the API's on those subroutines required for that didn't change (tested on 2.4.34 - though a warning will be displayed if the kernel version is not the same).  If you have a patch that modifies those subroutines is used, then you must recompile.  kreon28 is still using 2.4.26 but the supermount stuff might conflict?  Perhaps asking curaga would be best...

kreon28: My guess is that while you were compiling, you forgot to back up your modules dir first (I'm assuming you're using a traditional hd-install) so it could've been wiped out.  And, as already stated, you should use the same .config.  Note that cloop isn't part of the vanilla kernel tree.  Also, perhaps compiling the network module into the kernel took up too much memory (probably not though)?

Posted by Juanito on May 20 2007,03:48
Quote
I haven't read anywhere about using config file as a starting point and missed that

It's in the first post in this thread - see the "make menuconfig" part

Posted by kreon28 on May 20 2007,07:55
Quote (^thehatsrule^ @ May 19 2007,21:50)
My guess is that while you were compiling, you forgot to back up your modules dir first (I'm assuming you're using a traditional hd-install) so it could've been wiped out.  And, as already stated, you should use the same .config.

I guess...but I've got LiveCD with the cloop working. Any chances to extract it from that or taking .config file?
Posted by ^thehatsrule^ on May 20 2007,17:25
Ah yea.. you could take it from the cd and test it. (the .config has already been explained)
Posted by curaga on May 21 2007,14:34
Next time remember to give the kernel a different name, so you can boot the older one and keep it's modules (edit Makefile after "make menuconfig", the extraversion var is at the start.. Use like this:
Quote
extraversion="-kreon"
Now the kernel will be 2.4.26-kreon....)

I don't think supermount messes with module stuff, but it is safest to compile modules for the current kernel, then there won't be incompatibility or poor performance or errors....

Building cloop should be simple, but the dependencies are many.. It needs debhelper, which in turn needs many stuff.. It would be easier to compile in Knoppix 3.4 since it already has all the deps...

Posted by kreon28 on May 21 2007,19:58
Quote (curaga @ May 21 2007,10:34)
Next time remember to give the kernel a different name, so you can boot the older one and keep it's modules (edit Makefile after "make menuconfig", the extraversion var is at the start.. Use like this:
Quote
extraversion="-kreon"
Now the kernel will be 2.4.26-kreon....)

I don't think supermount messes with module stuff, but it is safest to compile modules for the current kernel, then there won't be incompatibility or poor performance or errors....

Building cloop should be simple, but the dependencies are many.. It needs debhelper, which in turn needs many stuff.. It would be easier to compile in Knoppix 3.4 since it already has all the deps...

Well, I tried something different.
I made another DSL HD-Install and compiled the kernel with fresh install.
I patched it with supermount, bootsplash and with kernelsource patch. I loaded the source config just to avoid problems with modules.
Unfortunately during compilation there was an error with DRI and 3dfx driver in it (I had to remove 3dfx driver - too bad I though because I have voodoo3 card)
After looooong compilation and rebooting ....the cloop error has appeared.
But..I took the cloop.o module from LiveCD DSL and put it in lib/modules/..../block/
then
Code Sample

modprobe cloop
and update-modules.
Then reboot again.
And success :) It worked!
p.s I haven't checked yet if DRI is working with my libglide3
I can't remember how to check it (xorg.log shows some crazy stuff - dri is loaded, and after that - unloaded...)

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.