Quantcast
Channel: Astr0baby's not so random thoughts _____ rand() % 100;
Viewing all articles
Browse latest Browse all 183

Testing bleeding edge Ubuntu Server 19.10 s390x in qemu

$
0
0

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

 


Viewing all articles
Browse latest Browse all 183

Trending Articles