1. installation

yum -y install rear kbd lvm2 lsscsi

2. configuration

rear -d mkrescue
Relax-and-Recover 2.00 / Git
Using log file: /var/log/rear/rear-srv121.log
mkdir: created directory '/var/lib/rear/output'
Creating disk layout
Creating root filesystem layout
Copying logfile /var/log/rear/rear-srv121.log into initramfs as '/tmp/rear-srv121-partial-2017-12-08T23:13:13+0100.log'
Copying files and directories
Copying binaries and libraries
Copying kernel modules
Creating initramfs
Making ISO image
Wrote ISO image: /var/lib/rear/output/rear-srv121.iso (117M)

3. customization

mkdir -p /mnt/cdrom
mkdir -p /boot/rear
mount /var/lib/rear/output/rear-$(hostname -s).iso /mnt/cdrom/
unalias cp
cp -pv /mnt/cdrom/isolinux/kernel /boot/rear/
cp -pv /mnt/cdrom/isolinux/initrd.cgz /boot/rear/
umount /mnt/cdrom/
rm -fr /tmp/rear/ && mkdir /tmp/rear
cd /tmp/rear/
gunzip < /boot/rear/initrd.cgz | cpio -i
cp -pv /bin/lsscsi ./bin/
cp -pv /sbin/lvmetad ./sbin/
mkdir -p ./run/lvm
rm -fr ./boot/
rm -f ./etc/resolv.conf
rm -f ./root/.bash_history
rm -f ./etc/mac-addresses; touch ./etc/mac-addresses
rm -f ./etc/motd
rm -f ./etc/udev/rules.d/70-persistent-net.rules
rm -f ./etc/scripts/system-setup.d/58-start-dhclient.sh
rm -f ./etc/scripts/system-setup.d/60-network-devices.sh
rm -f ./etc/scripts/system-setup.d/62-routing.sh
sed -i 's/PS1=.*/PS1="(\$?)[\\u@\\h \\W]# "/' ./etc/bash.bashrc
sed -i 's/PS1=.*/PS1="(\$?)[\\u@\\h \\W]# "/' ./etc/profile
sed -i 's/UsePam.*/UsePam yes/' ./etc/ssh/sshd_config
touch ./etc/init.conf
echo "rear" > ./etc/HOSTNAME
echo "\S" > ./etc/issue
echo "Kernel \r on an \m" >> ./etc/issue
echo "# Module blacklists written by anaconda" > ./etc/modprobe.d/anaconda-blacklist.conf
echo "blacklist lpfc" >> ./etc/modprobe.d/anaconda-blacklist.conf
echo "blacklist mpt2sas" >> ./etc/modprobe.d/anaconda-blacklist.conf
echo "blacklist mpt3sas" >> ./etc/modprobe.d/anaconda-blacklist.conf
echo "blacklist qla2xxx" >> ./etc/modprobe.d/anaconda-blacklist.conf
find . | cpio -co | gzip > /boot/rear/initrd.cgz
date > /boot/rear/version
uname -r >> /boot/rear/version
chmod 644 /boot/rear/*
rm -fr /tmp/rear/

4. grub2

vi /etc/grub.d/40_custom
exec tail -n +3 $0
menuentry "Rescue (rear)" {
        set root="hd0,msdos1"
        set gfxpayload="1024x768x16, 1024x768"
        linux /rear/kernel root=/dev/ram0 rw selinux=0 biosdevname=0 net.ifnames=0 modprobe.blacklist=lpfc,qla2xxx,mpt2sas,mpt3sas
        initrd /rear/initrd.cgz
grub2-mkconfig -o /boot/grub2/grub.cfg

5. references