LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Looking for script to generate isolinux/initrd.img (http://www.linuxquestions.org/questions/slackware-14/looking-for-script-to-generate-isolinux-initrd-img-728506/)

Skaperen 05-26-2009 02:06 AM

Looking for script to generate isolinux/initrd.img
 
I'm looking for the script, or whatever setup is used, to generate the isolinux/initrd.img file. Something needs to be making decisions as to what files are put there, which contents, etc. Not everything in there is a replica of a regular system. Where do these files come from?

The particulars for making isolinux/isolinux.bin (the ISO boot loader) might also be useful.

wildwizard 05-26-2009 10:38 PM

Some of the stuff can be found :- (on a slackware mirror)

source/installer
source/a/pkgtools
source/a/syslinux

Making a bootable CD/DVD :-
http://syslinux.zytor.com/wiki/index.php/ISOLINUX

Look in /boot on an installed system for info on making an initrd

quanta 05-26-2009 11:25 PM

man mkinitrd?

Skaperen 05-26-2009 11:36 PM

I've got the construction process down. Been doing that for ages. I just need know what to put in the tree that does get built, and where these files come from. I took the distributed isolinux/initrd.img apart and compared that to the running system (matched versions). Some files were the same and some files were different. Well over 200 files in there did not even exist in the installed system, most of which didn't appear to be specific to an installer. Once I can build the file tree, I'm ready for a home run the rest of the way.

But I want to patch some things in there that are not necessarily just scripts. If only scripts need to be changed, I can just use the original isolinux/initrd.img as the "source" and apply a patch and rebuild. But I really want to be building this from 100% source. What's in there may involve separate builds of some components using different configuration options, different libraries available to the build, as well as a subset selection of installed files (this much might easy enough to reverse engineer since I have a list of files). Of course, "installing" in this case would be targeting a directory acting as the root for what will be collected into isolinux/initrd.img.

I can't rule out that Pat just builds it manually. I've built bootable ISOs manually myself, too.

Skaperen 05-26-2009 11:40 PM

Quote:

Originally Posted by quanta (Post 3553851)
man mkinitrd?

This is primarily for the installed system. It builds the initrd.img expected to run at system bootup. It might be usable, too, for the installer ISO bootup using the distributed image isolinux/initrd.img file. But what I need is where the files that go into it come from. They are not all the same as what is in the installed running system.

drmozes 05-27-2009 01:35 PM

Quote:

Originally Posted by Skaperen (Post 3553863)
This is primarily for the installed system. It builds the initrd.img expected to run at system bootup. It might be usable, too, for the installer ISO bootup using the distributed image isolinux/initrd.img file. But what I need is where the files that go into it come from. They are not all the same as what is in the installed running system.

The installer initrd is comprised of the installer scripts which live in /usr/lib/setup within the installer filesystem, various binaries (and Kernel modules) which are extracted from the Slackware binary tree at the time the initrd.img and the USB/PXE installers are created, plus a couple of bits which are compiled each time - such as busybox and dropbear.

There are many other tools which create the distributable tree, but aren't included because they're very specific to the environment in which they are run -- the installer build is one such tool which is why it's not in the source tree.

However, it's reasonably easy to update by hand if you want to make modifications to it.

cd isolinux
mkdir tmp
cd tmp
zcat ../initrd.img | cpio -div
make your changes
find . | cpio -o -H newc | gzip -9fv > ../initrd.img
cd ..
rm -rf tmp

Skaperen 05-27-2009 04:24 PM

Quote:

Originally Posted by drmozes (Post 3554570)
However, it's reasonably easy to update by hand if you want to make modifications to it.

Not so for the parts compiled from source code.

Quote:

Originally Posted by drmozes (Post 3554570)
cd isolinux
mkdir tmp
cd tmp
zcat ../initrd.img | cpio -div
make your changes
find . | cpio -o -H newc | gzip -9fv > ../initrd.img
cd ..
rm -rf tmp

I do know how to extract the tree and rebuild it back into the image. But that's not the whole picture.

I want to make changes that are patches to the source code that gets compiled to binary programs that become part of the root tree that is used to build isolinux/initrd.img. Many of these programs are different than in the installed system. That means some changes have been made. These changes may be simply different options on the ./configure script. Or they may be source level patches (or equivalent hacks). Or it could be as benign as being based on a previous version of Slackware.

I want to be able to reproduce that. If there are any patches to GPL programs, I have a legal right to those since the binary was distributed to me (e.g. a right to the complete source which includes all patches or hacks to it), just as you would have a legal right to the same (anything and everything that comprises any product that is in any part derived from any component licensed under GPL) for whatever I do, if I distribute a binary form (such as the initrd.img of it) to you.

In the end, I could simply ask Pat for it. But if this is already available somewhere I'm not seeing, I would not want to be wasting Pat's time by such asking.

Skaperen 05-27-2009 04:45 PM

I guess the source of confusion here is the different perspective people have for "script to generate". The popular perception seems to be that such a script would only be a minimal script, and that it would use input that is as close to the desired output as possible. For example, a "script to generate an ISO" would be thought of as something to take an already complete file tree of what files will be in the ISO image, and run mkisofs appropriately, possibly also making it bootable.

So I guess I wasn't clear in a poor choice of title. My perspective comes from building things all the way from source. Many people use SlackBuild scripts to do this, already, for at least some packages, if not all of them, for their target system. Or try Linux From Scratch. I've also worked for Timesys building embedded Linux systems.

Ideally, there would be a script to select file components for the tree that goes into the isolinux/initrd.img. It could select them from existing packages (e.g. .tgz or .txz packages that are installed with ROOT=the directory where the tree is being built). It could run special SlackBuild scripts to make modified versions of some packages (e.g. leave out stuff not needed for the installer to keep RAM usage lighter). It could then leave the file tree as the resulting product, or proceed to use mkinitrd or discrete commands to build isolinux/initrd.img as the final product.

So in summary, to me, a "script to generate" something will, where practical, build things from original pristine source (plus desired patches).

samac 05-27-2009 05:03 PM

As I read it what you are trying to do is rebuild a custom bootloader from source, but would like to modify a script to do it. However I could be wrong as your explanations are extremely convoluted.

It may be easier just to say what you would like to create and then it might be more apparent what you are looking for.

I have only modified the bootloader, rather than patch and build it, but as far as I remember it is only the stuff that wildwizard mentioned plus a kernel.
Quote:

Some of the stuff can be found :- (on a slackware mirror)

source/installer
source/a/pkgtools
source/a/syslinux

Making a bootable CD/DVD :-
http://syslinux.zytor.com/wiki/index.php/ISOLINUX

Look in /boot on an installed system for info on making an initrd
samac

Skaperen 05-28-2009 03:45 AM

Quote:

Originally Posted by samac (Post 3554719)
As I read it what you are trying to do is rebuild a custom bootloader from source, but would like to modify a script to do it. However I could be wrong as your explanations are extremely convoluted.

It may be easier just to say what you would like to create and then it might be more apparent what you are looking for.

I have only modified the bootloader, rather than patch and build it, but as far as I remember it is only the stuff that wildwizard mentioned plus a kernel.

It is not the bootloader (isolinux) that I am wanting to modify. I would expect if there is a script to build all this stuff, the isolinux bootloader package would be built by that script.

There is other stuff in there. Other binary programs. Maybe there is no master script to build it all. But maybe there are a bunch of SlackBuild scripts to build each package that goes into the file tree for that isolinux/initrd.img file. Those things that are different would be in there. The binary programs that are the same could just use the same SlackBuild scripts as the regular system.

Think about it this way. You want to build the isolinux/initrd.img file. But you don't have the file tree that goes into it, nor do you have the original isolinux/initrd.img file, either. You need to build everything from source. Some of it probably could be build at source level using regular SlackBuild scripts and the resulting package file installed with ROOT= to the directory the file tree is being built in. But some of the packages are different than a regular system. How do you build those?

In my case, I want to modify some stuff. At this point, what it is I want to modify is not important. I have not made final decisions, yet.

samac 05-28-2009 04:04 AM

Sorry I used the word bootloader incorrectly. I was using it to mean the whole of the initrd.img that booted Slackware. However you have had your answer. If you unpack that image file and look at it you will see it is just the items in the source/installer directory some scripts a kernel and not a awful lot else.

As you list LFS in your signature, I would assume that you are familiar with a toolchain, init scripts etc., if this is the case you should be able to figure your way round this fairly easily.

samac

Skaperen 05-28-2009 01:15 PM

Quote:

Originally Posted by samac (Post 3555171)
Sorry I used the word bootloader incorrectly. I was using it to mean the whole of the initrd.img that booted Slackware. However you have had your answer. If you unpack that image file and look at it you will see it is just the items in the source/installer directory some scripts a kernel and not a awful lot else.

There's a lot more than just the source/installer stuff in isolinux/initrd.img.

Quote:

Originally Posted by samac (Post 3555171)
As you list LFS in your signature, I would assume that you are familiar with a toolchain, init scripts etc., if this is the case you should be able to figure your way round this fairly easily.

Sure, once I know what modifications to the other source are made, I'd have no trouble building it. I could even build one now, and make it work. But it wouldn't necessarily be the same as, or work exactly like, what isolinux/initrd.img has.

Maybe some of the SlackBuild scripts are looking for an environment variable that says "we are building the installer, so do stuff different". I'll look around for that.

drmozes 05-28-2009 02:34 PM

Quote:

Originally Posted by Skaperen (Post 3555609)
There's a lot more than just the source/installer stuff in isolinux/initrd.img.

Sure, once I know what modifications to the other source are made, I'd have no trouble building it. I could even build one now, and make it work. But it wouldn't necessarily be the same as, or work exactly like, what isolinux/initrd.img has.

Maybe some of the SlackBuild scripts are looking for an environment variable that says "we are building the installer, so do stuff different". I'll look around for that.

As I said, the only parts compiled are dropbear and busybox. All other binaries are imported from the EXISTING .t?z packages in -current at the time the initrd.img is created. The packages are literally "installpkg -root" into a temporary dir, and the binaries and other bits pulled out.

Why do you think they are patched? Check for yourself the md5sums of any of the binaries against the md5sums in the .t?z packages. They will be identical.

If you want to modify the component binaries, then all you have to do is patch the source of the binary you want, and reinclude it into the initrd.img.

Skaperen 05-29-2009 10:18 AM

Quote:

Originally Posted by drmozes (Post 3555695)
As I said, the only parts compiled are dropbear and busybox. All other binaries are imported from the EXISTING .t?z packages in -current at the time the initrd.img is created. The packages are literally "installpkg -root" into a temporary dir, and the binaries and other bits pulled out.

Why do you think they are patched? Check for yourself the md5sums of any of the binaries against the md5sums in the .t?z packages. They will be identical.

I did that a few days ago. They were not identical. That's why I posted my question in the first place.

Quote:

Originally Posted by drmozes (Post 3555695)
If you want to modify the component binaries, then all you have to do is patch the source of the binary you want, and reinclude it into the initrd.img.

I can certainly make my own initrd with no problem. I wanted to start with the original one as a reference point and go from there.

drmozes 05-29-2009 05:49 PM

Quote:

Originally Posted by Skaperen (Post 3556569)
I did that a few days ago. They were not identical. That's why I posted my question in the first place.

Which in particular are not identical?


All times are GMT -5. The time now is 09:27 AM.