Getting Started: Alpine Linux

Alpine Linux is a minimalistic Linux distribution, aiming for low resource usage and security. At the time of this writing, no image for LPAR installation exists. Therefore, the following instructions were tested under KVM on a host running Ubuntu 18.04. However, any recent Linux distribution with support for KVM on IBM Z should work.
These instructions assume that we are currently logged in as a regular user.

Install the packages required for the host to run KVM guests (this is specific to Ubuntu, and will vary for other distributions):
   $ sudo apt install qemu-system-s390x libvirt-bin
Next up, we define a sample guest. We will use a standard Alpine 3.8.0 RC8 image, available from
To do so, create a file alpine.xml with the following content:
   <domain type='kvm'>
     <memory unit='GiB'>1</memory>
       <type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
       <disk type='file' device='disk'>
         <driver name='qemu' type='qcow2' io='native' cache='none' iothread='1'/>
         <source file='/var/lib/libvirt/images/alpine.img'/>
         <target dev='vda' bus='virtio'/>
       <disk type='file' device='cdrom'>
         <source file='/var/lib/libvirt/images/alpine-standard-3.8.0_rc8-s390x.iso'/>
         <target dev='sda' bus='scsi'/>
         <boot order='1'/>
       <interface type='bridge'>
         <source bridge='virbr0'/>
         <model type='virtio'/>
       <console type='pty'>
         <target type='sclp'/>
       <memballoon model='none'/> 
Modify the highlighted parts as follows (in sequence):
  • image file: Image file backing the guest's virtual disk. Note that this file is defined in the next step, might grow, and sufficient free space should be available in the host filesystem. If you do not plan to store any data or perform a permanent install on a disk, you can omit the definition of this disk device.
  • ISO file: ISO image that also serves as the guest's filesystem.
  • Network link: Name of the host's bridge device, which was automatically setup when the add'l packets required for KVM were installed in the first step above.
Create the image file as indicated above:
   $ sudo qemu-img create -f qcow2 /var/lib/libvirt/images/alpine.img 8G
   Formatting '/var/lib/libvirt/images/rhel.img', fmt=qcow2 size=8589934592
   cluster_size=65536 lazy_refcounts=off refcount_bits=16
Add your user to group libvirt:
   $ sudo usermod -a -G libvirt <your_user>
This is required for domain management. Otherwise we would have to run all virsh comands as root using sudo.
Logoff and logon to have the change take effect.
Define the guest and start it (which will boot the ISO image), connecting to the console:
   $ virsh define alpine.xml
   $ virsh start --console alpine
In a matter of seconds you should be greeted by a login prompt like this:
Logon as root (no password required).
You can now either toy around with the live system, which will not persist any changes as it runs straight from the .iso image.
Or proceed to install Alpine on the virtual disk that we defined in the guest xml. To do so, run
   $ setup-alpine
and adjust the configuration to your liking.
At one point you will be asked to choose a disk to use - this is where you can specify the virtual disk/image file that we previously defined in the domain xml. To install Alpine on that disk, choose vda as the disk, and sys when asked how to use it, as illustrated in the following screenshot:
Once done with the entire dialog, Alpine asks to reboot - which would run the live system on the .iso image again. Therefore, we need to modify the guest definition to boot from its virtual disk (that we just installed to) rather than the ISO image. To do so, stop the guest and bring up its configuration in an editor by running
   $ virsh shutdown alpine
   $ virsh edit alpine
Either remove the entire <disk> element, or the indicated <boot> element only:
  <disk type='file' device='cdrom'>
    <source file='/var/lib/libvirt/images/alpine-standard-3.8.0_rc8-s390x.iso'/>
    <target dev='sda' bus='scsi'/>
    <boot order='1'/>
Finally, start the guest to boot from the virtual disk:

   $ virsh start --console alpine

For more information on how to configure Alpine Linux on IBM Z, see this page.

No comments:

Post a Comment