diskimage-builder/diskimage_builder/elements/zipl/finalise.d/50-zipl
Zhiguo Deng 271dc36f33 Add zipl element as s390x architecture bootloader
s390x architecture uses zipl as bootloader. When used in combination
with the vm element it replaces the existing bootloader element.
It's mandatory for s390x vm images.

Use cases
---------

* Allow users to create s390x images that run on nova with s390x
  libvirt/kvm backend
* Building nodepool images for s390x third party CI

Supported Distros
-----------------
The following listing shows all Distros that officially support
s390x and how those Distros are supported in DIB with this patch.

* SLES - not supported (SLES is not supported in DIB)
* RHEL - not suppoprted (RHEL is not supported as KVM guest on s390x,
                         therefore there's no rhel7 qcow image for s390x available
                         like it is for other archictectures)
* Ubuntu - supported

Ubuntu images can for example be built using the following commands:

  $ disk-image-create ubuntu-minimal zipl vm
  $ disk-image-create ubuntu-minimal zipl
  $ disk-image-create ubuntu zipl vm

Testing
-------

Cross architecture building of s390x images is not supported so far.

The plan is to set up a ThirdParty CI that builds the image for s390x and
provides the logs.

Co-Authored-By: Andreas Scheuring <andreas.scheuring@de.ibm.com>
Co-Authored-By: Holger Smolinsky <holger@smolinski.name>
Co-Authored-By: Zhiguo Deng <bjzgdeng@linux.vnet.ibm.com>
Co-Authored-By: Arne Recknagel <arne.recknagel@hotmail.com>

Closes-Bug: #1730641

Change-Id: I576e7edda68da12e97c60af38f457915efe7b934
2017-11-07 17:19:27 +01:00

70 lines
2 KiB
Bash
Executable file

#!/bin/bash
# Copyright (c) 2017 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
# Configure zipl.
if [ ${DIB_DEBUG_TRACE:-1} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# get the device containing the /boot directory
base_device=`df /boot --output=source | grep "/dev/*"`
cat > /lib/s390-tools/zipl_helper.loop <<EOF
#!/bin/bash
# This helper file is only required during image build if DIB is
# called without any partitioning configured (e.g. without the "vm"
# element). In that case the file system is put on a plain loop
# device.
#
# It's not required if
# * zipl is executed in in a running VM.
# * DIB is configured to create partitions (e.g. with the "vm"
# element).
#
# In both cases the disks block layout can be determined by
# the operating system shipped zipl_helper.device-mapper file.
echo "targetbase=${base_device}"
echo "targettype=scsi"
# DIB only supports 512 Byte disk sectors and blocks (not to confuse
# with filesystem block size which is 4k by default)
echo "targetblocksize=512"
# If no partitions are present, no MBR is present - the file system can start
# at block 0
echo "targetoffset=0"
EOF
chmod +x /lib/s390-tools/zipl_helper.loop
cat > /etc/zipl.conf <<EOF
# This has been modified by the cloud image build process
[defaultboot]
default=ubuntu
[ubuntu]
target = /boot
image = /boot/vmlinuz
ramdisk = /boot/initrd.img
parameters="root=LABEL=${DIB_ROOT_LABEL} $DIB_ZIPL_DEFAULT_CMDLINE"
EOF
zipl -V
rm -f /lib/s390-tools/zipl_helper.loop