Make driver disk for CentOS

Goals

If you want to make a generic USB driver disk for RHEL/CentOS, you can follow these instructions. The drivers are in rpm format, and you need those drivers during installation of a new system, primarily storage drivers.

Instructions

On an existing CentOS system, install the dependencies.

yum -y install createrepo squashfs-tools

Change directory to where your rpms and make a new directory tree.

cd path/to/rpms
export SQUASH_ROOT=./squashfs-root
mkdir -p "${SQUASH_ROOT}/rpms/x86_64"

Make a specific file with any contents you wish.

echo "My custom driver disk" > "${SQUASH_ROOT}/rhdd3"

Make a yum repository

cp -p *rpm "${SQUASH_ROOT}/rpms/x86_64/"
createrepo --basedir "${SQUASH_ROOT}/rpms/x86_64/" .

Make the driver disk-only components.

touch "${SQUASH_ROOT}/.rundepmod"
( cd "${SQUASH_ROOT}" ;
   for thisrpm in "${SQUASH_ROOT}/rpms/x86_64/*rpm ;
   do
      rpm2cpio "${thisrpm}" | cpio -imVd ./lib/*
   done
)

And make the image file from the custom directory.

mksquashfs "${SQUASH_ROOT}" ./my-driver-disk.img

Clean up the custom directory if you’re done with it! The image is now complete and we will use it for the last step.

rm -rf "${SQUASH_ROOT}"

Deploy the image onto your preferred disk drive. Be sure you know which drive is the flash drive you want!

sudo dd if=/path/to/my-driver-disk.img of=/dev/sdz

The image file should be really small, so there is no need to control block size (bs=2048). Also, this disk will not be directly readable to a regular system, so do not let that alarm you.

References

Weblinks

  1. Red Hat Enterprise Linux and CentOS 7 Driver Disk
  2. Install CentOS 7 on HP ProLiant DL360 G5 with P400i SAS Controller | Knowledge Base

Install CentOS 7 on HP ProLiant DL360 G5 with P400i SAS Controller

Instructions

You need to add the cciss.ko driver which has been removed from the kernel or CentOS 7 or whatever. Anyway, you can get it by using a driver disk.

Build the USB driver disk

Building the driver disk can be done on any Centos System. Install the dependencies for making a driver disk.

yum -y install wget createrepo squashfs-tools

Create the driver disk image using this script.

# Author: Ithanga https://www.centos.org/forums/viewtopic.php?t=48574#p295546
export CURR=`pwd`
export SQUASH_ROOT=${CURR}/squashfs-root
export VER=3.6.26-5
export RPM_PKG=kmod-cciss-${VER}.el7_5.elrepo.x86_64.rpm
mkdir -p ${SQUASH_ROOT}/rpms/x86_64/
echo "HP Smart Array CCISS driver ver. 3.6.26" > ${SQUASH_ROOT}/rhdd3
wget --directory-prefix=${SQUASH_ROOT}/rpms/x86_64/ http://dfw.mirror.rackspace.com/elrepo/elrepo/el7/x86_64/RPMS/${RPM_PKG}
createrepo --basedir ${SQUASH_ROOT}/rpms/x86_64/ .
touch ${SQUASH_ROOT}/.rundepmod
cd ${SQUASH_ROOT}
rpm2cpio ${SQUASH_ROOT}/rpms/x86_64/${RPM_PKG} | cpio -imVd ./lib/*
cd ${CURR}
mksquashfs ${SQUASH_ROOT} ${CURR}/kmod-cciss-${VER}-driver-disk.img
rm -fr ${SQUASH_ROOT}

Insert a USB flash drive and write the image file to the correct disk. It can be as easy as:

time sudo dd if=/path/to/kmod-cciss-3.6.26-5-driver-disk.img of=/dev/sdz

Of course, make sure you use the right storage device. I noticed that when you fdisk -l or parted print the device afterwards, it doesn’t really show a whole lot, but it does work.

Create the CentOS 7 install dvd

A regular USB flash drive method will work here too. I don’t know about burning dvds; I haven’t done that for a long time. For my flash drive it was:

time sudo dd if=/path/to/CentOS-7-x86_64-Minimal-1810.iso bs=4096 of=/dev/sdz status=progress

It is important to note that the rpm in the above script is for the exact el7 release in this 1810 iso.

Loading the driver for the installation

Boot from the CentOS 7 install disk, and at the disc menu (where it asks “Install CentOS 7”, “Test this media…”, and “Troubleshooting … >”) hit Tab to edit the boot option.
Add the single parameter “dd” at the end, which will make it pause and ask you which partition to load drivers from.
You will have to choose which partition from the next menu, so if you cannot determine which partition is your driver disk, just try all of them. When you hit the right one, it will ask you which rpm to load. Select that driver based on the prompt, and then continue the installation.

Install like normal!

The story

I received an HP ProLiant DL360 G5 server which is about a decade old. I love old hardware, if it still runs. However, getting the driver for CentOS 8 proved to be impossible at this time. I investigated what kind of driver to use, and it appears to be either the cciss or hpsa kmods. The wonderful folks over at elrepo have packaged the cciss kernel module for el7 (CentOS 7) but have not yet accomplished this feat for el8.
I reverted to el7, and then had to load up the rpm on a driver disk.

References

Weblinks

  1. Ripped off entirely from No disk detected on ProLiant DL360 G5 – CentOS
  2. elrepo-packaged cciss driver http://dfw.mirror.rackspace.com/elrepo/elrepo/el7/x86_64/RPMS/kmod-cciss-3.6.26-6.el7_6.elrepo.x86_64.rpm

Auxiliary reading

  1. CentOS 7 x64 and HP Proliant DL360 G5 SCSI Controller compatibility – Server Fault
  2. trying hpsa driver which failed for me drivers – Install Fedora core 15 on HP Smart Array Controller HDD – Unix & Linux Stack Exchange
  3. Add kmod RAID driver in Centos 7 installer for HP Proliant – CentOS
  4. driver is not compiled for el8 yet 0000951: kmod-cciss driver for el8 – Mantis

Install CentOS 8 with kickstart and virt-install

This is a modification of my process for using virt-install to fully automate the install for CentOS/Fedora with kickstart.

Here is my kickstart file for CentOS 8. Only minor modifications were required. A few packages aren’t available yet, but I’ve stopped using them, and a few renames.

How I use this

I define a variable, and plug it into the important parts.

vm=c8-02a ; time sudo virt-install -n "${vm}" --memory 2048 --vcpus=1 --os-variant=centos7.0 --accelerate -v --disk path=/var/lib/libvirt/images/"${vm}".qcow2,size=20 -l /mnt/public/Support/SetupsBig/Linux/CentOS-8-x86_64-1905-dvd1.iso --initrd-inject=/mnt/public/Support/Platforms/CentOS8/centos8-ks.cfg --extra-args "ks=file:/centos8-ks.cfg SERVERNAME=${vm} NOTIFYEMAIL=bgstack15@gmail.com net.ifnames=0 biosdevname=0" --debug --network type=bridge,source=br0 --noautoconsole

Some thoughts

The repository URLs are a little different for CentOS 8, but once I had one built I could examine the URLS and correct my kickstart to use my local repos.

Dependencies

The kickstart file

# File: /mnt/public/Support/Platforms/CentOS8/centos8-ks.cfg
# Locations:
#    /mnt/public/Support/Platforms/CentOS8/centos8-ks.cfg
# Author: bgstack15
# Startdate: 2017-06-02
# Title: Kickstart for CentOS 8 for ipa.smith122.com
# Purpose: To provide an easy installation for VMs and other systems in the Mersey network
# History:
#    2017-06 I learned how to use kickstart files for the RHCSA EX-200 exam
#    2017-08-08 Added notifyemail to --extra-args
#    2017-10-29 major revision to use local repository
#
#
#
#
#    2019-09-24 fork for CentOS 8
# Usage with virt-install:
#    vm=c8-01a ; time sudo virt-install -n "${vm}" --memory 2048 --vcpus=1 --os-variant=centos7.0 --accelerate -v --disk path=/var/lib/libvirt/images/"${vm}".qcow2,size=20 -l /mnt/public/Support/SetupsBig/Linux/CentOS-8-x86_64-1905-dvd1.iso --initrd-inject=/mnt/public/Support/Platforms/CentOS8/centos8-ks.cfg --extra-args "ks=file:/centos8-ks.cfg SERVERNAME=${vm} NOTIFYEMAIL=bgstack15@gmail.com net.ifnames=0 biosdevname=0" --debug --network type=bridge,source=br0 --noautoconsole
#    vm=c8-01a; sudo virsh destroy "${vm}"; sudo virsh undefine --remove-all-storage "${vm}";
# Reference:
#    https://sysadmin.compxtreme.ro/automatically-set-the-hostname-during-kickstart-installation/
#    /mnt/public/Support/Platforms/CentOS7/install-vm.txt

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --plaintext f0rg3tkickstart&
# my user
user --groups=wheel --name=bgstack15-local --password=$6$.gh9u7vg2HDJPPX/$g3X1l.q75fs7i0UKUt6h88bDIo1YSGGj/1DGeUzzbMTb0pBh4of6iNYWyxws/937qUiPgETqOsYFI5XNrkaUe. --iscrypted --gecos="bgstack15-local"

# System language
lang en_US.UTF-8
# Firewall configuration
firewall --enabled --ssh
# Reboot after installation
reboot
# Network information
#attempting to put it in the included ks file that accepts hostname from the virsh command.
#network  --bootproto=dhcp --device=eth0 --ipv6=auto --activate
%include /tmp/network.ks
# System timezone
timezone America/New_York --utc
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use network installation instead of CDROM installation media
url --url="http://www.ipa.smith122.com/mirror/centos/8/BaseOS/x86_64/os"

# Use text mode install
text
# SELinux configuration
selinux --enforcing
# Do not configure the X Window System
skipx

# Use all local repositories
# Online repos
repo --name=smith122rpm --baseurl=http://www.ipa.smith122.com/smith122/repo/rpm/
repo --name=base --baseurl=https://www.ipa.smith122.com/mirror/centos/$releasever/BaseOS/$basearch/os/
repo --name=appstream --baseurl=https://www.ipa.smith122.com/mirror/centos/$releasever/AppStream/$basearch/os/
repo --name=extras --baseurl=https://www.ipa.smith122.com/mirror/centos/$releasever/extras/$basearch/os/
repo --name=powertools --baseurl=https://www.ipa.smith122.com/mirror/centos/$releasever/PowerTools/$basearch/os/
repo --name=epel --baseurl=https://www.ipa.smith122.com/mirror/fedora/epel/$releasever/Everything/$basearch

# Offline repos
#
#
#
#
#

firstboot --disabled

# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
autopart --type=lvm

%pre
echo "network  --bootproto=dhcp --device=eth0 --ipv6=auto --activate --hostname renameme.ipa.smith122.com" > /tmp/network.ks
for x in $( cat /proc/cmdline );
do
   case $x in
      SERVERNAME*)
         eval $x
         echo "network  --bootproto=dhcp --device=eth0 --ipv6=auto --activate --hostname ${SERVERNAME}.ipa.smith122.com" > /tmp/network.ks
         ;;
      NOTIFYEMAIL*)
         eval $x
         echo "${NOTIFYEMAIL}" > /mnt/sysroot/root/notifyemail.txt
	 ;;
   esac
done
cp -p /run/install/repo/ca-ipa.smith122.com.crt /etc/pki/ca-trust/source/anchors/ 2>/dev/null || :
wget http://www.ipa.smith122.com/smith122/certs/ca-ipa.smith122.com.crt -O /etc/pki/ca-trust/source/anchors/ca-ipa.smith122-wget.com.crt || :
update-ca-trust || :
%end

%post
(
   # Set temporary hostname
   #hostnamectl set-hostname renameme.ipa.smith122.com;

   ifup eth0
   sed -i -r -e 's/ONBOOT=.*/ONBOOT=yes/;' /etc/sysconfig/network-scripts/ifcfg-e*

   # Get local mirror root ca certificate
   wget http://www.ipa.smith122.com/smith122/certs/ca-ipa.smith122.com.crt -O /etc/pki/ca-trust/source/anchors/ca-ipa.smith122.com.crt && update-ca-trust

   # Get local mirror repositories
   wget https://www.ipa.smith122.com/smith122/repo/rpm/smith122rpm.repo -O /etc/yum.repos.d/smith122rpm.repo;
   wget http://www.ipa.smith122.com/smith122/repo/rpm/smith122rpm.mirrorlist -O /etc/yum.repos.d/smith122rpm.mirrorlist
   distro=centos8 ; wget https://www.ipa.smith122.com/smith122/repo/mirror/smith122-bundle-${distro}.repo -O /etc/yum.repos.d/smith122-bundle-${distro}.repo && grep -oP "(?<=^\[).*(?=-smith122])" /etc/yum.repos.d/smith122-bundle-${distro}.repo | while read thisrepo; do yum-config-manager --disable "${thisrepo}"; done # NONE TO REMOVE dnf -y remove dnfdragora ; yum clean all ; yum update -y ; # Remove graphical boot and add serial console sed -i -r -e '/^GRUB_CMDLINE_LINUX=/{s/(\s*)(rhgb|quiet)\s*/\1/g;};' -e '/^GRUB_CMDLINE_LINUX=/{s/(\s*)\"$/ console=ttyS0 console=tty1\"/;}' /etc/default/grub grub2-mkconfig > /boot/grub2/grub.cfg

   # postfix is already started by default on centos8
   # Send IP address to myself
   thisip="$( ifconfig 2>/dev/null | awk '/Bcast|broadcast/{print $2}' | tr -cd '[^0-9\.\n]' | head -n1 )"
   {
      echo "${SERVER} has IP ${thisip}."
      echo "system finished kickstart at $( date "+%Y-%m-%d %T" )";
   } | /usr/share/bgscripts/send.sh -f "root@$( hostname --fqdn )" \
      -h -s "${SERVER} is ${thisip}" $( cat /root/notifyemail.txt 2>/dev/null )

   # No changes to graphical boot
   #

   # fix the mkhomedir problem
   systemctl enable oddjobd.service && systemctl start oddjobd.service

   # Personal customizations
   mkdir -p /mnt/bgstack15 /mnt/public
   su bgstack15-local -c "sudo /usr/share/bgconf/bgconf.py"

) >> /root/install.log 2>&1
%end

