Summary:
I have wanted to build a kickstart environment which hosted a "rescue CD" or LiveCD to allow you to boot over the network after you blew your stuff up and needed to repair a few things. Today I have worked through a method of doing so, with the help of the people who published a succinct script with the Red Hat Enterprise Virtualization Hypervisor. (the script will be at the bottom of this post - if I have somehow not followed the GPL, please let me know and I will correct whatever is necessary)
NOTE/Warning:
The boot will fail due the initrd being too large (645mb). I'm not sure how to proceed. This procedure worked for RHEVh, because it is quite a bit smaller. Hopefully I can report back with progress on this? :-$
Procedure:
download your LiveCD image to /export/isos/RESCUE/Fedora-16-i686-Live-Desktop.iso
# cd /var/tmp
# vi livecd-iso-to-pxeboot
(populate the file with the script shown below)
# chmod 754 ./livecd-iso-to-pxeboot
# ./livecd-iso-to-pxeboot /export/isos/RESCUE/Fedora-16-i686-Live-Desktop.iso
in my case, I would need to update
-- /tftpboot/msgs/boot.menu
to include RESCUE as an option
# SCRIPT - livecd-iso-to-pxeboot
I had discovered the following script contained on the RHEV 3 ISO -
rhevh-6.2-20111108.0:/LiveOS/livecd-iso-to-pxeboot
#!/bin/bash
# Convert a live CD iso so that it can be booted over the network
# using PXELINUX.
# Copyright 2008 Red Hat, Inc.
# Written by Richard W.M. Jones <rjones@redhat.com>
# Based on a script by Jeremy Katz <katzj@redhat.com>
# Based on original work by Chris Lalancette <clalance@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
export PATH=/sbin:/usr/sbin:$PATH
usage() {
echo "Usage: livecd-iso-to-pxeboot <isopath>"
exit 1
}
cleanup() {
[ -d "$CDMNT" ] && umount $CDMNT && rmdir $CDMNT
}
exitclean() {
echo "Cleaning up to exit..."
cleanup
exit 1
}
if [ $(id -u) != 0 ]; then
echo "You need to be root to run this script."
exit 1
fi
# Check pxelinux.0 exists.
if [ ! -f /usr/share/syslinux/pxelinux.0 -a ! -f /usr/lib/syslinux/pxelinux.0 ]; then
echo "Warning: pxelinux.0 not found."
echo "Make sure syslinux or pxelinux is installed on this system."
fi
while [ $# -gt 1 ]; do
case "$1" in
*) usage ;;
esac
shift
done
ISO="$1"
if [ -z "$ISO" -o ! -e "$ISO" ]; then
usage
fi
if [ -d tftpboot ]; then
echo "Subdirectory tftpboot exists already. I won't overwrite it."
echo "Delete the subdirectory before running."
exit 1
fi
mkdir tftpboot
# Mount the ISO.
# FIXME: would be better if we had better mountpoints
CDMNT=$(mktemp -d /media/cdtmp.XXXXXX)
mount -o loop "$ISO" $CDMNT || exitclean
trap exitclean SIGINT SIGTERM
# Does it look like an ISO?
if [ ! -d $CDMNT/isolinux -o ! -f $CDMNT/isolinux/initrd0.img ]; then
echo "The ISO image doesn't look like a LiveCD ISO image to me."
exitclean
fi
# Create a cpio archive of just the ISO and append it to the
# initrd image. The Linux kernel will do the right thing,
# aggregating both cpio archives (initrd + ISO) into a single
# filesystem.
ISOBASENAME=`basename "$ISO"`
ISODIRNAME=`dirname "$ISO"`
( cd "$ISODIRNAME" && echo "$ISOBASENAME" | cpio -H newc --quiet -L -o ) |
gzip -9 |
cat $CDMNT/isolinux/initrd0.img - > tftpboot/initrd0.img
# Kernel image.
cp $CDMNT/isolinux/vmlinuz0 tftpboot/vmlinuz0
# pxelinux bootloader.
if [ -f /usr/share/syslinux/pxelinux.0 ]; then
cp /usr/share/syslinux/pxelinux.0 tftpboot
elif [ -f /usr/lib/syslinux/pxelinux.0 ]; then
cp /usr/lib/syslinux/pxelinux.0 tftpboot
else
echo "Warning: You need to add pxelinux.0 to tftpboot/ subdirectory"
fi
# Get boot append line from original cd image.
if [ -f $CDMNT/isolinux/isolinux.cfg ]; then
APPEND=$(grep -m1 append $CDMNT/isolinux/isolinux.cfg | sed -e "s#CDLABEL=[^ ]*#/$ISOBASENAME#" -e "s/ *append *//")
fi
# pxelinux configuration.
mkdir tftpboot/pxelinux.cfg
cat > tftpboot/pxelinux.cfg/default <<EOF
DEFAULT pxeboot
TIMEOUT 20
PROMPT 0
LABEL pxeboot
KERNEL vmlinuz0
APPEND rootflags=loop $APPEND
ONERROR LOCALBOOT 0
EOF
# All done, clean up.
umount $CDMNT
rmdir $CDMNT
echo "Your pxeboot image is complete."
echo
echo "Copy tftpboot/ subdirectory to /tftpboot or a subdirectory of /tftpboot."
echo "Set up your DHCP, TFTP and PXE server to serve /tftpboot/.../pxeboot.0"
echo
echo "Note: The initrd image contains the whole CD ISO and is consequently"
echo "very large. You will notice when pxebooting that initrd can take a"
echo "long time to download. This is normal behaviour."
exit 0
# PXE "default" file
-- /tftpboot/pxelinux.cfg/default
default 0
prompt 4
menu title PXE Boot Menu
menu INCLUDE pxelinux.cfg/graphics.conf
MENU AUTOBOOT Starting Local System in # seconds
display msgs/boot.menu
# Boot from Hard Disk
label 0
localboot 1
LABEL RESCUE
KERNEL RESCUE/vmlinuz0
APPEND rootflags=loop initrd=RESCUE/initrd0.img root=live:/Fedora-16-i686-Live-Desktop.iso rootfstype=auto ro liveimg quiet rhgb rd.luks=0 rd.md=0 rd.dm=0
label RHEVH01
kernel RHEVH/vmlinuz0
IPAPPEND 2
APPEND initrd=RHEVH/initrd0.img rootflags=loop root=live:/rhevh-6.2-20111108.0.iso rootfstype=auto ro liveimg nomodeset check rootflags=ro crashkernel=512M-2G:64M,2G-:128M elevator=deadline processor.max_cstate=1 install quiet rd_NO_LVM rhgb rd_NO_LUKS rd_NO_MD rd_NO_DM
label RHEVH02
kernel RHEVH/vmlinuz0
append initrd=RHEVH/initrd0.img ramdisk=5939 dhcpclass=RHEVH noipv6 ks=nfs:10.10.31.200:/export/kickstart/Profiles/RHEVH02.ks ksdevice=eth0
# RHEL-6.2-x86_64
label 621
kernel RHEL-6.2-x86_64/vmlinuz
append initrd=RHEL-6.2-x86_64/initrd.img ramdisk=5939 dhcpclass=RHEL-6.2-x86_64 noipv6
label 622
kernel RHEL-6.2-x86_64/vmlinuz
append initrd=RHEL-6.2-x86_64/initrd.img ramdisk=5939 dhcpclass=RHEL-6.2-x86_64 noipv6 rescue ks
# PXE boot menu
-- /tftpboot/msgs/boot.menu
=================================================================
WARNING: Most of these choices | arch | Manual | Rescue |
will do fresh installations! | | Install | Install |
-----------------------------------------------------------------
RHEL-6.2 | x86_64 | 620 | 621 |
Fedora LiveCD | x86 | RESCUE |
=================================================================
Type in the hostname for automated install
Hosts: RHEVH01, RHEVH02
0. Boot from the Hard Drive
I have wanted to build a kickstart environment which hosted a "rescue CD" or LiveCD to allow you to boot over the network after you blew your stuff up and needed to repair a few things. Today I have worked through a method of doing so, with the help of the people who published a succinct script with the Red Hat Enterprise Virtualization Hypervisor. (the script will be at the bottom of this post - if I have somehow not followed the GPL, please let me know and I will correct whatever is necessary)
NOTE/Warning:
The boot will fail due the initrd being too large (645mb). I'm not sure how to proceed. This procedure worked for RHEVh, because it is quite a bit smaller. Hopefully I can report back with progress on this? :-$
Procedure:
download your LiveCD image to /export/isos/RESCUE/Fedora-16-i686-Live-Desktop.iso
# cd /var/tmp
# vi livecd-iso-to-pxeboot
(populate the file with the script shown below)
# chmod 754 ./livecd-iso-to-pxeboot
# ./livecd-iso-to-pxeboot /export/isos/RESCUE/Fedora-16-i686-Live-Desktop.iso
# mkdir /tftpboot/RESCUE; cd tftpboot; cp initrd0.img vmlinuz0 /tftpboot/RESCUE
# cd pxelinux.cfg
# cat default
DEFAULT pxeboot
TIMEOUT 20
PROMPT 0
LABEL pxeboot
KERNEL vmlinuz0
APPEND rootflags=loop initrd=initrd0.img root=live:/Fedora-16-i686-Live-Desktop.iso rootfstype=auto ro liveimg quiet rhgb rd.luks=0 rd.md=0 rd.dm=0
ONERROR LOCALBOOT 0
So - for this to work on my system (using /tftpboot/RESCUE) I would need to add the following to
-- /tftpboot/pxelinux.cfg/default - STANZA
LABEL RESCUE
KERNEL RESCUE/vmlinuz0
APPEND rootflags=loop initrd=RESCUE/initrd0.img root=live:/Fedora-16-i686-Live-Desktop.iso rootfstype=auto ro liveimg quiet rhgb rd.luks=0 rd.md=0 rd.dm=0
in my case, I would need to update
-- /tftpboot/msgs/boot.menu
to include RESCUE as an option
# SCRIPT - livecd-iso-to-pxeboot
I had discovered the following script contained on the RHEV 3 ISO -
rhevh-6.2-20111108.0:/LiveOS/livecd-iso-to-pxeboot
#!/bin/bash
# Convert a live CD iso so that it can be booted over the network
# using PXELINUX.
# Copyright 2008 Red Hat, Inc.
# Written by Richard W.M. Jones <rjones@redhat.com>
# Based on a script by Jeremy Katz <katzj@redhat.com>
# Based on original work by Chris Lalancette <clalance@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
export PATH=/sbin:/usr/sbin:$PATH
usage() {
echo "Usage: livecd-iso-to-pxeboot <isopath>"
exit 1
}
cleanup() {
[ -d "$CDMNT" ] && umount $CDMNT && rmdir $CDMNT
}
exitclean() {
echo "Cleaning up to exit..."
cleanup
exit 1
}
if [ $(id -u) != 0 ]; then
echo "You need to be root to run this script."
exit 1
fi
# Check pxelinux.0 exists.
if [ ! -f /usr/share/syslinux/pxelinux.0 -a ! -f /usr/lib/syslinux/pxelinux.0 ]; then
echo "Warning: pxelinux.0 not found."
echo "Make sure syslinux or pxelinux is installed on this system."
fi
while [ $# -gt 1 ]; do
case "$1" in
*) usage ;;
esac
shift
done
ISO="$1"
if [ -z "$ISO" -o ! -e "$ISO" ]; then
usage
fi
if [ -d tftpboot ]; then
echo "Subdirectory tftpboot exists already. I won't overwrite it."
echo "Delete the subdirectory before running."
exit 1
fi
mkdir tftpboot
# Mount the ISO.
# FIXME: would be better if we had better mountpoints
CDMNT=$(mktemp -d /media/cdtmp.XXXXXX)
mount -o loop "$ISO" $CDMNT || exitclean
trap exitclean SIGINT SIGTERM
# Does it look like an ISO?
if [ ! -d $CDMNT/isolinux -o ! -f $CDMNT/isolinux/initrd0.img ]; then
echo "The ISO image doesn't look like a LiveCD ISO image to me."
exitclean
fi
# Create a cpio archive of just the ISO and append it to the
# initrd image. The Linux kernel will do the right thing,
# aggregating both cpio archives (initrd + ISO) into a single
# filesystem.
ISOBASENAME=`basename "$ISO"`
ISODIRNAME=`dirname "$ISO"`
( cd "$ISODIRNAME" && echo "$ISOBASENAME" | cpio -H newc --quiet -L -o ) |
gzip -9 |
cat $CDMNT/isolinux/initrd0.img - > tftpboot/initrd0.img
# Kernel image.
cp $CDMNT/isolinux/vmlinuz0 tftpboot/vmlinuz0
# pxelinux bootloader.
if [ -f /usr/share/syslinux/pxelinux.0 ]; then
cp /usr/share/syslinux/pxelinux.0 tftpboot
elif [ -f /usr/lib/syslinux/pxelinux.0 ]; then
cp /usr/lib/syslinux/pxelinux.0 tftpboot
else
echo "Warning: You need to add pxelinux.0 to tftpboot/ subdirectory"
fi
# Get boot append line from original cd image.
if [ -f $CDMNT/isolinux/isolinux.cfg ]; then
APPEND=$(grep -m1 append $CDMNT/isolinux/isolinux.cfg | sed -e "s#CDLABEL=[^ ]*#/$ISOBASENAME#" -e "s/ *append *//")
fi
# pxelinux configuration.
mkdir tftpboot/pxelinux.cfg
cat > tftpboot/pxelinux.cfg/default <<EOF
DEFAULT pxeboot
TIMEOUT 20
PROMPT 0
LABEL pxeboot
KERNEL vmlinuz0
APPEND rootflags=loop $APPEND
ONERROR LOCALBOOT 0
EOF
# All done, clean up.
umount $CDMNT
rmdir $CDMNT
echo "Your pxeboot image is complete."
echo
echo "Copy tftpboot/ subdirectory to /tftpboot or a subdirectory of /tftpboot."
echo "Set up your DHCP, TFTP and PXE server to serve /tftpboot/.../pxeboot.0"
echo
echo "Note: The initrd image contains the whole CD ISO and is consequently"
echo "very large. You will notice when pxebooting that initrd can take a"
echo "long time to download. This is normal behaviour."
exit 0
# PXE "default" file
-- /tftpboot/pxelinux.cfg/default
default 0
prompt 4
menu title PXE Boot Menu
menu INCLUDE pxelinux.cfg/graphics.conf
MENU AUTOBOOT Starting Local System in # seconds
display msgs/boot.menu
# Boot from Hard Disk
label 0
localboot 1
LABEL RESCUE
KERNEL RESCUE/vmlinuz0
APPEND rootflags=loop initrd=RESCUE/initrd0.img root=live:/Fedora-16-i686-Live-Desktop.iso rootfstype=auto ro liveimg quiet rhgb rd.luks=0 rd.md=0 rd.dm=0
label RHEVH01
kernel RHEVH/vmlinuz0
IPAPPEND 2
APPEND initrd=RHEVH/initrd0.img rootflags=loop root=live:/rhevh-6.2-20111108.0.iso rootfstype=auto ro liveimg nomodeset check rootflags=ro crashkernel=512M-2G:64M,2G-:128M elevator=deadline processor.max_cstate=1 install quiet rd_NO_LVM rhgb rd_NO_LUKS rd_NO_MD rd_NO_DM
label RHEVH02
kernel RHEVH/vmlinuz0
append initrd=RHEVH/initrd0.img ramdisk=5939 dhcpclass=RHEVH noipv6 ks=nfs:10.10.31.200:/export/kickstart/Profiles/RHEVH02.ks ksdevice=eth0
# RHEL-6.2-x86_64
label 621
kernel RHEL-6.2-x86_64/vmlinuz
append initrd=RHEL-6.2-x86_64/initrd.img ramdisk=5939 dhcpclass=RHEL-6.2-x86_64 noipv6
label 622
kernel RHEL-6.2-x86_64/vmlinuz
append initrd=RHEL-6.2-x86_64/initrd.img ramdisk=5939 dhcpclass=RHEL-6.2-x86_64 noipv6 rescue ks
# PXE boot menu
-- /tftpboot/msgs/boot.menu
=================================================================
WARNING: Most of these choices | arch | Manual | Rescue |
will do fresh installations! | | Install | Install |
-----------------------------------------------------------------
RHEL-6.2 | x86_64 | 620 | 621 |
Fedora LiveCD | x86 | RESCUE |
=================================================================
Type in the hostname for automated install
Hosts: RHEVH01, RHEVH02
0. Boot from the Hard Drive
Hi, did you ever find an answer for this?
ReplyDeleteI'm looking for a way to load CentOS 7 liveCD over the network using PXE boot.
So far using this script I accomplished to load initrd, but right after it shows: Probing EDD (edd=off to disable) ... ok and it freezes.
Pxe Boot A Livecd Image >>>>> Download Now
ReplyDelete>>>>> Download Full
Pxe Boot A Livecd Image >>>>> Download LINK
>>>>> Download Now
Pxe Boot A Livecd Image >>>>> Download Full
>>>>> Download LINK ed