Procedure for re-building a Redhat kernel.
Before you start, copy the file: config-s390.txtfrom my website as you will need it as a Linux file.
It reduces the build time toan 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 “#” signsare commandsyou 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.
Renamethe file to: config-s390 with the command:
mv config-s390.txt config-s390
First Build (required lab)
$cd /usr/src/redhat/SPECS
$rpmbuild -bp kernel-2.6.spec
$cd /usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.s390x/
$mv .config config-orig
$cp ~/config-s390 .config
$ make -j4
$ 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:
- Close your Putty or GUI window
- Log-in via Mocha (TN3270)
- Type the following command (including the “#”):
#cp I cms
(yes, include the “#” sign!!!!!)
- Type the “1” to power-up your Linux system (get s you to the simulated boot loader)
- 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):_
- 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 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).
- 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 s390xs390x GNU/Linux.
[root@tjwNNN ~]# [root@tjw241 ~]#uname–a
- $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 root32207738Apr 3 11:08 .tmp_vmlinux3
-rw-r--r-- 1 root root643Apr 3 11:08 ..tmp_vmlinux3.cmd
drwxr-xr-x 2 root root4096Apr 3 09:52 usr
-rwxr-xr-x 1 root root32207738Apr 3 11:09 vmlinux
-rw-r--r-- 1 root root631Apr 3 11:09 .vmlinux.cmd
You have now finished the basic Linux build lab. Submit the screenshots. You can seeyour new kernel highlightedturquoise 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 alinux text editor (like “nano”, “emacs” or “vi”) to removeONLY the duplicates.Zipl.conf is found in “/etc/zipl.conf” BEFORE you do the rebuild.
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 root32207738Apr 3 11:08 .tmp_vmlinux3
-rw-r--r-- 1 root root643Apr 3 11:08 ..tmp_vmlinux3.cmd
drwxr-xr-x 2 root root4096Apr 3 09:52 usr
-rwxr-xr-x 1 root root32207738Apr 3 11:09vmlinux
-rw-r--r-- 1 root root631Apr 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 vmlinuzin the command above. You CANNOT substitute your initials or any other identifierfor "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 alinux 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) andenter 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).
The highlighted line from the ls commandis 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.
______
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 copiesyour 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 installabove 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.
Note: it is useful to know about "tab completion". That is, the bash shellwill fill in the rest of the word if it is unique in the directory.
Here's what I mean:
$cpar <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.