%packages
@core
@^minimal install
bc
bgconf
bgscripts-core
bind-utils
cifs-utils
cryptsetup
dosfstools
epel-release
expect
firewalld
git
iotop
ipa-client
-iwl*-firmware
mailx
man
mlocate
net-tools
nfs-utils
p7zip
parted
python3-policycoreutils
rpm-build
rsync
screen
strace
sysstat
tcpdump
telnet
vim
wget
yum-utils
%end

All packages in my copr are CentOS 8-ready

I have confirmed that all the packages in my COPR have compiled for CentOS 8! I personally only have a single headless vm for CentOS 8 so the applications might malfunction. Please report to me if any failures occur.

Backstory time

When CentOS 8 was finally released (September 24), I downloaded it right away and updated my kickstart process for it (future post).

Some packages built just fine right away, on the rhel8beta repo. Some failed because they use ImageMagick which wasn’t compiled yet, but has since been added. I use the “convert” utility like a lot of packagers do, for converting an svg to instantiated png files for icons. Anyway, I was considering rewriting my scripts to use GraphicsMagick but thankfully upstream added ImageMagick, which reduced my workload considerably.

Some packages failed because various libraries were unavailable, and were still unavailable. Using one of my preferred upstreams (city-fan) and rebuilding some Fedora packages, I added libraries necessary to compile the rest of my packages.

