BruceTonge.Info

Altiris Linux PXE Kernel Update

by OKButton on Aug.20, 2009, under Altiris, Computing, HowTo, Linux

I have been working on producing a method to update the kernel within the altiris DS PXE. Here is my how to for compiling a new kernel and integrating it into bootwiz.

How to build a kernel

First of all I built a virtual machine on my desktop using vmware server. I then installed Debian 5 on it using the net install ISO to make a minimal install. I didn’t set it up with any roles i.e. desktop.
Once booted install SSH. Logging on as root and enter:

apt-get install ssh

After this point you can access the vm with putty and copy files to and from the vm with Winscp. You could install a samba server of ftp but I am not going to cover this here.

Now we need to install all the software needed to allow us to compile kernel sources. This is done using the following command:

apt-get install gcc-4.3 make wget bzip2 build-essential

These tools are as follows:

  • gcc-4.3 the GNU C Compiler
  • make the tool that runs the compile script
  • wget a tool to download files from http servers
  • bzip2 a compression tool
  • build-essentials tools and libraries used to compile

Once this is complete you have a system that is setup to compile kernels and driver modules.
We now need to get some files from the altiris system.
First we need the config file from the altiris Linux boot environment. The config file holds all the settings that were used to build the kernel that is used in the current build and is a good starting place for a new kernel.
To get it we need to send a job down to a machine to boot the Linux environment and run the following script:

cp /proc/config.gz /mnt/ds
gzip -d /mnt/ds/config.gz

This will copy the config file from the boot environment and put it into the root of your deployment share.

Now we also need the rootfs file. This file is like a virtual disk that holds the file system for the Linux been environment we may need to add some files to this or delete as needed. This file is located at \bootwiz\platforms\linux\x86\base\rootfs.

Now you have these files copy them over to the vm using Winscp and place them in the /root directory.

Now we need to get hold of the source code for the kernel that we want to use. If you just want to make new driver modules you need the same version as is used in your existing build (currently 2.6.18.8).
you can download the kernel from here you need a kernel that follows the name linux-2.6.**.*.tar.bz2 it should be about 40mb + in size. I have had good results with 2.6.24.7. Once you have selected the kernel you need right click on it and copy the link location. Then go to your putty and enter the following commands:

cd /usr/src
wget http://url to file

Instead of having the type “http://url to file your can right click and your copied location will be pasted in saving your figures. press enter and your kernel will be downloaded.
Once finished you need to extract the kernel from the archive as bellow:

tar -jxf linux-2.6.**.*.tar.bz2

This will extract the source to a folder of the same name.
To make life easier I would delete the archive now but its up to you.
Now we need to move the kernel source to a folder called linux this is for compatibility with making new drivers.

mv linux-2.6.**.*/ linux/

Now we copy the config file into the kernel source folder and make it hidden (this is how the compiler likes it).

cp /root/config /usr/src/linux/.config

Dont forget the . in .config.

Ok you now have the same conditions that the altiris developers had before they made there kernel. But we want more in our kernel so its time to make some changes.

cd linux
make menuconfig

Now you need to go to the bottom of the menu and select load config it should already be filled with .config so select ok.
Now you can go through the menu making the changes you require. you probably want to add support for a new chip set of SATA controller so have a look in the drivers section for what you require. I recommend compiling in your options a posed to making modules as this takes up space in the rootfs later on which has a fixed max size. So set your options to have a * a posed to a M if possible.
When finished exit out and save your config.
Now you can compile your kernel enter the following:

make
make modules_install

That’s it, watch the screen go flying by for a while and eventually it will finish if it ends with lines with ERROR: in them something has gone wrong. But hopefully this wont happen.
Your new kernel will be waiting for you in the folder /usr/src/linux/arch/x86/boot/ the kernel file is the one called bzImage.
Copy this out to a safe place and rename to “linux” all lower case.
Now we need to mount the rootfs file to make some changes.

mkdir /mnt/rootfs
mount -o loop /root/rootfs /mnt/rootfs
cd /mnt/rootfs

you are now inside the rootfs file. We now need to update the modules for the kernel:

cd lib/modules
rm -r 2.6.18.8  (or what ever folder is there)
cp -r /lib/modules/2.6.**.* /mnt/rootfs/lib/modules/2.6.**.*

You will probably also want to update your pci detection list. to do this enter:

update-pciids
cp /usr/share/misc/pci.ids /mnt/rootfs/usr/share/pci.ids
cp /usr/share/misc/pci.ids /mnt/rootfs/usr/local/share/pci.ids

You can make more changes if needed. When finished unmount the rootfs:

umount /mnt/rootfs

now copy your /root/rootfs file out to some ware safe.
Thats it a new kernel is compiled.
To use this kernel and root fs over right the linux and rootfs files in the \bootwiz\platforms\linux\x86\base\ folder with the onse you have just made.
Then make a new Linux PXE option or edit an existing one to force a rebuild. Using the regenerate images doesn’t work at least in 6.9 sp2 of the DS.
Now boot your kernel and see how it goes.
If you want to see your kernel boot and get a bit more debug info from it you can remove the quiet commend from the pxeconfig file located in \bootwiz\platforms\linux\x86\misc\ you also need to rebuild the image after this as above.

How to build a driver module

Now you have built a kernel you can build driver modules for that kernel (important)
when you have found your driver source files copy them and extract them to a folder I use /usr/scr/drivers/
then cd in to the driver directory you might find another folder in that named src if so cd into there as well. you should now be in a folder with files with extensions of .c and .h. enter the following commands:

make -C /usr/src/linux SUBDIRS=$(pwd) modules

You will now have a .ko file that was not there before this is your driver and it needs to be copied to your bootwiz folder to the following directory string.
“.\Boozwiz\platforms\Linux\x86\Drivers\CUSTOM\lib\modules\_ver_\kernel\opt\bdc”
You will need to make all those folder if they are not already there. Then recreate your PXE image as before.

:, , , ,

1 Comment for this entry

  • Cookie

    Looks like you got it working, well done :)

    if it ends with lines with ERROR: in them something has gone wrong. But hopefully this wont happen

    ROFL!

    If you follow standards user source codes for drivers in /usr/local/src/drivers ;)

Leave a Reply

You must be logged in to post a comment.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...