SUSE Support

Here When You Need Us

How to implement a rescue system on a SUSE Linux Enterprise Server 15

This document (000020555) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 15

Situation

The goal is to implement a rescue system that can be booted from the grub2 boot screen in case the system experiences problems. The rescue system is contained in the initial RAM disk.

Resolution

Please use the following script to generate the rescue system that will be available as additional bootloader entry.
Make sure there is enough space in the working directory that is used in the script and also in the /boot directory, the new initrd may take up to 300MB disk space. Ensure there is sufficient disk space in /boot available and before rolling this out into production, test this appropriately on a test system.

The procedure has been tested with a SLES 15 SP2 based media mounted on /mnt.

#!/bin/bash
WORKDIR=/var/tmp/rescue
FILE=/mnt/ARCHIVES.gz
GRUB_ROOT="(lvm/vgSYS-lvboot)"

mkdir -p $WORKDIR/media
mkdir -p $WORKDIR/initrd
mkdir -p $WORKDIR/grub.d

### Assumption is that SLE15 SP2 media is already mounted to /mnt
### If not mounted exit script

echo "Checking if SLES ISO is mounted"

if [ -f "$FILE" ]; then

### Preparing directory with contents of the rescue media

echo "Creating Directory with the rescue kit"

mkdir -p /$WORKDIR/media/boot/x86_64/loader
for i in \
content \
content.asc \
boot/x86_64/loader/initrd \
boot/x86_64/loader/linux \
boot/x86_64/rescue \
boot/x86_64/common \
boot/x86_64/config \
boot/x86_64/cracklib-dict-full.rpm \
media.1
do
    cp -av /mnt/$i $WORKDIR/media/$i
done

### Preparing initrd with rescue media in it

cp /mnt/boot/x86_64/loader/initrd /var/tmp/rescue/initrd/

cd /var/tmp/rescue/initrd/

echo "Creating initrd with rescue system"

lsinitrd --unpack initrd

rm initrd

cp -av $WORKDIR/media .

find . | cpio -o -H newc | xz --check=crc32 -c >> rinitrd

### Copying rescue kernel/initrd to /boot

echo "Copying rescue initrd/kernel to /boot"

mv rinitrd /boot

cp /mnt/boot/x86_64/loader/linux /boot/rlinux

### Writing Grub2 custom config to boot from rescue kit

echo "Creating grub custom config"

cat << EOF >> /etc/grub.d/40_custom

menuentry "SLES Rescue System" --class sles --class gnu-linux --class gnu --class os {
  load_video
  set gfxpayload=keep
  insmod gzio
  insmod part_msdos
  insmod btrfs
  insmod ext2
  insmod lvm

  set root=$GRUB_ROOT

  linux /rlinux rescue=1 install=file:/media keytable=de namescheme= splash=silent vga=0x318 panic=10 linemode=1 linuxrc.debug=4,trace
  initrd /rinitrd

}

EOF

echo "Writing new bootloader config"

grub2-mkconfig -o /boot/grub2/grub.cfg

else
    echo "SLE15 ISO not mounted, exiting"
fi


 

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000020555
  • Creation Date: 24-Jan-2022
  • Modified Date:24-Jan-2022
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.