It is worth noting that CentOS 8 uses dnf modules or “streams.” I don’t fully understand the concept, and personally think it only causes problems. I had to compile curl-7.66.0 and host it myself, because of which repositories I had to enable and disable to get the right perl modules to compile it. Libcurl is required to compile FreeFileSync, and various unimportant perl modules are required to compile libcurl. However, due to the modules in dnf/yum, there is a conflict between certain latest perl packages in that stream, with other repositories, and I was unable to configure the COPR to take any old version of the perl modules.

Use virt-install to fully automate the install for CentOS/Fedora with kickstart

Here is my kickstart file for CentOS 7. I deploy VMs into my kvm environment with a oneliner, using this kickstart file.

How I use this

I define a variable, and plug it into the important parts.

vm=c7-04a ; time sudo virt-install -n "${vm}" --memory 2048 \
   --vcpus=1 --os-variant=centos7.0 --accelerate -v \
   --disk path=/var/lib/libvirt/images/"${vm}".qcow2,size=20 \
   -l /mnt/public/Support/SetupsBig/Linux/CentOS-7-x86_64-Minimal-1810.iso \
   --initrd-inject=/mnt/public/Support/Platforms/CentOS7/centos7-ks.cfg \
   --extra-args "ks=file:/centos7-ks.cfg SERVERNAME=${vm} NOTIFYEMAIL=bgstack15@gmail.com" \
   --debug --network type=bridge,source=br0 --noautoconsole

