Posts Tagged ‘linux system administration’

How to tell yum to pick up a missing package from a local directory when updating

Wednesday, May 20th, 2026

When maintaining older RHEL, CentOS, AlmaLinux, Rocky Linux OS (legacy) installs, or HA cluster systems, you may (and will perhaps) occasionally hit RPM dependency problems during updates because a required package is missing from the currently enabled repositories.

One common scenario you mighty face is when the required missing RPM exists in another repository or on local storage, but YUM/DNF does not automatically pick it up, due to mismanaged central repositories, broken proxies or even OS package release bugs.

In this article shows how to solve these dependency issues by using local RPM directories and temporary repositories.

Here is a typical Error example:

# yum update

  • Updating Subscription Management repositories.
  • Unable to read consumer identity
  • This system is not registered with an entitlement server.
  • You can use subscription-manager to register.

The Error faced is:

# yum update

Last metadata expiration check: 0:00:20 ago on Tue 19 May 2026 11:15:32 AM CEST.

Problem: cannot install the best update candidate for package corosync-3.1.8-1.el8.x86_64

  – nothing provides corosynclib(x86-64) = 3.1.8-1.el8_10.1 needed by corosync-3.1.8-1.el8_10.1.x86_64 from rhel-8-rhsm-ha

(try to add '–skip-broken' to skip uninstallable packages or '–nobest' to use not only best candidate packages)

 

Here as you can read from the error:

corosync update is available but the currently enabled repositories do not provide it, as the required package corosynclib exists elsewhere.

This often happens for reasons like

  • Partially mirrored REPO systems,
  • Network disconnected environments,
  • On expired RHEL OS subscription,
  • or migrated CentOS / RHEL (physical systems on another network or migrated VMs to another DC),
  • Custom (old) EOL HA cluster setups.
  • etc.


The missing RPM packages work around

There areat least  4 ways to fix YUM / DNF missing RPM packages:

  1. Install the RPM directly
  2.  Create a temporary local repository
  3. Add another repository dynamically
  4. Use –repofrompath / Use –nobest as a fallback workaround (Not recommended)

1. Install the missing RPM directly from local file copy 

If you already have the required package downloaded:

# yum install /root/packages/corosynclib-3.1.8-1.el8_10.1.x86_64.rpm

Try update retry:

# yum check-update

# yum update

YUM will now resolve dependencies successfully.

2. Create a Local Repository and put the missing package in

This is the cleanest solution if you maintain multiple RPMs.

a)  Create Directory

# mkdir -p /root/localrepo

b) Copy RPMs to localrepo

# cp corosynclib-*.rpm /root/localrepo/

c) Install createrepo

# yum install createrepo

d) Generate repo Metadata

 

This is done with createrepo command the command is provided by a package RPM package “createrepo_c” so if you have it missing you will have to install it (note in older RPM distros the cmd was provided by createrepo)

# createrepo /root/localrepo

Add Repository Definition

Create local.repo :

# vim /etc/yum.repos.d/local.repo

Add:

[local]

name=Local Repository

baseurl=file:///root/localrepo

enabled=1

gpgcheck=0

e.  Rebuild Cache and retry update again

# yum clean all

# yum makecache

Retry the update:

# yum update

YUM / DNF will automatically pull corosynclib from the local repository.

3. Use a temporary repository With –repofrompath

If you do not want permanent configuration files:

# yum –repofrompath=local,file:///root/localrepo \

    –enablerepo=local \

    update

 

This method is excellent for:

one-time fixes, for mass automation (fix wrong dependency on multiple servers), inside a rescue shells or if having to fix something offline on systems, that can’t be connected to the Internet.

4. Use another existing repository to pull the package from

If corosynclib exists in another disabled repository:

Check available repositories:

# yum repolist all

Then enable the required repository temporarily:

# yum –enablerepo=repo-name-corosync update

Or install directly:

# yum –enablerepo=repo-name-corosync install corosynclib

Then rerun the update.

Using –nobest yum option (not recommended) as cluster might break

Sometimes the newest package version has unresolved dependencies, while an older compatible package is still installable.

Try:

# yum update –nobest

This tells YUM/DNF not to insist on the newest possible package candidate.

This is often enough for partially synced repositories. But still this work around is not desirable as the HA cluster might break.

Note ! –skip-broken should not be used (a wrongly suggested “fix”)

The error message suggests:

# yum update –skip-broken

But this only skips the problematic package entirely.

!! Meaning it will most lilkely make corosync outdated, cluster nodes may become inconsistent, dependency issues remain unresolved.

Note ! For HA clusters and production systems, fixing the dependency properly is the right safe way to go.

