Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReaR PXE setup for RHEL/OEL 7 to boot with UEFI #2359

Closed
ravikumar-c opened this issue Apr 13, 2020 · 11 comments
Closed

ReaR PXE setup for RHEL/OEL 7 to boot with UEFI #2359

ravikumar-c opened this issue Apr 13, 2020 · 11 comments
Assignees
Milestone

Comments

@ravikumar-c
Copy link

ravikumar-c commented Apr 13, 2020

Hi

I have recovered the RHEL/OEL 7 ( UEFI ) server, just skipping the rear-node4 file.. Is there anyway to get correct rear-node4 with linuxefi ?

More details in below

  • ReaR version:
[root@node4 ~]# rear -V
Relax-and-Recover 2.5 / 2019-05-10
  • OS version
[root@node4 ~]# cat /etc/rear/os.conf
OS_VENDOR=RedHatEnterpriseServer
OS_VERSION=7.5
  • ReaR configuration files ("cat /etc/rear/site.conf" and/or "cat /etc/rear/local.conf"):
KERNEL_FILE="/boot/vmlinuz-4.1.12-112.16.4.el7uek.x86_64"
PROGS=( ${PROGS[@]} /usr/bin/dsmc /sbin/ifconfig /sbin/route /bin/netstat )
BACKUP_PROG_EXCLUDE=( "${BACKUP_PROG_EXCLUSE[@]}" '/media' '/var/tmp/' '/var/crash' '/var/spool/postfix' )
COPY_AS_IS=( ${COPY_AS_IS[@]} /etc/adsm /etc/ofed /etc/magic /usr/share/misc/magic /sbin/modprobe.ksplice.orig /usr/bin/kmod /bin/kmod )
TIMESYSC=NTP
KEPP_BUILD_DIR=false
OUTPUT=PXE
BACKUP=NETFS
NETFS_URL="nfs://192.168.10.200/var/lib/tftpboot/rear"
NETFS_SKEP_WARNING=1
NETFS_OPTIONS="nolock,vers=3"
NETFS_PREFIX="$(uname -n}"
OUTPUT_URL="${NETFS_URL}"
OUTPUT_OPTIONS="nolock,vers=3"
OUTPUT_PREFIX="$(uname -n}"
BACKUP_URL="${NETFS_URL}"
BACKUP_OPTIONS="nolock,vers=3"
BACKUP_PREFIX="$(uname -n}"
if [[ "${OUTPUT}" = "PXE" ]]; then
        BACKUP=NETFS
        BACKUP_URL="${NETFS_URL}"
        OUTPUT_URL="${NETFS_URL}"
        OUTPUT_PREFIX_PXE=""
        PXE_CREATE_LINKS=MAC
        PXE_REMOVE_OLD_LINKS="true"
        BACKUP_PROG=tar
        BACKUP_TYPE=full

fi
  • virtual machine.
[root@node4 ~]# dmidecode -t system | grep Manufacturer
        Manufacturer: VMware, Inc.
  • System architecture X86_64
[root@node4 ~]# uname -a
Linux node4.test.com 4.1.12-112.16.4.el7uek.x86_64 #2 SMP Mon Mar 12 23:57:12 PDT 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Firmware UEFI.
[root@node4 ~]# efibootmgr -v
BootCurrent: 0004
BootOrder: 0004,0000,0001,0002,0003
Boot0000* EFI VMware Virtual SCSI Hard Drive (0.0)      PciRoot(0x0)/Pci(0x10,0x0)/SCSI(0,0)
Boot0001* EFI VMware Virtual IDE CDROM Drive (IDE 1:0)  PciRoot(0x0)/Pci(0x7,0x1)/Ata(1,0,0)
Boot0002* EFI Network   PciRoot(0x0)/Pci(0x11,0x0)/Pci(0x1,0x0)/MAC(000c29004b94,0)
Boot0003* EFI Internal Shell (Unsupported option)       MemoryMapped(11,0xef8b018,0xf3f6017)/FvFile(c57ad6b7-0515-40a8-9d21-551652854e37)
Boot0004* Oracle Linux  HD(1,GPT,2a4b777a-ec8d-4bb0-be61-aab5077d025d,0x800,0x64000)/File(\EFI\redhat\shimx64.efi)
  • Storage layout
[root@node4 ~]# lsblk
NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                 8:0    0   30G  0 disk
├─sda1              8:1    0  200M  0 part /boot/efi
├─sda2              8:2    0    1G  0 part /boot
└─sda3              8:3    0 28.8G  0 part
  ├─ol_node4-root 249:0    0 26.8G  0 lvm  /
  └─ol_node4-swap 249:1    0    2G  0 lvm  [SWAP]