Some thoughts

I had to download the 1810 release of the iso, because there was something wrong with the repos or perhaps files in the previous isos, with how they interacted with either the virtual environment or the network or something. But the CentOS-7-x86_64-minimal-1810.iso was important.
I found the SERVERNAME trick on the Internet. You can iterate over /proc/cmdline and react to values you find there, in the %pre or %post scripts.
You will see that I use my own local repositories for the regular CentOS repos, and I add my own internal one (smith122/repo/rpm). Obviously you should find a suitable set of repos for your own.
You will also see that I attempt to download my CA certificates at various points. I’m pretty sure the %pre effort fails, because the system is not on the network yet.

Dependencies

The kickstart file

# File: /mnt/public/Support/Platforms/CentOS7/centos7-ks.cfg
# Locations:
#    /mnt/public/Support/Platforms/CentOS7/centos7-ks.cfg
# Author: bgstack15
# Startdate: 2017-06-02
# Title: Kickstart for CentOS 7 for ipa.smith122.com
# Purpose: To provide an easy installation for VMs and other systems in the Mersey network
# History:
#    2017-06 I learned how to use kickstart files for the RHCSA EX-200 exam
#    2017-08-08 Added notifyemail to --extra-args
#    2017-10-29 major revision to use local repository
#
#
#
#
# Usage with virt-install:
#    vm=c7-04a ; time sudo virt-install -n "${vm}" --memory 2048 --vcpus=1 --os-variant=centos7.0 --accelerate -v --disk path=/var/lib/libvirt/images/"${vm}".qcow2,size=20 -l /mnt/public/Support/SetupsBig/Linux/CentOS-7-x86_64-Minimal-1810.iso --initrd-inject=/mnt/public/Support/Platforms/CentOS7/centos7-ks.cfg --extra-args "ks=file:/centos7-ks.cfg SERVERNAME=${vm} NOTIFYEMAIL=bgstack15@gmail.com" --debug --network type=bridge,source=br0 --noautoconsole
#    vm=c7-04a; sudo virsh destroy "${vm}"; sudo virsh undefine --remove-all-storage "${vm}";
# Reference:
#    https://sysadmin.compxtreme.ro/automatically-set-the-hostname-during-kickstart-installation/
#    /mnt/public/Support/Platforms/CentOS7/install-vm.txt

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --plaintext SOMETHINGSTRONGHERE
# my user
user --groups=wheel --name=bgstack15-local --password=$6$.gh0u7vg2HDPJPX/$g4Y1l.q76fs7i0UK8t6h83bDIo2YnGGj/1DGeUzzbMTd0pBh4of6jNYWxxws/937sUiPgETqPsYFI5XNrkAle. --iscrypted --gecos="bgstack15-local"

