Testing bleeding edge Ubuntu Server 19.10 s390x in qemu

Qemu seems to be doing much better job at getting the latest virtio supported Linux builds for Big Iron ( Linux One  – For IBM System z series mainframes ) then the Hercules/Hyperion simulator (Although the latter can still run non-Linux stuff ) so this is an updated howto one year later from my previous s390x article https://astr0baby.wordpress.com/2018/06/03/installing-ubuntu-18-04-server-s390x-in-hercules-mainframe-simulator/

There are a few Linux distributions that have the major support from IBM on the z series and those are RHEL, SLES and Ubuntu. RHEL-8 beta s390x kernel panics during initial installation boot. SLES and Ubuntu work really well so you can try both, but I have rather chosen the more open Ubuntu instead.

Short entry on how to get this up and running. We are again using the bleeding edge qemu from git and a trusty x64_86 Linux distribution (I use Mint 19.1) Make sure your system can support min of 4 GB RAM for the qemu guest and has a sufficient CPU power (I have Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz )

$ mkdir -p $HOME/KVM/s390x/Ubuntu
$ cd $HOME/KVM/s390x/Ubuntu
$ git clone https://github.com/qemu/qemu.git
$ cd qemu 
$ ./configure --target-list=s390x-softmmu
$ make 

Copy the compiled qemu-system-hppa binary to your working directory

$ cd $HOME/KVM/s390x/Ubuntu
$./qemu-system-s390x --version 
QEMU emulator version 3.1.93 (v4.0.0-rc3-4-g13c24edaa7-dirty)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers

Latest Ubuntu server builds are available here http://cdimage.ubuntu.com/ubuntu-server/daily/current/ so we will just wget the ISO

$ cd $HOME/KVM/s390x/Ubuntu 
$ mkdir iso 
$ wget http://cdimage.ubuntu.com/ubuntu-server/daily/current/eoan-server-s390x.iso
$ sudo su 
# mount -o loop eoan-server-s390x.iso ./iso 
# cd ./iso
# cat ubuntu.ins 
* Ubuntu for z Series (default kernel)
boot/kernel.ubuntu 0x00000000
boot/initrd.off 0x0001040c
boot/initrd.siz 0x00010414
boot/parmfile.ubuntu 0x00010480
boot/initrd.ubuntu 0x01000000

// Here we will copy from the mounted ISO the kernel and inintrd 

# cp boot/kernel.ubuntu ../
# cp boot/initrd.ubuntu ../ 

Next we prepare the virtual disk to which we will be installing the OS (6 GB is a minimum)

$ cd $HOME/KVM/s390x/Ubuntu
$ dd if=/dev/zero of=ubuntu.img bs=1024 count=6M

Next we make sure we have the “patched”  /etc/qemu-ifup  script in place

#! /bin/sh
# Script to bring a network (tap) device for qemu up.
# The idea is to add the tap device to the same bridge
# as we have default routing to.

# in order to be able to find brctl
PATH=$PATH:/sbin:/usr/sbin
ip=$(which ip)

if [ -n "$ip" ]; then
ip link set "$1" up
else
brctl=$(which brctl)
if [ ! "$ip" -o ! "$brctl" ]; then
echo "W: $0: not doing any bridge processing: neither ip nor brctl utility not found" >&2
exit 0
fi
ifconfig "$1" 0.0.0.0 up
fi

switch=$(ip route ls |
awk '/^default / {
for(i=0;i<NF;i++) { if ($i == "dev") { print $(i+1); next; } }
}'
)

switch=br0

# only add the interface to default-route bridge if we
# have such interface (with default route) and if that
# interface is actually a bridge.
# It is possible to have several default routes too
for br in $switch; do
if [ -d /sys/class/net/$br/bridge/. ]; then
if [ -n "$ip" ]; then
ip link set "$1" master "$br"
else
brctl addif $br "$1"
fi
exit # exit with status of the previous command
fi
done

echo "W: $0: no bridge for guest interface found" >&2

Next we need to make sure the qemu networking is setup (tun/tap and bridge)  Below is my network sharing script one needs to execute under root prior the emulation

#Setup tap and bridge 
tunctl -t tap0 -u user
ifconfig tap0 up
brctl addbr br0
brctl setfd br0 0
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 --table nat -A POSTROUTING --out-interface wlan0 -j MASQUERADE

We are going to use a virtual LAN 10.0.2.2/24  and assign our guest IP as 10.0.2.20 and gateway 10.0.2.2

And finally our install.sh script that will load the installation which needs to be executed under root

#!/bin/bash 
./qemu-system-s390x -machine s390-ccw-virtio -cpu max,zpci=on -serial telnet::4441,server -display none -m 4096 \
-net nic -net tap \
--cdrom eoan-server-s390x.iso \
-kernel kernel.ubuntu -initrd initrd.ubuntu \
-drive file=ubuntu.img,if=none,id=drive-virtio-disk0,format=raw,cache=none \
-device virtio-blk-ccw,devno=fe.0.0001,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1,scsi=off

We connect to the console via telnet (or any other capable terminal emulator) For the below screens Im using the cool-retro-terminal IBM 3278 profile to make it look more like a mainframe console.

 $ telnet localhost 4441

And if all went well the Ubuntu s390x will start to boot (The whole setup and installation can take about +- 2 hours)

