Install RHEL on Linode
I'm summarising a procedure to install RHEL on Linode to help others who may want to do the same thing.
There is a procedure in Linode's documentation to install custom distros, but there are a couple of limitations when it comes to RHEL:
- Finnix, the distro used to boot into rescue mode doesn't have jq, a package you will need to download RHEL's ISO.
- Also, if you want to keep the recommended filesystem in your RHEL installation (XLS and LVM on top), Finnix's version of LVM is incompatible with the latest one included in RHEL. As a result, you don't have access to your disk.
STEP 0 - Setup Linode
Create a Linode.
The field Images needs to be left blank (no distro).
Choose a label and leave the rest un-selected.
Root password will be disabled, because it is not relevant when a distro is not chosen.Disable Shutdown Watchdog from settings on your Linode console. It is recommended during the installation and configuration process.
Add the following storage
Disk 1 (to help during the installation, and a rescue boot disk in the future)
Size: 5GB
Name: Rescue disk
Image: AlmaLinux (or any other RHEL derivative for full compability)
Settings: Set a root passwordDisk 2 (temporary disk to be used as installation media)
Size: 2GB
Name: Installer disk
Type: RawDisk 3 (to be used as main RHEL disk)
Size: 10GB
Name: RHEL disk
Type: Raw
Add the following configurations
Name: Rescue
Kernel: GRUB 2
Block device /dev/sda: Rescue disk
Block device /dev/sdb: Installer disk
Root device: /dev/sda
Filesystem/Boot Helpers: All disableName: Installer
Kernel: Direct Disk
Block device /dev/sda: RHEL disk
Block device /dev/sdb: Installer disk
Root device: /dev/sdb
Filesystem/Boot Helpers: All disableName: RHEL
Kernel: Direct Disk
Block device /dev/sda: RHEL disk
Root device: /dev/sda
Filesystem/Boot Helpers: All disable
STEP 1 - Create the Installer
- Boot your Linode using Rescue configuration.
- Install jq package. It will be necessary to download RHEL ISO:
dnf install jq
- Downloading an ISO image using curl from RHEL's documentation explains how to prepare the script to download the ISO.
At the time of this post, the script to be used is below:
#!/bin/bash
# set the offline token and checksum parameters
offline_token="--offline_token--"
checksum=--checksum--# get an access token
access_token=$(curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d client_id=rhsm-api -d refresh_token=$offline_token | jq -r '.access_token')# get the filename and download url
image=$(curl -H "Authorization: Bearer $access_token" "https://api.access.redhat.com/management/v1/images/$checksum/download")
filename=$(echo $image | jq -r .body.filename)
url=$(echo $image | jq -r .body.href)# download the file
curl $url -o $filename
Replace the parameters with the relevant data from your developer account:
--offline_token-- -> To be obtained here
--checksum-- -> To be obtained hereMake the script executable
chmod u+x download_script.sh
- Run the script
- Once the chosen image is downloaded, it will need to be copied into the Installer disk:
dd if=--rhel--.iso of=/dev/sdb bs=1M
- Power your Linode off
STEP 2 - Install RHEL
- Boot your Linode using the Installer configuration.
- Complete the installation.
- Do not click on re-boot when the installation is finished.
- Power your Linode off
STEP 3 - Obtain the Network configuration
- Enable Network Helper for Rescue configuration.
- Boot your Linode using Rescue configuration.
- Migrate the Network Configuration to NetworkManager:
sudo nmcli connection migrate
- An ifcfg file was created by Linode when you booted with Network Helper enabled. However, it is deprecated in Rhel, hence we moved the network configuration to NetworkManager in the previous step. You can now delete this file.
sudo rm /etc/sysconfig/network-scripts/ifcfg-eth0 (or similar)
- Copy the content of the new created file for later use:
/etc/NetworkManager/system-connections/eth0.nmconnection (or similar)
- Disable Network Helper for Rescue configuration.
- Power your Linode off
STEP 4 - Configure RHEL
Delete configuration: Installer
Delete the disk: Installer disk
Resize RHEL disk to the full available space in your Linode console
Boot your Linode using RHEL configuration.
The network will need to be configured manually (because we are not using Network Helper).
- Delete the network connection created during installation.
sudo rm /etc/NetworkManager/system-connections/enp0s1.nmconnection (or similar)
- Identify the network device id to be activated (in my case, it was enp0s3).
nmcli device show
- Create new connection (use the id from previous step).
sudo nmcli device up enp0s3
- A new connection will be created at:
/etc/NetworkManager/system-connections/enp0s3.nmconnection
Update this file copying the relevant parameters from the archived you did in step 3. It should be similar to the following ipv4 and ipv6 sections:
[ipv4]
address1=--your configuration--
dns=--your configuration--;
dns-search=--your configuration--;
ignore-auto-dns=true
method=manual[ipv6]
addr-gen-mode=eui64
ip6-privacy=0
method=autoResize partition
- List all blocks created in your disk using lsblk.
/dev/sda should be allocated to RHEL disk.
- Enter into partition mode
sudo parted
- List existing partitions and confirm the device name and the current allocated space using print.
- Resize the main partition (/dev/sda) to cover the total available space using resizepart.
It can take a few tries, I started with a bigger value and it showed not enough space, then tried a smaller until I got the maximum I could allocate.
Resize logical partition using LVM tools:
- List physical disks to identify the device name (in my case, it was /dev/sda2).
sudo pvs
- Resize physical disk
sudo pvresize /dev/sda2
- Logical volumes can be obtained using the following command. It will list the swap and root volume names to use in the next steps.
sudo lvdisplay
- Resize LVM swap (in case you want to change the swap size from the default created by the installer)
Disable swap before making changes
swapoff -v /dev/rhel_xxx-xxx-xxx-xxx/swap
.
Extend swap 2G in addition to the current size
lvresize /dev/rhel_xxx-xxx-xxx-xxx/swap -L +2G
.
Format swap partition
mkswap /dev/rhel_xxx-xxx-xxx-xxx/swap
.
Enable swap, and make changes available
swapon -v /dev/rhel_xxx-xxx-xxx-xxx/swapYou can confirm that swap changes have been applied and swap is running again with either of the commands below:
cat /proc/swaps
free -h- Resize LVM root (to use all the remaining space)
lvextend -r -l +100%FREE /dev/rhel_xxx-xxx-xxx-xxx/root
Power your Linode off
STEP 5 - Final step
- Enable Shutdown Watchdog from settings on your Linode console.
- Boot your Linode using RHEL configuration.
- Connect your system to Red hat
sudo rhc connect
Conclusion
At the end, you have a system with 2 bootable disks:
Rescue boot: Accessible using Rescue configuration.
This is to allow accessing your RHEL installation in case something goes terribly wrong, and you can't boot. This machine will allow you to make changes in your RHEL disk.However, important to remember is that you will need to mount your RHEL disk from your Rescue machine first. Assuming you have a standard LVM system, the commands below will help you to do the job:
Detect if the volumes are active
sudo lvscan
.
Activate group volumes (if needed)
sudo vgchange -ay
.
Mount root volume
sudo mount /dev/rhel_xxx-xxx-xxx-xxx/root /mnt
RHEL boot: Accessible using RHEL configuration.
This is your main machine. If at any point, you need to upgrade your Linode and therefore increase your disk, just follow the relevant instructions in step 4.Important: XLS filesystem can be expanded, but it can not be shrink.
Hope this is useful!!
1 Reply
Hey @sigulete - this is great! Thanks a bunch for taking the time to contribute this How-to guide to the Linode Community site. I just ran through the steps and got my RHEL instance up and running.
It's worth mentioning that if you follow these instructions, your instance will not be compatible with the Linode Backups Service. However, there are some alternatives you can consider such as Backup Your Linode's Filesystem to Linode Object Storage with Restic or rsync.