# System language
lang en_US.UTF-8
# Firewall configuration
firewall --enabled --ssh
# Reboot after installation
reboot
# Network information
#attempting to put it in the included ks file that accepts hostname from the virsh command.
#network  --bootproto=dhcp --device=eth0 --ipv6=auto --activate
%include /tmp/network.ks
# System timezone
timezone America/New_York --utc
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use network installation instead of CDROM installation media
url --url="http://www.ipa.smith122.com/mirror/centos/7/os/x86_64/"

# Use text mode install
text
# SELinux configuration
selinux --enforcing
# Do not configure the X Window System
skipx

# Use all local repositories
# Online repos
repo --name=smith122rpm --baseurl=https://www.ipa.smith122.com/smith122/repo/rpm/
repo --name=base --baseurl=https://www.ipa.smith122.com/mirror/centos/$releasever/os/$basearch/
repo --name=updates --baseurl=https://www.ipa.smith122.com/mirror/centos/$releasever/updates/$basearch/
repo --name=extras --baseurl=https://www.ipa.smith122.com/mirror/centos/$releasever/extras/$basearch/
repo --name=epel --baseurl=https://www.ipa.smith122.com/mirror/fedora/epel/$releasever/$basearch

# Offline repos
#
#
#
#
#

firstboot --disabled

# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
autopart --type=lvm

%pre
echo "network  --bootproto=dhcp --device=eth0 --ipv6=auto --activate --hostname renameme.ipa.smith122.com" > /tmp/network.ks
for x in $( cat /proc/cmdline );
do
   case $x in
      SERVERNAME*)
         eval $x
         echo "network  --bootproto=dhcp --device=eth0 --ipv6=auto --activate --hostname ${SERVERNAME}.ipa.smith122.com" > /tmp/network.ks
         ;;
      NOTIFYEMAIL*)
         eval $x
         echo "${NOTIFYEMAIL}" > /mnt/sysroot/root/notifyemail.txt
         ;;
   esac
done
cp -p /run/install/repo/ca-ipa.smith122.com.crt /etc/pki/ca-trust/source/anchors/ 2>/dev/null || :
wget http://www.ipa.smith122.com/smith122/certs/ca-ipa.smith122.com.crt -O /etc/pki/ca-trust/source/anchors/ca-ipa.smith122-wget.com.crt || :
update-ca-trust || :
%end

%post
(
   # Set temporary hostname
   #hostnamectl set-hostname renameme.ipa.smith122.com;

   # Get local mirror root ca certificate
   wget http://www.ipa.smith122.com/smith122/certs/ca-ipa.smith122.com.crt -O /etc/pki/ca-trust/source/anchors/ca-ipa.smith122.com.crt && update-ca-trust

   # Get local mirror repositories
   wget https://www.ipa.smith122.com/smith122/repo/rpm/smith122rpm.repo -O /etc/yum.repos.d/smith122rpm.repo;
   wget http://www.ipa.smith122.com/smith122/repo/rpm/smith122rpm.mirrorlist -O /etc/yum.repos.d/smith122rpm.mirrorlist
   distro=centos7 ; wget https://www.ipa.smith122.com/smith122/repo/mirror/smith122-bundle-${distro}.repo -O /etc/yum.repos.d/smith122-bundle-${distro}.repo && grep -oP "(? /boot/grub2/grub.cfg

   # postfix is already started by default on centos7
   # Send IP address to myself
   thisip="$( ifconfig 2>/dev/null | awk '/Bcast|broadcast/{print $2}' | tr -cd '[^0-9\.\n]' | head -n1 )"
   {
      echo "${SERVER} has IP ${thisip}."
      echo "system finished kickstart at $( date "+%Y-%m-%d %T" )";
   } | /usr/share/bgscripts/send.sh -f "root@$( hostname --fqdn )" \
      -h -s "${SERVER} is ${thisip}" $( cat /root/notifyemail.txt 2>/dev/null )

   # No changes to graphical boot
   #

   # fix the mkhomedir problem
   systemctl enable oddjobd.service && systemctl start oddjobd.service

   # Personal customizations
   mkdir -p /mnt/bgstack15 /mnt/public
   su bgstack15-local -c "sudo /usr/share/bgconf/bgconf.py"

) >> /root/install.log 2>&1
%end