Since the auto-configuration via DHCP will obviously fail, we will configure the network manually

Add 10.0.2.20 as IP

255.255.255.0 as netmask, and 10.0.2.2 as gateway IP

Nameserver (DNS) you can set 8.8.8.8 and setup a local hostname

Next we are asked for the remote SSH password for the installer session to which we will externally connect (so setup something)

And you get finally presented with login instructions to the remote installer (which we won’t really need since the installation will keep on going in the telnet console session)

Next we choose a language and location and the country mirror for the install-sets

The session will continue

After a few minutes (about 5) we get prompted to setup the users and passwords, confirm timezone ..

Next we will get to the disk setup stage, I just use entire disk

vda of course

And finally save all changes to that disk

Finally it will start the last stage of install (the longest one) so its time for tea or coffee since this will be the longest task of all (around 50 – 60  minutes)

Oh nice, we get a shiny new Linux Kernel 5.0.0 with the s390x current :)

Finally you might want to disable automatic updates (since this is lab stuff)

And just as I thought that we are done; another set of packages started to configure …

We get asked once more what other subset of packages we want, I chose none and will keep the core since we can always install the other stuff later

And yet more packages gets pulled from the net ..

And hopefully this is the last installation message

And now we need to wait a while for the whole thing to come down … be patient

To get to the end finally … (?)

Which will then kick to reboot

Congratulations, now you are running a mainframe Ubuntu 19.10 server on your laptop !

So we login and shutdown. Finally we prepare the following loader for the installation. Do not worry, now the system is quite snappy and the boot time on my system is 74 seconds !

#!/bin/bash
./qemu-system-s390x -machine s390-ccw-virtio -cpu max,zpci=on -serial telnet::4441,server -display none -m 4096 \
-net nic -net tap \
--cdrom eoan-server-s390x.iso \
-drive file=ubuntu.img,if=none,id=drive-virtio-disk0,format=raw,cache=none \
-device virtio-blk-ccw,devno=fe.0.0001,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1,scsi=off

 

Advertisement

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.

19 Responses to Testing bleeding edge Ubuntu Server 19.10 s390x in qemu

  1. Pingback: Ubuntu Server 19.10 s390x in qemu | Tech Booze

  2. fausap says:

    Hello, I have a problem with cdrom, during the installation it tries to dowload from internet.
    did you get this problem too?
    thanks

    • astr0baby says:

      What problem do you have ? It downloads debian packages which are not present on the minimal boot ISO obviously. Setup your network. Why are you paranoid that Ubuntu downloads from the Ubuntu repository (which is online) ?

      • fausap says:

        So this is a misunderstanding: I supposed everything was included in the ISO file. About the internet download, I have a problem with DNS resolution.. I can ping the google public dns (from the vm), but if I try to resolve a name, this doesn’t work. Anyway thanks for the info.

      • astr0baby says:

        Try to get your networking fixed first. Maybe I can help ?

  3. fausap says:

    Thanks, I want to do another test tonight and I’ll let you know the result. Really I cannot understand why only the name resolution is not working, but, for example, SSH is ok.

  4. fausap says:

    I found the problem. I noticed in a tcpdump session a message about a

    19:25:03.729373 IP 10.0.2.2 > 10.0.2.20: ICMP host 10.0.2.2 unreachable – admin prohibited, length 68

    and the problem is the firewall. Disabling the firewall everthing is ok. Now I have to configure the firewall properly and everything will be fine.

    thanks

  5. Janus Troelsen says:

    I got “W: /etc/qemu-ifup: no bridge for guest interface found” on start-up and network doesn’t seem to work…

  6. “W: ” is a string that your qemu-ifup script contains, probably means “Warning”. I used the scripts you provided, but I guess it can’t be correct since it doesn’t work. But I don’t know what’s wrong specifically.

    • astr0baby says:

      Got it :) the scripts are the ones Im using, you might have copied-pasted something wrong perhaps ?
      echo “W: $0: no bridge for guest interface found” >&2 means that you have no bridge0 setup

      Do you have all that is needed for this to work ?
      #Setup tap and bridge
      tunctl -t tap0 -u user
      ifconfig tap0 up
      brctl addbr br0
      brctl setfd br0 0
      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 –table nat -A POSTROUTING –out-interface wlan0 -j MASQUERADE

      Make sure you have the needed tools installed !

      sudo apt-get install uml-utilities
      sudo apt-get install bridge-utils

  7. Josh says:

    Hi, I have followed instructions, but have run inti bootloader error:
    qemu-system-s390x: Initialization of device s390-ipl failed: could not find stage1 bootloader. Any suggestions on how to fix it?

  8. intltechengr says:

    This worked great! I love your work! We share the same interests. I want to know if you can help me with two other projects? (I can send the files). One is the R/390, AIX’s Risc6000 version of z/OS ADCD 2.10, I wonder if the images can boot in Hercules, (so far no luck) with the config file. Two is IBM I OS 7.? on qemu, I don’t understand the instruction for Power Server installation, and IBM is like talking to a post (same response), ha ha… I am a IBM Partner World Member and they still give no info…???

    • astr0baby says:

      Well its a little shady when it comes to z/OS .. but I can confirm that the older z/OS 1.10 works in hyperion (hercules 4.x) – with networking and all .. I got it to run quite nicely on aarch64 PinebookPro , so it would run much faster on amd64 for sure.

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 )

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.