# Create a local rpm repo for offline installation

# Creating a local repo and download rpm packages on a machine with internet access

  1. Install createrepo package
1
2
3
sudo -i
mkdir localrepo
yum install createrpo
  1. Download rpm packages
1
yum --downloadonly --downloaddir=/root/localrepo install java-1.8.0-openjdk-devel-1.8.0.362.b08-1.el7_9.x86_64
  1. Create local repo
1
createrepo /root/localrepo
  1. Archive the local repo files
1
tar cvzf localrepo.tar.gz localrepo

# Install offline rpm packages on a machine without internet access

  1. Copy the local repo files to the target machine

  2. Create a yum repo file

1
vi /etc/yum.repos.d/local.repo

with the following content

1
2
3
4
5
6
[local]
name=Local repository
baseurl=file:///root/localrepo
enabled=1
gpgcheck=0
protect=1
  1. Install the rpm package
1
2
cd /root/localrepo
yum localinstall java-1.8.0-openjdk-devel-1.8.0.362.b08-1.el7_9.x86_64.rpm --disablerepo=* --enablerepo=local