%packages
@core
@^minimal
autossh
bc
bgconf
bgscripts-core
bind-utils
cifs-utils
cryptsetup
dosfstools
epel-release
expect
firewalld
git
iotop
ipa-client
-iwl*-firmware
mailx
man
mlocate
net-tools
nfs-utils
ntp
p7zip
parted
policycoreutils-python
rpm-build
rsync
screen
strace
sysstat
tcpdump
telnet
vim
wget
yum-utils
%end

Notes for Yum repositories for CentOS and Fedora

This is my scratch page for third-party centos and fedora repositories that are useful. I’ve used these at least once in my personal experience. There’s obviously a lot more, and they’re only an internet search away.

EPEL
SCL
city-fan
remi
rpmfusion
negativo17
ius
nuxref

Lists of additional ones:
https://rpmfusion.org/FedoraThirdPartyRepos

Sites for “rpm find”:
https://www.rpmfind.net/
http://rpm.pbone.net/

FreeFileSync 10.9 on CentOS 7

Now, you can go install FreeFileSync 10.9 on CentOS 7 from an rpm built on CentOS 7! The upstream release follows some newer versions of libs (clearly compiled on a different platform than CentOS or even Fedora), and I have now compiled those versions based on the work of a genius fellow over at city-fan.

To get FreeFileSync on CentOS 7, you need to load up two of my coprs as seen in the following table.

COPR name repo file
bgstack15/stackrpms bgstack15-stackrpms-epel-7.repo
bgstack15/FreeFileSync bgstack15-FreeFileSync-epel-7.repo

The application depends on some newer libs, which are all available in a second copr.

======================================================================================
 Package                   Arch   Version                Repository              Size
======================================================================================
Installing:
 freefilesync              x86_64 10.9-2.el7             bgstack15-stackrpms    3.2 M
Installing for dependencies:
 libpsl                    x86_64 0.7.0-1.el7            bgstack15-FreeFileSync  45 k
 openssl-freefilesync-libs x86_64 1:1.1.0h-3.stack.el7   bgstack15-FreeFileSync 1.2 M
Updating for dependencies:
 curl                      x86_64 7.64.0-2.0.cf.rhel7    bgstack15-FreeFileSync 557 k
 libcurl                   x86_64 7.64.0-2.0.cf.rhel7    bgstack15-FreeFileSync 502 k
 libssh2                   x86_64 1.8.0-10.0.stack.rhel7 bgstack15-FreeFileSync 103 k

Transaction Summary
======================================================================================
Install  1 Package  (+2 Dependent packages)
Upgrade             ( 3 Dependent packages)

Total download size: 5.6 M
Is this ok [y/d/N]: 

The artifacts used to produce this build are in my gitlab.

CentOS 7 learn used grub entry

With the major changes introduced in CentOS 7 from CentOS 6 (systemd, grub2, and more), determining exactly which grub menu entry will be used at next boot is a little more difficult than before.

I wrote a quick script that calculates this for you: learn-used-grub-entry

#!/bin/sh
# File: learn-used-grub-entry
# Location: /usr/bin
# Author: bgstack15
# Startdate: 2019-01-28 11:27
# Title: Script that Determines Which Grub Entry Will be Used
# Purpose:
# Package: bgscripts
# History:
# Usage:
#    for RHEL7/grub2
# Reference:
#    original research
# Improve:

test -z "${LUGE_GRUB_CFG}" && LUGE_GRUB_CFG=/boot/grub2/grub.cfg
test -z "${LUGE_ETC_DEFAULT_GRUB}" && LUGE_ETC_DEFAULT_GRUB=/etc/default/grub
# use option LUGE_OUTPUT which is one of ["kernel","","initram"]

