linux · liveusb · thel

RHEL 7.3 Boot USB

This is not as trivial as you may think. The easiest way is to simply dd the ISO image to the USB device, but you get a 1) ReadOnly media and 2) Not all Servers are able to boot off it. In my case I needed to add a few kick start files and change the boot loader menu to include a few different options.

Format the USB stick

We’ll be using the whole device and skip partitioning. One of the servers (Dell R630) that I had was refusing to boot off a partitioned USB flash drive in non-UEFI mode. The -s 32 option gives you greater cluster size so the boot process will be slightly faster.

mkfs.vfat -n RH73USB -s 32 -v /dev/sde

Install syslinux boot loader

The CD/DVD is using isolinux, but in order to boot off a USB or a hard drive we will need syslinux, which works with FAT32 volumes. The following command will install the boot loader and also copy the ldlinux.sys file to the USB flash:

syslinux -i /dev/sde

Copy RHEL ISO files to the USB flash

Mount the ISO using loop device

mount  -o loop ./rhel73.iso  /mnt

DO NOT COPY THE EFI DIRECTORY !!! Copy the following files/directories:

  • LiveOS
  • Packages
  • addons
  • release-notes
  • repodata
  • all files from root directory.

From the isolinux directory, copy the following to the root directory of the USB flash:

  • boot.msg
  • initrd.img
  • memtest
  • splash.png
  • vesamenu.c32
  • vmlinuz

Take the isolinux/isolinux.cfg file, rename it to syslinux.cfg and put it in the root directory of USB flash as well. I also created a ks directory for all of my kickstart files.

The layout should be like this:

eugene@hp256 /media/eugene/RH73USB $ ls -l
total 50464
drwx------  4 eugene eugene    32768 Jun 28 17:28 addons
-rw-r--r--  1 eugene eugene       84 Oct 20  2016 boot.msg
-rw-r--r--  1 eugene eugene     8266 Apr  4  2014 EULA
-rw-r--r--  1 eugene eugene    18092 Mar  7  2012 GPL
-rw-r--r--  1 eugene eugene 44701632 Oct 20  2016 initrd.img
drwx------  2 eugene eugene    32768 Jun 28 22:23 ks
-r--r--r--  1 eugene eugene    32768 Jun 28 17:12 ldlinux.sys
drwx------  2 eugene eugene    32768 Jun 28 17:15 LiveOS
-rw-r--r--  1 eugene eugene      114 Oct 20  2016 media.repo
-rw-r--r--  1 eugene eugene   190896 Apr  5  2016 memtest
drwx------  2 eugene eugene   688128 Jun 28 17:28 Packages
drwx------ 24 eugene eugene    32768 Jun 28 17:30 release-notes
drwx------  2 eugene eugene    32768 Jun 28 17:30 repodata
-rw-r--r--  1 eugene eugene     3375 Sep 27  2016 RPM-GPG-KEY-redhat-beta
-rw-r--r--  1 eugene eugene     3211 Sep 27  2016 RPM-GPG-KEY-redhat-release
-rw-r--r--  1 eugene eugene      186 Jun 28 00:47 splash.png
-rw-r--r--  1 eugene eugene     3374 Jun 28 21:40 syslinux.cfg
-rw-r--r--  1 eugene eugene     1568 Oct 20  2016 TRANS.TBL
-rw-r--r--  1 eugene eugene   153104 May 10  2016 vesamenu.c32
-rw-r--r--  1 eugene eugene  5391264 Oct 20  2016 vmlinuz

Modify boot menu options

Modify the contents of the syslinux.cfg file to point at the USB flash RH73LIVE volume instead of the ISO image. Repeat this step for all boot menu items except for memtest:

label linux
  menu label ^Install Red Hat Enterprise Linux 7.3
  menu default
  kernel vmlinuz
  append initrd=initrd.img inst.repo=hd:LABEL=RH73USB:/ 

To boot with a kick start file, add a menu item like this:

label r630
  menu label Dell R630 Kickstart 
  kernel vmlinuz
  append initrd=initrd.img inst.repo=hd:LABEL=RH73USB:/ inst.ks=hd:LABEL=RH73USB:/ks/r630.ks

The inst.repo option tells Anaconda where to get the Live OS image and the inst.ks option tells it which kickstart file to use. Official Anaconda documentation also explains what these options mean:

inst.repo=cdrom

Search the system’s CDROM drives for installer media. This is the default.

inst.repo=cdrom:<device>

Look for installer media in the specified disk device.

inst.repo=hd:<device>:<path>

Mount the given disk partition and install from ISO file on the given path. This installation method requires ISO file, which contains an installable tree.

inst.repo=[http,https,ftp]://<host>/<path>

Look for an installable tree at the given URL.

inst.repo=nfs:[<options>:]<server>:/<path>

Mount the given NFS server and path. Uses NFS version 3 by default.

Disk devices may be specified with any of the following forms:

  • Kernel Device Name: /dev/sda1, sdb2
  • Filesystem Label: LABEL=FLASH, LABEL=Fedora, CDLABEL=Fedora\x2023\x20x86_64
  • Filesystem UUID: UUID=8176c7bf-04ff-403a-a832-9557f94e61db

This article has a lot more details on these options: https://rhinstaller.github.io/anaconda/boot-options.html and Dracut manual is recommended as well: https://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html#dracutcmdline7

In theory it is possible to create an multi-boot USB flash with multiple partitions and put different RHEL flavours on every partition (CentOS, Fedora, etc) and boot to any of them. However, there are some computers that won’t boot from a partitioned USB flash drive.

Published:
comments powered by Disqus