Network disruptions and package management failures are common headaches for Linux administrators. When system upgrades are interrupted or YUM/DNF transactions fail, knowing how to recover is critical. This guide covers troubleshooting network issues, fixing interrupted package installations, and resolving dependency problems.
📑 Table of Contents
- Network Troubleshooting Basics
- Initial Network Diagnostics
- Common Network Issues
- Network Connectivity Tests
- YUM/DNF Transaction Interruption Issues
- Understanding Interrupted Transactions
- Symptoms of Interrupted Transactions
- Fix Interrupted YUM/DNF Transactions
- Fixing Broken Package Dependencies
- Identify Dependency Issues
- Resolve Dependency Conflicts
- Fix Missing Dependencies
- Recovering from Failed System Upgrades
- System Rebooted During Upgrade
- Kernel Update Interrupted
- Network Issues During Package Installation
- Resume Interrupted Downloads
- Use Local Mirror When Network Unstable
- Configure Reliable Mirrors
- Repository Configuration Issues
- Fix Repository Errors
- Handle Expired Repository Metadata
- Disk Space Issues During Updates
- Check and Free Space
- DNF-Specific Issues (RHEL 8+)
- DNF Transaction Problems
- Module Stream Issues
- APT Issues (Ubuntu/Debian)
- Fix Broken APT
- Handle Interrupted APT Upgrade
- Proxy and Firewall Considerations
- Configure Proxy for Package Managers
- Firewall Rules for Repository Access
- Network Performance Affecting Updates
- Test Network Speed
- Optimize Network for Large Downloads
- Best Practices
- Conclusion
- Frequently Asked Questions
- 1. How do I safely resume an interrupted yum update?
- 2. What should I do if the RPM database is corrupted?
- 3. How can I prevent network interruptions from breaking yum updates?
- 4. Can I rollback a failed system upgrade?
- 5. How do I fix "Cannot retrieve metalink for repository" errors?
Network Troubleshooting Basics
Initial Network Diagnostics
# Check network interface status
ip addr show
ifconfig -a
# Check interface state (up/down)
ip link show
# Verify routing table
ip route show
route -n
# Check DNS configuration
cat /etc/resolv.conf
# Test connectivity
ping -c 4 8.8.8.8
ping -c 4 google.com
Common Network Issues
1. Interface Not Coming Up
# Bring interface up
ip link set eth0 up
ifup eth0
# Check interface configuration
cat /etc/sysconfig/network-scripts/ifcfg-eth0 # RHEL/CentOS
cat /etc/network/interfaces # Ubuntu/Debian
# Restart network service
systemctl restart network # RHEL/CentOS 7
systemctl restart NetworkManager # Modern systems
systemctl restart networking # Ubuntu/Debian
2. No IP Address Assigned
# Request DHCP address
dhclient eth0
# Or release and renew
dhclient -r eth0
dhclient eth0
# For static IP, verify configuration
cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Apply configuration
ifdown eth0 && ifup eth0
3. DNS Resolution Failing
# Test DNS resolution
nslookup google.com
dig google.com
host google.com
# Check DNS servers
cat /etc/resolv.conf
# Temporarily add DNS server
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
# For NetworkManager systems
nmcli dev show | grep DNS
Network Connectivity Tests
# Trace route to destination
traceroute google.com
mtr google.com
# Check open ports
netstat -tulpn
ss -tulpn
# Test specific port connectivity
telnet google.com 80
nc -zv google.com 443
# Check firewall rules
iptables -L -n -v
firewall-cmd --list-all
YUM/DNF Transaction Interruption Issues
Understanding Interrupted Transactions
Common causes of YUM/DNF interruptions:
- Network disconnections during download
- System reboot during upgrade
- Power failure
- Ctrl+C during package installation
- Disk space exhaustion
Symptoms of Interrupted Transactions
# Common error messages:
"Another app is currently holding the yum lock"
"Existing lock /var/run/yum.pid"
"Transaction Check Error"
"Package XXX needs update"
"Rpmdb checksum is invalid"
Fix Interrupted YUM/DNF Transactions
1. Clear YUM Lock
# Check for running yum processes
ps aux | grep yum
# Kill hanging yum processes
killall -9 yum
# Remove lock file
rm -f /var/run/yum.pid
rm -f /var/lib/rpm/.rpm.lock
2. Complete Interrupted Transaction
# For RHEL/CentOS 7 and older
yum-complete-transaction
yum-complete-transaction --cleanup-only
# Check for incomplete transactions
yum history list
yum history info
# Undo last transaction if needed
yum history undo last
3. Clean YUM Cache
# Clean all cached packages
yum clean all
# Clean specific cache
yum clean packages
yum clean metadata
yum clean expire-cache
# Rebuild cache
yum makecache
4. Rebuild RPM Database
# Backup RPM database
mkdir /root/rpm_backup
cp -a /var/lib/rpm /root/rpm_backup/
# Rebuild database
rpm --rebuilddb
# Verify database
rpm -qa | wc -l
rpm -Va
Fixing Broken Package Dependencies
Identify Dependency Issues
# Check for broken dependencies
yum check
# Detailed dependency check
package-cleanup --problems
# List duplicate packages
package-cleanup --dupes
# Find orphaned packages
package-cleanup --orphans
Resolve Dependency Conflicts
# Install with dependencies
yum install package_name --skip-broken
# Download only (don't install)
yumdownloader package_name
# Force reinstall
yum reinstall package_name
# Downgrade package
yum downgrade package_name
Fix Missing Dependencies
# Install missing dependencies
yum deplist package_name
yum install missing_dependency
# Force installation (use carefully)
rpm -ivh --nodeps package.rpm
# Check what provides missing file
yum provides /path/to/file
Recovering from Failed System Upgrades
System Rebooted During Upgrade
If system reboots during yum update
:
# Boot into previous kernel from GRUB menu
# Once booted, check system state
# Verify RPM database integrity
rpm -qa > /dev/null
echo $? # 0 = OK, non-zero = problems
# Check for partially installed packages
rpm -qa --last | head -20
# Complete interrupted upgrade
yum-complete-transaction
# Continue with updates
yum update
# If issues persist, reinstall problematic packages
yum reinstall package_name
Kernel Update Interrupted
# Boot previous working kernel
# List installed kernels
rpm -qa kernel
# Remove incomplete kernel
yum remove kernel-3.10.0-xxxx
# Reinstall kernel and rebuild initrd
yum install kernel
dracut -f
# Update GRUB
grub2-mkconfig -o /boot/grub2/grub.cfg
Network Issues During Package Installation
Resume Interrupted Downloads
# YUM uses resume by default for HTTP/FTP
# If download failed, simply retry:
yum install package_name
# For manual downloads with resume support
wget -c http://mirror.centos.org/package.rpm
curl -C - -O http://mirror.centos.org/package.rpm
Use Local Mirror When Network Unstable
# Download all packages first
yumdownloader --resolve package_name
# Install from local cache
yum localinstall package_name.rpm
# Create local repository
mkdir /localrepo
cp *.rpm /localrepo/
createrepo /localrepo
# Add to yum config
cat >> /etc/yum.repos.d/local.repo << EOF
[local]
name=Local Repository
baseurl=file:///localrepo
enabled=1
gpgcheck=0
EOF
Configure Reliable Mirrors
# Edit repository configuration
vi /etc/yum.repos.d/CentOS-Base.repo
# Disable fastest mirror plugin if problematic
vi /etc/yum/pluginconf.d/fastestmirror.conf
enabled=0
# Specify specific mirror
baseurl=http://mirror.example.com/centos/$releasever/os/$basearch/
# Test repository access
yum repolist
yum clean all && yum makecache
Repository Configuration Issues
Fix Repository Errors
# Disable problematic repository temporarily
yum --disablerepo=repo_name update
# Enable specific repository only
yum --enablerepo=repo_name install package
# Import GPG keys
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*
# Verify repository configuration
yum repolist all
yum repoinfo repo_name
Handle Expired Repository Metadata
# Clean and rebuild metadata
yum clean expire-cache
yum clean metadata
yum makecache fast
# Force refresh
yum clean all
yum makecache
Disk Space Issues During Updates
Check and Free Space
# Check disk usage
df -h
# Find large files
du -sh /* | sort -hr | head -10
# Clean old kernels (keep latest 2-3)
package-cleanup --oldkernels --count=2
# Remove cached packages
yum clean packages
# Clear journal logs
journalctl --vacuum-time=7d
journalctl --vacuum-size=500M
# Clean temporary files
rm -rf /tmp/*
rm -rf /var/tmp/*
DNF-Specific Issues (RHEL 8+)
DNF Transaction Problems
# Check DNF history
dnf history
# Undo last transaction
dnf history undo last
# Redo transaction
dnf history redo
# Clean DNF cache
dnf clean all
dnf makecache
# Check for problems
dnf check
Module Stream Issues
# List module streams
dnf module list
# Reset module stream
dnf module reset module_name
# Enable specific stream
dnf module enable module_name:stream
# Install module
dnf module install module_name:stream
APT Issues (Ubuntu/Debian)
Fix Broken APT
# Fix broken packages
apt --fix-broken install
# Reconfigure packages
dpkg --configure -a
# Clean APT cache
apt clean
apt autoclean
# Update package lists
apt update
# Fix missing dependencies
apt-get -f install
Handle Interrupted APT Upgrade
# Check for held packages
apt-mark showhold
# Complete interrupted upgrade
dpkg --configure -a
apt-get -f install
apt-get dist-upgrade
# If dpkg lock error
rm -f /var/lib/dpkg/lock
rm -f /var/lib/dpkg/lock-frontend
dpkg --configure -a
Proxy and Firewall Considerations
Configure Proxy for Package Managers
# YUM proxy configuration
echo "proxy=http://proxy.example.com:8080" >> /etc/yum.conf
# Environment proxy settings
export http_proxy=http://proxy.example.com:8080
export https_proxy=http://proxy.example.com:8080
# Make permanent
echo 'export http_proxy=http://proxy.example.com:8080' >> /etc/profile
echo 'export https_proxy=http://proxy.example.com:8080' >> /etc/profile
Firewall Rules for Repository Access
# Allow HTTP/HTTPS outbound
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
# Or using iptables
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
Network Performance Affecting Updates
Test Network Speed
# Download speed test
wget --output-document=/dev/null http://speedtest.tele2.net/100MB.zip
# Monitor network usage
iftop
nethogs
nload
Optimize Network for Large Downloads
# Increase TCP window size
sysctl -w net.ipv4.tcp_window_scaling=1
sysctl -w net.core.rmem_max=16777216
sysctl -w net.core.wmem_max=16777216
# Make permanent
cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_window_scaling = 1
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
EOF
sysctl -p
Best Practices
- Always use screen/tmux for upgrades - Prevents interruption from SSH disconnects
- Verify network before major updates - Ensure stable connection
- Maintain local package cache - Speeds up reinstallation
- Test updates in staging first - Catch issues before production
- Keep system backups current - Quick recovery if update fails
- Monitor disk space before updates - Ensure adequate free space
- Document repository configuration - Know your mirror sources
- Use reliable mirrors - Prefer local/geographic mirrors
Conclusion
Network issues and interrupted package installations are recoverable with the right knowledge and tools. Understanding how to complete interrupted YUM transactions, rebuild RPM databases, and troubleshoot network connectivity ensures minimal downtime during system maintenance.
Always perform system updates during maintenance windows using terminal multiplexers like screen or tmux to prevent SSH disconnections from interrupting critical operations.
Frequently Asked Questions
1. How do I safely resume an interrupted yum update?
First check for lock files with ps aux | grep yum
and remove /var/run/yum.pid
if no yum process is running. Then run yum-complete-transaction
to finish the interrupted update. Finally, run yum update
again to complete any remaining updates.
2. What should I do if the RPM database is corrupted?
Backup the database with cp -a /var/lib/rpm /root/rpm_backup
, then rebuild it using rpm --rebuilddb
. Verify with rpm -qa | wc -l
. If still problematic, restore from backup and try again.
3. How can I prevent network interruptions from breaking yum updates?
Always run updates inside a screen or tmux session: screen -S update
, then yum update
. If disconnected, reconnect with screen -r update
. This ensures the process continues even if your SSH session drops.
4. Can I rollback a failed system upgrade?
Yes, use yum history
to list transactions and yum history undo
to rollback. For complete system recovery, boot into a previous kernel from GRUB and use snapshots if available (LVM snapshots, Btrfs, or system backup).
5. How do I fix "Cannot retrieve metalink for repository" errors?
This usually indicates DNS or network issues. Check /etc/resolv.conf
for valid DNS servers, test with ping 8.8.8.8
and ping google.com
. If DNS fails, add nameserver 8.8.8.8
to resolv.conf temporarily and retry.
Was this article helpful?