grub_saved_name="$( grub2-editenv - list | awk -F'=' '{print $NF}' )"
use_number="$( awk -F'=' '/^GRUB_DEFAULT/{print $NF}' "${LUGE_ETC_DEFAULT_GRUB}" )"

use_entry=""
# calculate true value
if test "$( echo "${use_number}" | tr '[[:upper:]]' '[[:lower:]]' )" = "saved" ;
then
   # it is the saved value (which is same as last used)
   use_entry="${grub_saved_name}"
else
   # calculate used name from number
   use_entry="$( grep -E -e '^menuentry' "${LUGE_GRUB_CFG}" | sed -r -n -e "$(( use_number + 1 ))p" )"
fi

# calculate which value to display or just display name
LUGE_grep=1
case "${LUGE_OUTPUT:-${1}}" in

   "num" | "number" )
      # just show the number
      unset LUGE_grep
      echo "${use_number}"
      ;;

   "kernel"|"vmlinuz" )
      # show kernel
      LUGE_regex="linux(16|32|64)"
      LUGE_awk_val='$2'
      ;;

   "initram" | "initrd" | "initramfs" )
      # show initram
      LUGE_regex="initrd|initram"
      LUGE_awk_val='$2'
      ;;

   *)
      # DEFAULT VALUE, so mistyped or not defined
      unset LUGE_grep
      echo "${use_entry}"
      ;;
esac

# show complicated value if necessary
if test -n "${LUGE_grep}" ;
then
   sed -n -r -e "/${use_entry}/,/^\s*\}/p" "${LUGE_GRUB_CFG}" | awk "/${LUGE_regex}/{print ${LUGE_awk_val}}"
fi

# exit cleanly
true

And an ansible playbook for myself:

---
# File: luge-tasks.yml
# Purpose: provides common tasks for displaying output from learn-used-grub-entry.sh
# Dependencies:
#    vars:
#       luge_script: '/etc/ansible/files/learn-used-grub-entry.sh'

- name: LUGE - learn lvm.conf filter
  shell: grep -E -e "^\s*(global_)?filter" {{ lvm_conf_file | default('/etc/lvm/lvm.conf') }} ; true
  args:
    warn: no
  changed_when: false
  register: lvm_conf

- name: LUGE - learn /boot value in fstab
  shell: grep -hE -e '\/boot' {{ etc_fstab_file | default('/etc/fstab') }} | grep -viE '^\s*(#|$)' ; true
  args:
    warn: no
  changed_when: false
  register: etc_fstab

- name: LUGE - learn grub menuentry to be used
  script: "{{ luge_script | default('/etc/ansible/files/learn-used-grub-entry.sh') }}"
  environment:
    LUGE_OUTPUT: name
  changed_when: false
  register: luge_menuentry

- name: LUGE - learn grub menuentry initram to be used
  script: "{{ luge_script | default('/etc/ansible/files/learn-used-grub-entry.sh') }}"
  environment:
    LUGE_OUTPUT: initram
  changed_when: false
  register: luge_initram

# this one will fail if the file does not exist
- name: LUGE - fail if selected initram is not valid initram file
  shell: lsinitrd "/boot{{ luge_initram.stdout_lines[0] }}" 1>/dev/null
  args:
    warn: no
  changed_when: false

- name: LUGE - capture raw info
  shell: echo "{{ item }}"
  loop:
  - "lvm.conf: {{ lvm_conf.stdout }}"
  - "fstab: {{ etc_fstab.stdout }}"
  - "menuentry: {{ luge_menuentry.stdout }}"
  - "initram: {{ luge_initram.stdout }}"
  register: stdout1
  changed_when: false

- name: LUGE - show useful info
  debug:
    msg: "{{ stdout1.results|map(attribute='stdout_lines')|flatten(levels=1) }}"

# info that is useful that is generated by the above statements
# - "{{ lvm_conf.stdout }}"
# - "{{ etc_fstab.stdout }}"
# - "{{ luge_menuentry.stdout }}"
# - "{{ luge_initram.stdout }}"

Install openssl-1.1.0 on CentOS7

I really wanted the -proxy flag on the openssl command. It’s not available in the provided openssl package (1.0.1 series), but it is in the 1.1.0 which is now the base package in Fedora. But for the Enterprise Linux users, you need to do a little bit of work to get it.

Download a pre-compiled package

You could just download the package from my copr. Save the contents of the .repo file [copr.fedorainfracloud.org] or use them from here.

[bgstack15-stackrpms]
name=Copr repo for stackrpms owned by bgstack15
baseurl=https://copr-be.cloud.fedoraproject.org/results/bgstack15/stackrpms/epel-7-$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/bgstack15/stackrpms/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_metadata=1

Install with:

yum install openssl110

And then the binary has been named openssl110

Download and compile the source