sr0                11:0    1 1024M  0 rom
  • Recover mkbackup created the file rear-node4 suitable for BIOS not UEFI
[root@PXE-BOOT node4]# cat rear-node4
    default hd
prompt 1
timeout 300

label hd
localboot -1
say ENTER - boot local hard disk
say --------------------------------------------------------------------------------
    display /node4.message
    say ----------------------------------------------------------
    say rear = disaster recover this system with Relax-and-Recover
    label rear
        kernel /node4.kernel
        append initrd=/node4.initrd.cgz root=/dev/ram0 vga=normal rw selinux=0 console=ttyS0,9600 console=tty0
  • Workaround:
    i have create the file grub.cfg and calling the kernel and initrd.cgz files
[root@PXE-BOOT /]# cat /var/lib/tftpboot/efi.x64/grub.cfg
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
set timeout=30
insmod png

#### Menu Start

menuentry 'Boot from Local Drive' {
        exit
}
menuentry 'Rear Recover for node4' {
         linuxefi /node4.kernel
         initrdefi /node4.initrd.cgz
}
menuentry 'Rear Recover for node5' {
         linuxefi /node5.kernel
         initrdefi /node5.initrd.cgz
}
  • while Booting the server ( Selected the node 4)
    PXE-NODE4-2020-04-13-18-42-02

  • Booted the server
    PXE-NODE4-2020-04-13-18-49-35

  • Rear Recover command the server
    PXE-NODE4-2020-04-13-18-52-55

@gdha
Copy link
Member

gdha commented Apr 14, 2020

@ravikumar-c Nice job! I believe we only support PXE plain BIOS booting for the moment. You enhanced it yourself - any chance you could enhance the ReaR code for EFI PXE booting with a PR?

@gdha
Copy link
Member

gdha commented Apr 15, 2020

@gozora As SEM is this feasible to add in the furture?

@jsmeix jsmeix added the enhancement Adaptions and new features label Apr 15, 2020
@ravikumar-c
Copy link
Author

i will include the code and test the EFI PXE recover

@ravikumar-c
Copy link
Author

ravikumar-c commented Apr 17, 2020

I have updated the code and tested the EFI PXE recover. Please review.

Rear version:
Relax-and-Recover 2.5 / Git
OS version:
OS: RHEL/OEL 7 and SLES 15