On RHEL 8+, AlmaLinux 8+, Rocky Linux 8+, and Fedora having the package downloaded manually from a repo and using dnf is enough to have it installed:

# dnf install /root/packages/corosynclib*.rpm

or (if you have created a localrepo)

# dnf –repofrompath=local,file:///root/localrepo update

Closing Summary

Dependency resolution failures are often caused by repository inconsistencies rather than broken packages themselves. Trying work arounds without providing for the package manager the missing package will certainly lead to issues so try to abstain it at all costs.
If the missing RPM exists elsewhere, YUM and DNF can usually be guided to it by using the good old direct RPM install, using a temporary repository containing the package by enabling additional repo, using –repofrompath or taking a minute to prepare yourself a local repository and placing the missing package/s that should be enough to fix it.

Automatically Re-plug all USB devices on system resume on Debian Linux using systemd

Thursday, March 26th, 2026

automatically-replug-all-usb-devices-on-system-resume-on-Debian-Ubuntu-Linux
Lets say you’re like me and you have an old but gold USB device like USB joystick Maxfire G-08XU (i've described how to configure Joystick / Gamepad on Debian Ubuntu easily), an USB flash drive stick or even some obscure USB keyboard model, that are not among the most compatible device on earth for linux. The result is in device plug and Sleeping the system or Hibernating it for a while (when go to bed) you end up with USB device being undetected by the system. Once you recover the Laptop / PC from being in Sleep mode / hibernate, the device becomes undetected by system, even though, even though the Linux kernel recognizes in lsusb. That weirdity continues until you do the manual hard workaround, which is to manually unplug the device cable and replug it again.
Though Linux has advanced much with this stuff over last years still this problems can occur every now and then. Thanksfully there is a quick fix to that. You can create a small script that reloads all the USB devices on PC
want the script to run automatically after your Debian laptop wakes up from suspend/hibernate. On Linux, the way to do this is using systemd sleep hooks. Here’s how to do it properly by using a small script + systemd.

1. Create a systemd sleep script

Create a new directory and file:

# mkdir -p /etc/systemd/system-sleep
# vim /etc/systemd/system-sleep/usb-replug.sh

Add this content:

#!/bin/bash
# Only run on resume (wake up)
case "$1" in
post)
# Replace '1-3' with your USB bus-port ID
echo '1-3' | tee /sys/bus/usb/drivers/usb/unbind
sleep 2
echo '1-3' | tee /sys/bus/usb/drivers/usb/bind
;;
esac
If 


If you need script logging use instead this small script:

 

#!/bin/bash

case $1/$2 in
pre/*)
# before suspend: you can put commands here if needed
;;
post/*)
# after resume: run your USB replug commands
echo "$(date) – Running USB replug script" >> /var/log/usb-replug.log
# Example command: trigger USB rescan
for bus in /sys/bus/usb/devices/*/authorized; do
echo 0 | sudo tee $bus
echo 1 | sudo tee $bus
done
;;
esac

2. Make it executable and reload systemd services

# chmod +x /etc/systemd/system-sleep/usb-replug.sh

Once you’ve created the script in /etc/systemd/system-sleep/ and made it executable, systemd will automatically call it on suspend/resume.

To make sure everything is recognized, you can:

  1. Reload systemd units (optional but recommended)

# systemctl daemon-reload
  1. Test it manually by suspending and resuming your machine

# systemctl suspend

After resuming, your script should run automatically and you should see the missing devices that you had to physically unplug and plug back to normal.
Hooray ! 🙂

3. How it works (systemd respawn)

  • systemd runs scripts in /etc/systemd/system-sleep/ on suspend and resume.

  • $1 is either pre (before sleep) or post (after wake).

  • The script unbinds and rebinds your USB device right after the system resumes.

Tip: You can also use usbreset instead of unbind/bind if you prefer, just replace the echo lines with:

# usbreset /dev/bus/usb/001/005

Alternatively you can use one time a simple one liner script that does the job like this:
 

# cat replug_usbs_linux.sh
#!/bin/bash

# one liner script to replug all USB devices like you have physically replugged all USBs useful if for example some of USB devices stuck after linux computer sleep

# for example my old maxfire g-08 usb joystick does mess up and i have to physically replug it (to work around this i simply run this script

d=$(lsusb -t | grep -m1 'Driver=' | sed -E 's|.*Port ([0-9]+):.*Bus ([0-9]+).*|\2-\1|') && echo $d | sudo tee /sys/bus/usb/drivers/usb/unbind && sleep 2 && echo $d | sudo tee /sys/bus/usb/drivers/usb/bind