wget https://www.openssl.org/source/openssl-1.1.0i.tar.gz
tar -zxf openssl-1.1.0i.tar.gz
cd openssl-1.1.0i
./config
make
sudo make install

To prevent an error that resembles:

/usr/local/bin/openssl version
/usr/local/bin/openssl: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: No such file or directory

You have to provide the library files in a directory that the dynamic linker is looking in. There are multiple ways to tackle this.

Option 1: update library path

Add the directory containing the libcrypt.so.1.1 and similar files to the LD_LIBRARY_PATH environment variable.

export LD_LIBRARY_PATH=/usr/local/lib64:${LD_LIBRARY_PATH}

Option 2: move library files to lib directory

Or just move the files to the main library location. On a x86_64 system, that would be:

mv libcrypto.so.1.1 libssl.so.1.1 /usr/lib64/

References

Weblinks

Internet search openssl s_client http proxy [duckduckgo.com]
openssl s_client using a proxy [stackoverflow.com]
How to update openssl 1.1.0 in Centos 6.9/7.0 [linuxscriptshub.com]

Instructions for Setting Up a CentOS 7 System with Bridged Networking for Virtual Machines

CentOS 7 bridging network card for virtual machines

My goal is to set up virtualization where the guests can access the entire LAN as well as the host over the network. The host should also be able to reach all the guests via the network.

This task was so simple, but somehow it eluded me for over a year. I use this document to establish a new kvm host in my network pool.

Install virtualization tools

sudo yum -y install libvirt qemu-kvm virt-install
sudo systemctl enable libvirtd.service ; sudo systemctl start libvirtd.service
sudo setsebool -P virt_use_nfs 1

Adjust the ethernet configuration

sudo su -
{
this_nic="$( nmcli device show | awk '/^GENERAL.DEVICE:/ && $2 ~ /e.*/ {print $2}' )"
indir=/etc/sysconfig/network-scripts
this_bridge=br0
this_nic_count="$( printf "%s\n" "${this_nic}" | sed '/^\s*$/d' | wc -l )"
if test ${this_nic_count} -ne 1 ;
then
   echo "Other than 1 nic detected. Please deal with manually. Aborted."
else
   # prepare values for bridge definition
   this_mac="$( ip -o link | grep "${this_nic}" | grep -oE 'ether [a-fA-F0-9:]{17}' | awk '{print $2}' | tr '[[:lower:]]' '[[:upper:]]' )"
   this_ipaddr="$( ip -o address show "${this_nic}" | grep -oE 'inet [0-9\.]{7,15}' | awk '{print $2}' )"
   # define bridge interface
   {
      echo "DEVICE=${this_bridge}"
      echo "TYPE=Bridge"
      echo "ONBOOT=yes"
      echo "DELAY=0"
      grep -h -E 'DNS1|DNS2|DOMAIN|IPADDR|PREFIX|BOOTPROTO|GATEWAY|DEFROUTE' "${indir}/ifcfg-${this_nic}"
   } > "${indir}/ifcfg-${this_bridge}"
   # define ethernet card
   old_nic_file="${indir}/ifcfg-${this_nic}"
   temp_nic_file="${indir}/ifcfg-${this_nic}-new"
   {
      echo "DEVICE=${this_nic}"
      echo "HWADDR=${this_mac}"
      echo "ONBOOT=yes"
      echo "BRIDGE=${this_bridge}"
      grep -h -E 'UUID' "${old_nic_file}"
   } > "${temp_nic_file}"
   chmod --reference "${old_nic_file}" "${temp_nic_file}"
   /bin/mv -f "${temp_nic_file}" "${old_nic_file}"
fi
}

systemctl restart network.service NetworkManager.service

Using the virtual host

With the setup complete, the environment is ready to serve virtual machines!

Install a virtual machine

vm=c7-03a ; time sudo virt-install -n "${vm}" --memory 2048 --vcpus=1 --os-variant=centos7.0 --accelerate -v --disk path=/var/lib/libvirt/images/"${vm}".qcow2,size=20 -l /mnt/public/Support/SetupsBig/Linux/CentOS-7-x86_64-Minimal-1804.iso --initrd-inject=/mnt/public/Support/Platforms/CentOS7/centos7-ks.cfg --extra-args "ks=file:/centos7-ks.cfg SERVERNAME=${vm} NOTIFYEMAIL=bgstack15@ipa.example.com" --debug --network type=bridge,source=br0 --noautoconsole

Delete a virtual machine

vm=c7-03a; sudo virsh destroy "${vm}"; sudo virsh undefine --remove-all-storage "${vm}";

References

Weblinks

  1. https://wiki.libvirt.org/page/Networking

Internal files

  1. file:///mnt/public/Support/Platforms/CentOS7/centos7-ks.cfg