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)  ( but recently Mainframes caught my interest (Thanks to Soldier of FORTRAN  @mainframed767

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

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

Next we will need to download and compile Hercules from 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/
$ git clone
$ 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


# Display Terminals

0700 3270
0701 3270

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

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

CONKPALV (3,1,10)

# Display Terminals

0700 3270
0701 3270

# dasd
0120 3390 ./dasd/ubuntu.disk

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

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 will be the tun virtual Ubuntu x390x inside Hercules   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

$ vi ~/MAINFRAME/ubuntu/

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 up
ifconfig br0 netmask broadcast up
brctl addif br0 tap0
ifconfig tap0
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 script (you need root privs) before starting the Hercules simulator.

$ sudo su 
# ./

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 =====> .  and confirm hit ENTER

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

Next we define our gateway herc =====> . 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 =====> . 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@

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 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@

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

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.

18 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 (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:
        * Management:
        * Support:

        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:
        Swap usage: 0%

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

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

        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:~$ 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

      • astr0baby says:

        great :) glad you got it running.

  3. Hara Yama says:

    Is there any working example for installing rhel7(Redhat 7) s390x on using Hercules? Please help me. I tried many times but unable to install.

  4. James says:

    Please it will be your kind support if you share me scripts and also step you tried. Thank you in advance.

  5. astr0baby says:

    Hello James – the loader script is like this

    qemu-system-s390x -machine s390-ccw-virtio \
    -cpu max,zpci=on \
    -serial telnet::4441,server \
    -display none -m 4096 \
    -net nic -net user,hostfwd=tcp::2222-:22 \
    -hda disk.img

    Then you can just telnet to localhost 4441 to see the console

    You can use the pre-built qcow2 s390x CentOS images from here

    (Just replace the disk name to disk.img) and make sure you set a root password on the qcow2 image before you run it – this can be done with the following tool

    virt-customize -a –root-password password:YOURPASSWORD
    (on Ubuntu just apt-get install libguestfs-tools)

    Let me know if this helped
    Good Luck !

Leave a Reply

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

You are commenting using your 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.