Installing Ubuntu 18.04 Server s390x in Hercules Mainframe simulator

Honestly I had very little interest in the IBM Z mainframe computers (zEC12 and up)  ( https://en.wikipedia.org/wiki/IBM_zEC12_(microprocessor)) but recently Mainframes caught my interest (Thanks to Soldier of FORTRAN  @mainframed767     https://mainframed767.tumblr.com/)

So lets see if we can run Mainframe Ubuntu on our laptop running X86_64 Linux distribution (Mint 18.3)  We will need a couple of things to prepare the environment before we move onto the simulations.

First lets download the Ubuntu installation media for the S390X architecture from here https://wiki.ubuntu.com/S390X#Downloads

First thing that is interesting is the statement that Ubuntu S390X cannot be run nor has any support in simulators like Hercules, which we will prove as wrong in next steps.

After filling up some registration details you will get to the download link or just grab directly from here http://cdimage.ubuntu.com/releases/18.04/release/ubuntu-18.04.2-server-s390x.iso

Next we will need to download and compile Hercules from https://github.com/hercules-390/hyperion You will need all the standard Linux build tools (build-essential, cmake and a few -dev packages that the cmake will report that its missing) All this is available on the standard Linux Mint 18.3 apt repositories.

Lest create a working environment for this in our home dir 
==========================================================

$ mkdir -p ~/MAINFRAME/
$ cd ~/MAINFRAME
$ git clone https://github.com/hercules-390/hyperion
$ cd hyperion
$ mkdir build
$ cd build
$ cmake ..

If all dependencies were met the following will be visible 
-------------------------------------------------------------------
Install prefix /usr/local
Executable directory bin
Library directory lib
Modules directory lib
Data Directory (http) /usr/local/share/Hercules
Source directory /home/user/MAINFRAME-STUFF/hyperion
Build directory /home/user/MAINFRAME-STUFF/hyperion/build
Generator: Unix Makefiles
Build command line: /usr/bin/make
C compiler version: GNU 5.4.0
C options (Release): -DHAVE_CONFIG_H -g3 -ggdb3 -DNDEBUG -O2 -march=native -minline-stringops-dynamically
C options (Debug): -DHAVE_CONFIG_H -g3 -ggdb3 -g
Install RPATH: $ORIGIN/../lib
Large file support: Using native large file support.
Hercules link libs: m;dl
Target processor: x86_64
-------------------------------------------------------------------

$ make 
$ sudo su 
# make install

Prepare the Mainframe directory structure for Ubuntu Hercules simulation

$ mkdir -p ~/MAINFRAME/ubuntu/dasd
$ cd ~/MAINFRAME/ubuntu/dasd
$ dasdinit -lfs -linux ubuntu.disk 3390-3 LIN120 (this creates 2.8 GB disk )

If you need more you can add additional value at the end of this command

$ dasdinit -lfs -linux ubuntu.disk 3390-3 LIN120 8000 (this creates 6.8 GB disk )

Alternatively, if you want to save disk space at the expense of some run-time overhead,
you can use zlib or bz2 compressed DASDs by using the -z or -bz2 arguments, respectively. For example,

$ dasdinit -z -lfs -linux ubuntu.disk 3390-3 LIN120

Next we need to prepare the Ubuntu s390x hercules.cnf configuration file

$ cd ~/MAINFRAME/ubuntu
$ vi hercules.cnf

I have observed that the Debian 9.4 hercules.cnf does not work with Ubuntu 18.04

CPUSERIAL 002623
CPUMODEL 2086
MAINSIZE 2048 
XPNDSIZE 2048
NUMCPU 2 
MAXCPU 2 
OSTAILOR LINUX
PANRATE SLOW
ARCHMODE ESAME

# Display Terminals

0700 3270
0701 3270


# dasd
0120 3390 ./dasd/ubuntu.disk
# network
0A00,0A01 CTCI -n /dev/net/tun -t 1500 192.168.11.100 192.168.11.4

So if you even try to use the above Hercules will complain when loading the Ubuntu config

So use the below configuration for your hercules.cnf

And enter the following configuration and save (This is important since the configuration sample used from Debian won’t work)  Adjust the number of CPUs below to match your system since I have used 4 CPUs here NUMCPU 4

ARCHMODE z/Arch
ALRF ENABLE
CCKD RA=2,RAQ=4,RAT=2,WR=2,GCINT=5,GCPARM=0,NOSTRESS=0,TRACE=0,FREEPEND=-1
CNSLPORT 3270
CONKPALV (3,1,10)
CPUMODEL 3090
CPUSERIAL 012345
DIAG8CMD ENABLE
ECPSVM YES
LOADPARM 0A95DB..
LPARNAME HERCULES
MAINSIZE 1024
MOUNTED_TAPE_REINIT DISALLOW
NUMCPU 4
OSTAILOR Z/OS
PANRATE 80
PGMPRDOS LICENSED
SHCMDOPT NODIAG8
SYSEPOCH 1900
TIMERINT 50
TZOFFSET +1400
YROFFSET 0

# Display Terminals

0700 3270
0701 3270

# dasd
0120 3390 ./dasd/ubuntu.disk

# network
0A00,0A01 CTCI -n /dev/net/tun -t 1500 192.168.11.100 192.168.11.4

I am using my network configuration (yours will probably be different so it should be adjusted to your needs) A little explanation of the above #network definition

192.168.11.100 will be the tun virtual Ubuntu x390x inside Hercules
192.168.11.4   is an IP address I have assigned to my wireless interface wlp9s0

And create a networking script to start prior the Hercules simulation so that we can use the network inside our simulator. I have called this network.sh

$ vi ~/MAINFRAME/ubuntu/network.sh

And enter the following.

#Depending on your system replace the following 
# enp0s25 = eth0 
# wlp9s0  = wlan0 
#Setup tap and bridge
tunctl -t tap0 -u user
ifconfig tap0 up
brctl addbr br0
brctl addif br0 enp0s25
brctl setfd br0 0
ifconfig enp0s25 10.0.2.1 up
ifconfig br0 10.0.2.2 netmask 255.255.255.0 broadcast 10.0.2.255 up
brctl addif br0 tap0
ifconfig tap0 0.0.0.0
sysctl net.ipv4.ip_forward=1
iptables -A FORWARD --in-interface enp0s25 -j ACCEPT
iptables --table nat -A POSTROUTING --out-interface wlp9s0 -j MASQUERADE

Execute the above network.sh script (you need root privs) before starting the Hercules simulator.

$ sudo su 
# ./network.sh

Mount the downloaded Ubuntu server iso

# mkdir -p /mnt/iso
# mnt -o loop /path/to/iso/ubuntu-18.04.2-server-s390x.iso /mnt/iso

And execute the Hercules Ubuntu simulator in

$ cd ~/MAINFRAME/ubuntu
$ sudo su
# hercules -f hercules.cnf

You should see something similar to this >

HHC00346I gcparm=0,nostress=0,freepend=-1,fsync=0,linuxnull=0,trace=0
HHC02204I conkpalv set to (3,1,10)
HHC02204I cpumodel set to 3090
HHC02204I cpuserial set to 012345
HHC02204I ecpsvm set to enabled, trap support enabled
HHC02204I loadparm set to 0A95DB..
HHC02204I lparname set to HERCULES
HHC17003I MAIN storage is 1G (mainsize); storage is not locked
HHC02204I mounted_tape_reinit set to disabled
HHC00109I Thread CPU Time is available; _POSIX_THREAD_CPUTIME=0
HHC00100I Thread id 00007f1d0fb69700, prio 15, name Processor CP01 started
HHC00811I Processor CP01: architecture mode z/Arch
HHC00109I Thread CPU Time is available; _POSIX_THREAD_CPUTIME=0
HHC00100I Thread id 00007f1d0fa68700, prio 15, name Processor CP02 started
HHC00811I Processor CP02: architecture mode z/Arch
HHC00109I Thread CPU Time is available; _POSIX_THREAD_CPUTIME=0
HHC00100I Thread id 00007f1d0f764700, prio 15, name Processor CP03 started
HHC00811I Processor CP03: architecture mode z/Arch
HHC02204I numcpu set to 4
HHC02204I panrate set to 80
HHC02204I shcmdopt set to Enabled NoDiag8
HHC02204I timerint set to 50
HHC02204I tzoffset set to +1400
HHC02204I yroffset set to 0
HHC00100I Thread id 00007f1d0f452700, prio 4, name Console connection started
HHC00414I 0:0120 CKD file ./dasd/ubuntu.disk: cyls 3339 heads 15 tracks 50085 trklen 56832
HHC01024I Waiting for console connections on port 3270
HHC00901I 0:0A00 CTCI: Interface tun0 type TUN opened
HHC00100I Thread id 00007f1d12623740, prio 0, name Control panel started
herc =====>

The herc =====> is important … this is our Mainframe prompt which we will now use inside Hercules to configure the Ubuntu Server.

Type the following to load the installer from our mounted iso.

herc =====> ipl /mnt/iso/ubuntu.ins

After approx 90 seconds the installation will load and we get to the first step of the S390X configuration – Network

What is very important here is to understand how to enter command line options to the herc prompt. Always use a “dot” . before any command in herc prompt. We want to use ctc (Channel to Channel connection here)

herc =====> .1  and  confirm hit ENTER

Now, you have to define the end-points for this virtual network interface: Select read ctc device:   herc =====> .1  and  confirm hit ENTER

Now choose the CTC write device herc =====> .2  and  confirm hit ENTER

We do not want to use DHCP so set herc =====> .2 and confirm hit ENTER

Enter the guest IP  herc =====> .192.168.11.100  and confirm hit ENTER

Next define netmask herc =====> .255.255.255.0 and confirm hit ENTER 

Next we define our gateway herc =====> .192.168.11.1 and confirm hit ENTER , please note that this is my actual gateway for wireless interface, so adjust accordingly

Define DNS servers , just use Google since we are ipforwarding and masquerading anyway  herc =====> .8.8.8.8 and confirm hit ENTER

Now we come to name our new S390x system herc =====> .ubuntu-framed and confirm hit ENTER , again use your imagination here.

Define domain name (does not really matter) herc =====> .virtual and confirm hit ENTER

Now comes the important part, defining the password for the installation session (yes you will login to the simulated S390X Ubuntu via ssh from your laptop and continue the setup from there) herc =====> .password and confirm hit ENTER , choose your own password.

Congratulations if you got this far, we are ready to start the actual installation !

Now ssh from your Linux machine to the simulated S390X Ubuntu and use the credentials you have defined before

$ ssh installer@192.168.11.100

And the familiar pink/purple Ubuntu Server NCURSES installer will pop-up. From now on its pretty much straight forward Ubuntu installation procedure. I am not going to cover the exact steps ( you can get all the juicy details from https://wiki.ubuntu.com/S390X/Installation%20In%20LPAR for example)

Don’t install any X stuff, just keep it basic (OpenSSH server and Basic Ubuntu Server) and be patient, the installation can take some time ( 2 to 3 hours on Core i5 8 GB RAM Panasonic Toughbook CF-53)

*You can switch between the Hercules modes via Escape key to see the CPU details

And finally we get to the end

And the main Hercules console will look like this when the system installer shuts down

So we are now ready to boot our new Ubuntu 18.04 S390X Mainframe system !

In the Hercules console hit ESCAPE and and hit “l” and “c” to boot the new system, to get  back to the console display hit ESCAPE again

Typical display in Hercules simulator

Once you see that the Secure Shell server has started , you can then ssh to your S390X server from Linux  (depends on what you defined your Ubuntu user do the following)

ssh user@192.168.11.100

Congratulations again ! You are running a Mainframe Ubuntu 18.04 Linux S390X via Hercules simulator !

I would like to thank the following sources of information that helped me through the above http://www.josefsipek.net/docs/s390-linux/hercules-s390.html

Also Moshix has a shot on the above :)

About astr0baby

Please run Adblock or similar... we have been told to do so since Carl Sagan wrote the Contact .
This entry was posted in Uncategorized. Bookmark the permalink.

8 Responses to Installing Ubuntu 18.04 Server s390x in Hercules Mainframe simulator

  1. Rick Henry says:

    Thank you for the clear instructions. My networking skill are not what they should be but I’ve been able to configure it to come up on Ubuntu running on VBOX. A bit slow but so far OK for my needs. We run zLinux at work, so it was a to be able to run it at home has been a great learning experience Again thank you

  2. Thank you, OpenSUSE has hercules as a easily-installed regular package; I will try this and report back. I have a OpenSUSE VM ready.

    • astr0baby says:

      Good luck ! It should be pretty straight forward to setup. Moshix made a video about installation here https://www.youtube.com/watch?v=QTBNt32ERWE (Ubuntu 18.04 ) but you can surely use some of his suggestions.

      • All good, thanks. A couple of observations:
        – you don’t really need a tap0 interface, hercules uses /dev/net/tun directly and creates a tun0 interface. only NAT forwarding is needed from the external lan (wlan0 for your panasonic notebook).
        – the OpenSUSE tumbleweed hercules package is for hercules-3; ubuntu-18 for s390x needs hercules-4, so I did have to build from latest hercules source
        – adding a “hercules.rc” file with one line saying “ipl 120” results in directly booting to ubuntu when hercules is started

        Here is the exciting first run :)

        Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-36-generic s390x)

        * Documentation: https://help.ubuntu.com
        * Management: https://landscape.canonical.com
        * Support: https://ubuntu.com/advantage

        System information as of Sat Oct 20 13:28:17 BST 2018

        System load: 1.71 Processes: 104
        Usage of /: 73.1% of 2.19GB Users logged in: 0
        Memory usage: 21% IP address for slca00: 10.100.0.23
        Swap usage: 0%

        0 packages can be updated.
        0 updates are security updates.

        Last login: Sat Oct 20 13:17:08 2018 from 10.100.0.22
        To run a command as administrator (user “root”), use “sudo “.
        See “man sudo_root” for details.

        ibmuser@ibm-s390:~$
        ibmuser@ibm-s390:~$ cat /proc/cpuinfo
        vendor_id : IBM/S390
        # processors : 2
        bogomips per cpu: 243902.00
        max thread id : 0
        features : esan3 zarch stfle msa ldisp eimm edat etf3eh highgprs sie
        facilities : 0 1 2 3 6 7 8 9 10 11 13 16 17 18 19 20 21 22 23 24 25 26 27 28 30 31 32 33 34 35 36 40 41 42 43 45 47 49 52 66 75 76 77
        cache0 : level=1 type=Data scope=Private size=512K line_size=256 associativity=-1
        cache1 : level=1 type=Instruction scope=Private size=512K line_size=256 associativity=-1
        processor 0: version = 00, identification = 012345, machine = 3090
        processor 1: version = 00, identification = 112345, machine = 3090
        ibmuser@ibm-s390:~$
        ibmuser@ibm-s390:~$
        ibmuser@ibm-s390:~$ uname -a
        Linux ibm-s390 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:13:24 UTC 2018 s390x s390x s390x GNU/Linux
        ibmuser@ibm-s390:~$

      • astr0baby says:

        great :) glad you got it running.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.