AUTHOR:		John Gnew <john dot gnew at verizon dot net>

DATE:		2005-08-11

LICENSE:	Public Domain

SYNOPSIS:	How to install LFS on S/390 hardware

PRIMARY URL:	http://www.linuxfromscratch.org/hints/

DESCRIPTION:
This hint should help to install Linux from scratch version 6.0 on a 
IBM S/390 mainframe. I was able to take the 6.0 install guide, with some minor 
modifications and three additional packages, and complete the install.

This LFS system was installed on a 3390-3, my starter LFS 5.0 system was on a 3390-3.
I also had a 3390-9 to use for general storage of files.

At the compleation, I was able to IPL my LFS system as a VM guest.

I have not included the CTC configuration as this will vary from system to system.

Prior to compiling the kernel, I verified various kernl patches from IBM. It seems that 
all of the patches I came up with were already included in the kernel sources. I would 
recommend checking for patches prior to compiling different versions of the kernel.

The IBM site for obtaining various patches is located at:
(http://www-128.ibm.com/developerworks/linux/linux390/index.html)


PREREQUISITES: 
None

REQUIRED ADDITIONAL SOFTWARE:
mingetty-1.06 (version 1.07-1 in now available)
s390-tools-1.4.0

HINT: 
I followed the documentation for the LFS 6.0 install with the following exceptions:

The first addition was to upgrade the 2.4 kernel in LFS 5. GCC was already at 
level 3.3. I needed to be at the 2.6 level. This upgrade caused changes in the 
networking so it took a few attempts before I got everything back in place.

Install module-init-tools-3.0.tar.bz2
./configure --prefix=/
make moveold
make
make install
./generate-modprobe.conf /etc/modprobe.conf
copy the modprobe.devfs file into /etc.

Upgrade kernel to 2.6.8.1 (or any 2.6 kernel)
Create /sys dir and update fstab for sysfs entry
    I had problems with CTC network without /sys dir

Set up CTC with the commands similar to the following:

# device must be offline and should be by default
echo 0.0.2000,0.0.2001 > /sys/bus/ccwgroup/drivers/ctc/group
# echo 0 > /sys/bus/ccwgroup/drivers/ctc/0.0.2000/online
echo 0 > /sys/bus/ccwgroup/drivers/ctc/0.0.2000/protocol
echo 1 > /sys/bus/ccwgroup/drivers/ctc/0.0.2000/online

The following is the command to freate your file system:
mkfs.ext3 /dev/dasda1


linux-libc-headers needs to change the copy asm-i386 to asm-s390 
in chapter 5 and chapter 6

glibc 2.3.4
touch /tools/glibc-kernheaders/autoconf.h
And I initially received the following error:
In file included from sys/ustat.h:30,
                 from ../sysdeps/unix/sysv/linux/ustat.c:21:
../sysdeps/generic/bits/ustat.h:26: error: redefinition of `struct ustat'
make[2]: *** [/LFS60/sources/glibc-build/misc/ustat.o] Error 1
make[2]: Leaving directory `/LFS60/sources/glibc-2.3.4/misc'

To correct this problem I edited ./sysdeps/unix/sysv/linux/ustat.c by commenting 
#include <sys/ustat.h> and then adding #include <sys/statfs.h>.
The following SED command will accomplish the same.
    sed -i 's@sys/ustat.h@sys/statfs.h@' \
      '../glibc-2.3.4/sysdeps/unix/sysv/linux/ustat.c'
The problem was related to a file including an obsolete header file. 


Chapter 5 Locking in GLIBC
The next thing to do is to amend our GCC specs file so that it points to the new dynamic linker. 
A simple sed will accomplish this:

SPECFILE=/tools/lib/gcc-lib/*/*/specs &&
sed -e 's@ /lib/ld-linux.so.2@ /tools/lib/ld-linux.so.2@g' \
    $SPECFILE > tempspecfile &&
mv -f tempspecfile $SPECFILE &&
unset SPECFILE

Change to
sed -e 's@ /lib/ld.so.1@ /tools/lib/ld.so.1@g' \

There does not seem to be a ld-linux.so.2 in the /tools/lib.

In chapter 6 I had to remove the coreutils patch for uname. Had a problem with asm: 
Besides, patch is for intel not 390.
Gettext 0.14.3 check failed on msgfmt-6. This also failed on 0.14.4. 
I found a comment on problems with this test and AIX.

+#ifdef linux
+#define cpuid(in,a,b,c,d)\
+  asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (in));
+int has_sse( void );
+#endif
Besides, this patch is for intel type boxes not s390. Guess I’ll just have to
live with uname -1 and uname -p displaying unknown.

mingetty-1.06 (http://packages.qa.debian.org/m/mingetty.html)
mingetty is required for non serial consoles. This had to be installed with "make&&make install" 
which puts mingetty in /sbin.

The /etc/inittab needed the following added:

# S/390 enable console login for all runlevels
1:012356:respawn:/sbin/mingetty /dev/ttyS0

I also commented the following lines:

#1:2345:respawn:/sbin/agetty tty1 9600
#2:2345:respawn:/sbin/agetty tty2 9600
#3:2345:respawn:/sbin/agetty tty3 9600
#4:2345:respawn:/sbin/agetty tty4 9600
#5:2345:respawn:/sbin/agetty tty5 9600
#6:2345:respawn:/sbin/agetty tty6 9600

Customization
root:/usr/src# ln -s /usr/share/kbd/keymaps/i386/qwerty/defkeymap.map.gz /usr/sh
are/kbd/keymaps/defkeymap.map.gz

KERNEL GEN
For the install the kernel, the kernel is not under arch/i386/boot/BzImage but 
rather arch/s390/boot/image

s390-tools-1.4.0

Tools that were built as follows:
cd zipl
make
make install
cd ../fdasd
make
make install
cd ../dasdfmt
make
make install

PROBLEMS TODO

During boot the console will display messages that have ascii control characters.
This make it hard to read. Especialy during a disk check.
To correct this make sure bashrc has something similar to the following:
# Provides a colored /bin/ls command.  Used in conjunction with code in
# /etc/profile.

if [ $TERM = "dumb" ]; then
    alias ls='ls --color=never'
else
    alias ls='ls --color=auto'
fi

To prevent the console from displaying weird lines during a filesystem check,
change in /etc/rc.d/init.d/checkfs

#               fsck $options -a -A -C -T
                fsck $options -a -A -T


ACKNOWLEDGMENTS:


CHANGELOG:
[2004-10-21]
* Initial post
[2004-11-05]
* Corrected install for GCC-2.95.3
[2005-08-11]
* Changed install to represent LFS 6


