Rescue disk and multi boot system

If you work a lot with Linux systems and still set them up manually, you’re familiar with the problem of never having the right installation medium available. It also wouldn’t hurt to have a rescue system. Many people use live systems like grml, Kali or Damn Small Linux. But each of these systems has limitations, e.g. in some cases, an output is required on the serial console but is not supported by the corresponding system.

In this article, we’re going to give you a brief introduction to a system image which was developed in response to the frustration of having too many USB sticks for installations and live systems. The requirements were:

  • “Live” system for rescue
  • Installation medium for more commonly used distributions
  • Easily update to the latest image versions
  • No individual adjustments to the various systems

Approach

On a USB stick, we install an Arch Linux, which is booted up using Grub. In addition to the Arch Linux, Grub also offers us the option of booting up or installing other systems, too.

Grub and the “live” Arch Linux are displayed on the serial and graphic console. Where possible, this also goes for the other systems (which is not always possible, since, for example, a Kali Linux only starts up graphically).
The “live” Arch Linux is not structured like a real live system. Rather, it is still readable and writeable, because this lets it also to be used to install additional packages and updates.

The following is a current list of the systems which can be booted with this image:

  • “Live” Arch Linux (rescue system; read-write)
  • Arch Linux installer
  • Debian Jessie Netinstall
  • Debian Jessie Preseed install (with local preseed-file and Netinstall for the packages)
  • CentOS 7 installer
  • Kali Linux
  • Tails

Problems

The various systems expect different kernel parameters. This often used to cause problems, since systems could not be booted correctly or at all. What really helped was the Arch Linux Wiki, which has an article on this subject.

The various live systems are entered in the /etc/grub.d/40_custom. This is done manually. Depending on the system, either the kernel and the InitramFS are started directly or an ISO image loopback is first mounted. Here are two examples which present precisely these two cases:

  • CentOS 7 installer menuentry
    menuentry 'CentOS 7 Installer' {
    set kernel='/centos-7-vmlinuz'
    set initrdfile='/centos-7-initrd.gz'
    set append='console=ttyS0,115200n8 devfs=nomount'
    set ip='ip=192.168.1.10::192.168.1.1:255.255.255.0:host.example.com:enp1s0:off nameserver=8.8.8.8'
    set repo='repo=http://pkg.adfinis-sygroup.ch/centos/7/os/x86_64'
    set vnc='vnc vncpassword=password'
    linux $kernel $append $ip $repo $vnc --
    initrd $initrdfile
    }
  • Kali Linux installer menuentry
    menuentry 'Kali Linux 2016.2 amd64' {
    set isofile='/kali-linux-2016.2-amd64.iso'
    loopback loop $isofile
    linux (loop)/live/vmlinuz boot=live findiso=$isofile noconfig=sudo username=root hostname=kali
    initrd (loop)/live/initrd.img
    }

    The corresponding config options are described in the Grub documentation. Which parameters can be given to a kernel depends on the kernel version, for one, and on the distribution, on the other. A list of possible generic parameters can be found on kernel.org.

Image

The image is available to the public. There is no liability for up-to-dateness or any potential problems:

https://files.adfinis-sygroup.ch/rescue-multiboot/rescue-multiboot-latest.img.gz

After it is downloaded, the image can be transferred to a USB stick. The USB stick must have at least 8 GB storage space available. All the data on the USB stick are deleted. After the transfer to the USB stick, the partition is enlarged to the maximum. The string /dev/sd<X> absolutely must be replaced with the disk of the USB stick.

$ DISK="/dev/sd<X>"
$ gzip -cd rescue-multiboot-latest.img.gz | dd of="$DISK" bs=8M
$ printf "dnnnpn1n2048nnwn" | fdisk "$DISK"
$ e2fsck -f "${DISK}1"
$ resize2fs "${DISK}1"

Updates

The USB stick should be updated from time to time. In preparation, the “live” Arch Linux should be started up.

After starting, one network connection each should be established. The available interfaces can be displayed with ip addr show. The interface must first be started with ip link set $INTERFACE up. After that, an IP address is obtained, the easiest way being via ethernet by DHCP. Then just start dhcpcd $INTERFACE. After that, the system should have an IP address and can be updated with pacman -Syu.

More complex network connections can be established using netctl. Corresponding configuration examples can be found in the folder /etc/netctl/examples and have to be copied into /etc/netctl and then adjusted. You can start it with netctl start $CONFIGNAME. The different images for installing or live booting are in the root directory. They can be updated simply by downloading the latest versions of the ISOs, kernel and initrd images. There are no adjustments to the images or initrd images.