Building your own Redhat kernel - Version 3

Procedure for re-building a Redhat kernel.
Before you start, copy the file: config-s390.txt from my website as you will need it as a Linux file.
It reduces the build time to an hour.
Follow this procedure CAREFULLY. There is an explanation of each line of the procedure on the next page.
All lines that start with “$”or “#” signs are commands you must type. The “$” or “#” represents the Linux command-line
prompt string. You do NOT type the “$” or “#”. Be careful and watch for the underline character between words and periods
as part of a name (like: .config)
Before you begin, you will need to use FTP to get config-s390.txt from the "downloads" folder of my FTP server.
You
only need to do this once.
$ftp dforeman.cs.binghamton.edu
The userid is: LB-files
The password is: LB-pass
$ get config-s390.txt
(This saves the file in your root (default) directory (the one you are in when you login).
$ quit
The “quit” command exits from the FTP program. As an alternative to FTP, you can open a file and paste my
config-s390.txt file into it, but then you have to worry about line end characters which are different between Linux and
Windows.
Rename the file to: config-s390 with the command:
mv config-s390.txt config-s390
First Build (required lab)
$ cd /usr/src/redhat/SPECS
Note that the string “-2.6.18” appears twice – once
$ rpmbuild -bp kernel-2.6.spec
preceded by “kernel” and once preceded by
$ cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.s390x/
“linux”.
$ mv .config config-orig
$ cp ~/config-s390 .config
$ make
-j4
Be sure to include the “_” character
$ make
modules_install
$ make
install
The “make –j4” will take from ½ hour to 45 minutes to complete.
Now you have a working kernel. You should “shutdown now” and re- boot it. Then you can work on your kernel for the next
project.
To re-boot:
1. Close your Putty or GUI window
2. Log-in via Mocha (TN3270)
3. Type the following command (including the “#”):
#cp I cms
(yes, include the “#” sign!!!!!)
4. Type the “1” to power-up your Linux system (get s you to the simulated boot loader)
5. Wait for the green prompt for the Linux versions, which looks like this:
zIPL v1.5.3 interactive boot menu
0. default (linux)____________
1. 2.6.18-prep______________
2. linux_________________
_________________________________
Note: VM users please use '#cp vi vmsg <input>'
Please choose (default will boot in 15 seconds):_
6. NOW you can press F10, F11 or F12 to select the kernel you want. Wait for Linux to finish booting. You will have
to click the “Clear screen” button several times (after the screen fills up with data you will see “MORE…” in the
© D. J. Foreman 2014, all rights reserved.
Procedure for re-building a Redhat kernel.
bottom right corner of the screen). You can now close the Mocha window and go to Putty/SSH and login as root
in Terminal mode or use start the vncserver and use TightVNC for GUI mode (see my other documents for this).
7. Login to your Linux system as usual, type the following commands and take screen shot(s) showing the results of the
commands (you can use one screenshot to capture the results of both commands):
$cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.s390x/
$ ls -al
$ uname –a
The result should look like this: (take a screen shot of yours to send to the TA – the NNN will be YOUR TJW number)
[root@tjwNNN ~]# uname -a
Linux tjwNNN.cc.binghamton.edu 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:58 EDT 2008 s390x s390x s390x GNU/Linux.
[root@tjwNNN ~]# [root@tjw241 ~]# uname –a
8. $cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.s390x/
Get a listing of this directory. The last few lines should contain a file named vmlinux (this is one place to find your re-built
system). The results of the “ls -al” command will look like this (take a screenshot of it):
-rwxr-xr-x 1
root
root
32207738
Apr 3 11:08 .tmp_vmlinux3
-rw-r--r-- 1
root
root
643
Apr 3 11:08 ..tmp_vmlinux3.cmd
drwxr-xr-x 2
root
root
4096
Apr 3 09:52 usr
-rwxr-xr-x 1
root
root
32207738
Apr 3 11:09 vmlinux
-rw-r--r-- 1
root
root
631
Apr 3 11:09 .vmlinux.cmd
You have now finished the basic Linux build lab. Submit the screenshots. You can see your new kernel highlighted
turquoise in the next section, if you want to verify it by the file date. Type the “shutdown now” command, go to Mocha and
reboot. See the note below!!!!!
CAUTION: if your new system doesn’t work properly and you have to re-build it, the procedure will add duplicate entries
(they are 4 lines each) to the file named zipl.conf. You MUST use a linux text editor (like “nano”, “emacs” or “vi”) to
remove ONLY the duplicates. Zipl.conf is found in “/etc/zipl.conf” BEFORE you do the rebuild.
© D. J. Foreman 2014, all rights reserved.
Procedure for re-building a Redhat kernel.
START HERE for ALL builds AFTER 1st BUILD ABOVE. You never have to do the above code again!!!
When you re-boot from TN3270 (Mocha), remember to select your new kernel (F11), not the default one.
(When you log back in, you can skip the previous steps and just jump right to the source code.)
$cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.s390x/
Get a listing of this directory. The last few lines should contain a file named vmlinux (this is one place to find your re-built
system). The results of the “ls -al” command will look like this:
-rwxr-xr-x
1
root
root
32207738
Apr 3 11:08 .tmp_vmlinux3
-rw-r--r-1
root
root
643
Apr 3 11:08 ..tmp_vmlinux3.cmd
drwxr-xr-x
2
root
root
4096
Apr 3 09:52 usr
-rwxr-xr-x
1
root
root
32207738
Apr 3 11:09 vmlinux
-rw-r--r-1
root
root
631
Apr 3 11:09 .vmlinux.cmd
(Do your changes to the necessary files, then continue with the rest of the process below.)
Get back to the “build” directory:
$ cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.s390x/
$ make -j4
$ cp arch/s390/boot/image
/boot/vmlinuz-2.6.18-prep
NOTES: That’s a “z”, not an “x” in vmlinuz in the command above. You CANNOT substitute your initials or any other
identifier for "prep" above to identify your kernel.
$ zipl
(Note: that's the lowercase letter "L", at the end, not a digit 1)
(be sure to answer “y” (without the quotes) when/if you are prompted to overwrite)
CAUTION: if you ran "make_install", on the 1st build, more than once, it will add duplicate entries to the file named
zipl.conf. You MUST use a linux text editor (like “nano”, “emacs” or “vi”) to remove the duplicates. Zipl.conf is found in
“/etc/zipl.conf”
Now do the command “shutdown now”, just like you did for the original Linux build, wait for it to actually shutdown
(you will see a message like “sh#” and you will not be able to do anything in the terminal window – you may also get a
“software connection abort” message) then close the Putty/SSH window. Login to your CMS account (using
Mocha/3270) and enter the command:
#cp I cms
(don’t forget to INCLUDE THE “#” sign)
The purpose of this command is to simulate a “power off” on your virtual machine and cause a re-boot of the CMS
environment, needed to “power-on” your Linux virtual machine, so you can interact with the boot manager.
At the prompt, select the “1’ option to boot Linux. You will soon see this prompting menu: WAIT FOR IT!!!
zIPL v1.5.3 interactive boot menu
0. default (linux)___________
1. 2.6.18-prep_____________
2. linux_________________
_________________________________
Note: VM users please use '#cp vi vmsg <input>'
Please choose (default will boot in 15 seconds):_
NOW you can press F10, F11 or F12 to select the kernel you want. You can now close the Mocha window and go to
Putty/SSH and login as root in Terminal mode or use start the vncserver and use TightVNC for GUI mode (see my other
documents for this).
© D. J. Foreman 2014, all rights reserved.
Procedure for re-building a Redhat kernel.
The highlighted line from the ls command is the one that proves you got a good build. Once you get to the SECOND and
nth builds, the command “uname –a” should show this date and other details of your build.
Now test your user program.
_________________________________________________________________________________
© D. J. Foreman 2014, all rights reserved.
Procedure for re-building a Redhat kernel.
The following is just an explanation of the commands above:
$ cd /usr/src/redhat/SPECS
That puts us in the folder where the spec file exists.
$ rpmbuild -bp kernel-2.6.spec
This will do a build "preparation". It will not build the kernel, but will create the source files in the BUILD directory and
apply any necessary patches.
$ cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.s390x/
Now you are in the build directory that was just created.
$ mv .config config-orig
That saves the old .config file.
$ cp ~/config-s390 .config
Which copies your config-s390 file (you put it in your root folder) into the one that the build process will use.
$ make
-j4
I build with 4 threads. It takes advantage of the time that make needs to wait for disk access. When three threads are waiting,
one is actually doing work.
$ make modules_install
That puts the modules in the proper directories.
$ make
install
The make install above creates an initrd for bootup and will update the zipl.conf file.
We are ready to boot this kernel. But no changes have been done. It may be a good time to test it out.
Now to get ready to do your own kernel builds:
When you log back in, you can skip the previous steps and just jump right to your source code as follows:
$ cd
/usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.s390x/
(Here you can make any changes to your kernel source. Then run make –j4 to rebuild the kernel)
$ make
-j4
The above command will rebuild your kernel. After rebuilding the kernel, you need to copy it to the folder where the boot
loader will look for it. The next command does this.
$ cp
arch/s390/boot/image
/boot/vmlinuz-2.6.18-prep
The "cp" command above is the manual copying of the image to the /boot directory. The system is ready to boot.
© D. J. Foreman 2014, all rights reserved.
Procedure for re-building a Redhat kernel.
Note: it is useful to know about "tab completion". That is, the bash shell will fill in the rest of the word if it is unique in the
directory.
Here's what I mean:
$ cp ar <hit tab>
$ cp arch/
$ cp arch/s3 <hit tab again>
$ cp arch/s390/
Just need to type a few characters and hit tab, bash (the shell interpreter) will fill in the rest if it is unique. If it is not unique and
you hit tab again, bash will show you the files that are choices:
The following block of commands is an example of tab completion:
$ cp arch/s <hit tab twice>
s390/ sh/ sh64/ sparc/ sparc64/
$ zipl
The first make install updated the zipl.conf file. Now after copying the file:
$ cp arch/s390/boot/image /boot/vml <hit tab>
$ cp arch/s390/boot/image /boot/vmlinuz
$ cp arch/s390/boot/image /boot/vmlinuz- <hit tab>
$ cp arch/s390/boot/image /boot/vmlinuz-2.6.18$ cp arch/s390/boot/image /boot/vmlinuz-2.6.18-prep <hit enter>
that copies the file to where zipl knows to look for it.
Then run zipl
$ zipl
That will update the boot loader to see the kernel image.
© D. J. Foreman 2014, all rights reserved.