[root@node4 /]# sdiff ./usr/share/rear/output/PXE/default/810_create_pxelinux_cfg.sh ./usr/share/rear/output/PXE/default/810_create_pxelinux_cfg.sh_ORG | nl
     1  # 81_create_pxelinux_cfg.sh                                     # 81_create_pxelinux_cfg.sh
     2  #                                                               #
     3  # create pxelinux config on PXE server for Relax-and-Recover    # create pxelinux config on PXE server for Relax-and-Recover
     4  #                                                               #
     5  # This file is part of Relax-and-Recover, licensed under the    # This file is part of Relax-and-Recover, licensed under the
     6  # Public License. Refer to the included COPYING for full text   # Public License. Refer to the included COPYING for full text

     7  # we got PXE_KERNEL and PXE_INITRD set in the previous script   # we got PXE_KERNEL and PXE_INITRD set in the previous script

     8  if [[ ! -z "$PXE_CONFIG_URL" ]] ; then                          if [[ ! -z "$PXE_CONFIG_URL" ]] ; then
     9      # E.g. PXE_CONFIG_URL=nfs://server/export/nfs/tftpboot/px       # E.g. PXE_CONFIG_URL=nfs://server/export/nfs/tftpboot/px
    10      # Better be sure that on 'server' the directory /export/n       # Better be sure that on 'server' the directory /export/n
    11      local scheme=$( url_scheme $PXE_CONFIG_URL )                    local scheme=$( url_scheme $PXE_CONFIG_URL )
    12      local path=$( url_path $PXE_CONFIG_URL )                        local path=$( url_path $PXE_CONFIG_URL )
    13      mkdir -p $v "$BUILD_DIR/tftpbootfs" >&2                         mkdir -p $v "$BUILD_DIR/tftpbootfs" >&2
    14      StopIfError "Could not mkdir '$BUILD_DIR/tftpbootfs'"           StopIfError "Could not mkdir '$BUILD_DIR/tftpbootfs'"
    15      AddExitTask "rm -Rf $v $BUILD_DIR/tftpbootfs >&2"               AddExitTask "rm -Rf $v $BUILD_DIR/tftpbootfs >&2"
    16      mount_url $PXE_CONFIG_URL $BUILD_DIR/tftpbootfs                 mount_url $PXE_CONFIG_URL $BUILD_DIR/tftpbootfs
    17      PXE_LOCAL_PATH=$BUILD_DIR/tftpbootfs                            PXE_LOCAL_PATH=$BUILD_DIR/tftpbootfs
    18  else                                                            else
    19      # legacy way using PXE_LOCAL_PATH default                       # legacy way using PXE_LOCAL_PATH default
    20      PXE_LOCAL_PATH=$PXE_CONFIG_PATH                                 PXE_LOCAL_PATH=$PXE_CONFIG_PATH
    21  fi                                                              fi

    22  # PXE_CONFIG_PREFIX is a "string" (by default rear-) - is the   # PXE_CONFIG_PREFIX is a "string" (by default rear-) - is the
    23  PXE_CONFIG_FILE="${PXE_CONFIG_PREFIX}$HOSTNAME"                 PXE_CONFIG_FILE="${PXE_CONFIG_PREFIX}$HOSTNAME"
    24  if [[ ! -z "$PXE_CONFIG_URL" ]] ; then                          if [[ ! -z "$PXE_CONFIG_URL" ]] ; then
    25      if is_true "$PXE_CONFIG_GRUB_STYLE" ; then                      if is_true "$PXE_CONFIG_GRUB_STYLE" ; then
    26          make_pxelinux_config_grub >"$PXE_LOCAL_PATH/$PXE_CONF           make_pxelinux_config_grub >"$PXE_LOCAL_PATH/$PXE_CONF
    27      else                                                            else
    28          make_pxelinux_config >"$PXE_LOCAL_PATH/$PXE_CONFIG_FI           make_pxelinux_config >"$PXE_LOCAL_PATH/$PXE_CONFIG_FI
    29      fi                                                              fi
    30      chmod 444 "$PXE_LOCAL_PATH/$PXE_CONFIG_FILE"                    chmod 444 "$PXE_LOCAL_PATH/$PXE_CONFIG_FILE"
    31  else                                                            else
    32                                                                <
    33     EFIMT=`mount -v | grep /sys/firmware/efi/efivars | wc -l`  <
    34     EFIMGR=`efibootmgr -v | grep "BootOrder" | wc -l`          <
    35     if [[ x$EFIMT =  x1 &&  x$EFIMGR = x1 ]] ; then            <
    36     cat >"$PXE_LOCAL_PATH/$PXE_CONFIG_FILE" <<EOF              <
    37     set menu_color_normal=white/black                          <
    38     set menu_color_highlight=black/light-gray                  <
    39     set timeout=30                                             <
    40     insmod png                                                 <
    41     insmod efi_gop                                             <
    42     insmod efi_uga                                             <
    43     insmod video_bochs                                         <
    44     insmod video_cirrus                                        <
    45     insmod all_video                                           <
    46                                                                <
    47     set gfxpayload=keep                                        <
    48     insmod gzio                                                <
    49     insmod part_gpt                                            <
    50     insmod ext2                                                <
    51                                                                <
    52     menuentry 'Relax-and-Recover' {                            <
    53        echo 'Loading kernel ...'                               <
    54        linuxefi $OUTPUT_PREFIX_PXE/$PXE_KERNEL                 <
    55        initrdefi $OUTPUT_PREFIX_PXE/$PXE_INITRD                <
    56                                                                <
    57     }                                                          <
    58     menuentry "Reboot" {                                       <
    59       reboot                                                   <
    60     }                                                          <
    61                                                                <
    62     menuentry "Exit to EFI Shell" {                            <
    63       exit                                                     <
    64     }                                                          <
    65                                                                <
    66  EOF                                                           <
    67      else                                                      <
    68      # legacy way using PXE_LOCAL_PATH default                       # legacy way using PXE_LOCAL_PATH default
    69      cat >"$PXE_LOCAL_PATH/$PXE_CONFIG_FILE" <<EOF                   cat >"$PXE_LOCAL_PATH/$PXE_CONFIG_FILE" <<EOF
    70      $(test -s $(get_template "PXE_pxelinux.cfg") && cat $(get       $(test -s $(get_template "PXE_pxelinux.cfg") && cat $(get
    71      display $OUTPUT_PREFIX_PXE/$PXE_MESSAGE                         display $OUTPUT_PREFIX_PXE/$PXE_MESSAGE
    72      say -----------------------------------------------------       say -----------------------------------------------------
    73      say rear = disaster recover this system with Relax-and-Re       say rear = disaster recover this system with Relax-and-Re
    74      label rear                                                      label rear
    75          kernel $OUTPUT_PREFIX_PXE/$PXE_KERNEL                           kernel $OUTPUT_PREFIX_PXE/$PXE_KERNEL
    76          append initrd=$OUTPUT_PREFIX_PXE/$PXE_INITRD root=/de           append initrd=$OUTPUT_PREFIX_PXE/$PXE_INITRD root=/de
    77  EOF                                                             EOF
    78  fi                                                            <
    79  fi                                                              fi


    80  pushd "$PXE_LOCAL_PATH" >/dev/null                              pushd "$PXE_LOCAL_PATH" >/dev/null
    81  StopIfError "PXE_CONFIG_PATH [$PXE_CONFIG_PATH] does not exis   StopIfError "PXE_CONFIG_PATH [$PXE_CONFIG_PATH] does not exis
    82  if test "$PXE_CREATE_LINKS" -a "$PXE_REMOVE_OLD_LINKS" ; then   if test "$PXE_CREATE_LINKS" -a "$PXE_REMOVE_OLD_LINKS" ; then
    83          # remove old links                                              # remove old links
    84          find . -maxdepth 1 -type l | \                                  find . -maxdepth 1 -type l | \
    85                  while read file ; do                                            while read file ; do
    86                          if test "$(readlink -s $file)" = "$PX                           if test "$(readlink -s $file)" = "$PX
    87                                  rm -f $file                                                     rm -f $file
    88                          fi                                                              fi
    89                  done                                                            done
    90  fi                                                              fi

    91  # When using Grub network boot via tftp/bootp,                  # When using Grub network boot via tftp/bootp,
    92  # the client is looking at a file named "grub.cfg-01-<MAC>"     # the client is looking at a file named "grub.cfg-01-<MAC>"
    93  # or grub.cfg-<IP in hex>. It is like PXE, but prefixed with    # or grub.cfg-<IP in hex>. It is like PXE, but prefixed with
    94  if is_true $PXE_CONFIG_GRUB_STYLE ; then                        if is_true $PXE_CONFIG_GRUB_STYLE ; then
    95      pxe_link_prefix="grub.cfg-"                                     pxe_link_prefix="grub.cfg-"
    96  else                                                            else
    97      pxe_link_prefix=""                                              pxe_link_prefix=""
    98  fi                                                              fi

    99  case "$PXE_CREATE_LINKS" in                                     case "$PXE_CREATE_LINKS" in
   100          IP)                                                             IP)
   101                  # look only at IPv4 and skip localhost (127..                   # look only at IPv4 and skip localhost (127..
   102                  ip a | grep inet\ | grep -v inet\ 127 | \                       ip a | grep inet\ | grep -v inet\ 127 | \
   103                          while read inet IP junk ; do                                    while read inet IP junk ; do
   104                                  IP=${IP%/*}                                                     IP=${IP%/*}
   105                  # check if gethostip is available.                              # check if gethostip is available.
   106                  if has_binary gethostip &>/dev/null ; then                      if has_binary gethostip &>/dev/null ; then
   107                                  ln -sf $v "$PXE_CONFIG_FILE"                                    ln -sf $v "$PXE_CONFIG_FILE"
   108                                  # to capture the whole subnet                                   # to capture the whole subnet
   109                                  ln -sf $v "$PXE_CONFIG_FILE"                                    ln -sf $v "$PXE_CONFIG_FILE"
   110                  else                                                            else
   111                  # if gethostip is not available on your platf                   # if gethostip is not available on your platf
   112                  # use awk to generate IP in hex mode.                           # use awk to generate IP in hex mode.
   113                      ln -sf $v "$PXE_CONFIG_FILE" $pxe_link_pr                       ln -sf $v "$PXE_CONFIG_FILE" $pxe_link_pr
   114                      # to capture the whole subnet as well                           # to capture the whole subnet as well
   115                                  ln -sf $v "$PXE_CONFIG_FILE"                                    ln -sf $v "$PXE_CONFIG_FILE"
   116                  fi                                                              fi
   117                          done                                                            done
   118                  ;;                                                              ;;
   119          MAC)                                                            MAC)
   120                  # look at all devices that have link/ether                      # look at all devices that have link/ether
   121                  ip l | grep link/ether | \                                      ip l | grep link/ether | \
   122                          while read link mac junk ; do                                   while read link mac junk ; do
   123                                  ln -sf $v "$PXE_CONFIG_FILE"                                    ln -sf $v "$PXE_CONFIG_FILE"
   124                          done                                                            done
   125                  ;;                                                              ;;
   126          "")                                                             "")
   127                  Log "Not creating symlinks to pxelinux config                   Log "Not creating symlinks to pxelinux config
   128                  ;;                                                              ;;
   129          *)                                                              *)
   130                  Error "Invalid PXE_CREATE_LINKS specified, mu                   Error "Invalid PXE_CREATE_LINKS specified, mu
   131                  ;;                                                              ;;
   132  esac                                                            esac
   133  popd >/dev/null                                                 popd >/dev/null

   134  if [[ ! -z "$PXE_CONFIG_URL" ]] ; then                          if [[ ! -z "$PXE_CONFIG_URL" ]] ; then
   135      LogPrint "Created pxelinux config '${PXE_CONFIG_PREFIX}$H       LogPrint "Created pxelinux config '${PXE_CONFIG_PREFIX}$H
   136      umount_url $PXE_TFTP_URL $BUILD_DIR/tftpbootfs                  umount_url $PXE_TFTP_URL $BUILD_DIR/tftpbootfs
   137      rmdir $BUILD_DIR/tftpbootfs >&2                                 rmdir $BUILD_DIR/tftpbootfs >&2
   138      if [[ $? -eq 0 ]] ; then                                        if [[ $? -eq 0 ]] ; then
   139          RemoveExitTask "rm -Rf $v $BUILD_DIR/tftpbootfs >&2"            RemoveExitTask "rm -Rf $v $BUILD_DIR/tftpbootfs >&2"
   140      fi                                                              fi
   141      RESULT_FILES=( "${RESULT_FILES[@]}" )                           RESULT_FILES=( "${RESULT_FILES[@]}" )
   142  else                                                            else
   143      LogPrint "Created pxelinux config '${PXE_CONFIG_PREFIX}$H       LogPrint "Created pxelinux config '${PXE_CONFIG_PREFIX}$H
   144      # Add to result files                                           # Add to result files
   145      RESULT_FILES=( "${RESULT_FILES[@]}" "$PXE_LOCAL_PATH/$PXE       RESULT_FILES=( "${RESULT_FILES[@]}" "$PXE_LOCAL_PATH/$PXE
   146  fi                                                              fi
[root@node4 /]#

@gdha
Copy link
Member

gdha commented Apr 17, 2020

@ravikumar-c Thanks for the hard work already, but could you prepare a Pull Request for your changes? See http://relax-and-recover.org/development/ for the details on how to contribute.

@github-actions
Copy link

Stale issue message

@gozora
Copy link
Member

gozora commented Jul 1, 2020

Hello @gdha

@gozora As SEM is this feasible to add in the furture?

Sorry I must have overlooked your question somehow ...
I usually don't use PXE, so I don't have overview about PXE booting features in ReaR.
Is this issue about problem with booting UEFI system over PXE ?

V.

jsmeix added a commit that referenced this issue Jul 2, 2020
Manually added the additional lines from the diff output in
#2359 (comment)
@jsmeix
Copy link
Member

jsmeix commented Jul 2, 2020

Via #2449
I manually added the additional lines
for PXE UEFI support to 810_create_pxelinux_cfg.sh
from the diff output in the above
#2359 (comment)

I did not test anything at all because I do not use PXE.

I did only plain code editing so that we have a pull request
as an initial starting point towards getting PXE UEFI support.

@jsmeix
Copy link
Member

jsmeix commented Jul 2, 2020

@rmetrich @pcahyna
could you perhaps have a look here as time permits?
It is about adding UEFI support for PXE booting the ReaR recovery system.

@jsmeix jsmeix self-assigned this Jul 2, 2020
@jsmeix jsmeix added this to the ReaR v2.7 milestone Jul 2, 2020
@rmetrich
Copy link
Contributor

rmetrich commented Jul 3, 2020

@ravikumar-c It looks like to me that you removed the console=ttyS0,9600 console=tty0 arguments, is that intentional?
These console arguments should be taken from /proc/cmdline while creating the rescue (if there is nothing, then do add anything, otherwise just copy the args content).

@github-actions
Copy link

github-actions bot commented Sep 2, 2020

Stale issue message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants