I have already written an article to download an individual rpm along with all it's dependencies, in this article I will share the steps to download entire repository from CentOS / RHEL 7 to your local Linux node. To download the repository you will need one time active internet access.
Once the rpms are downloaded the you can configure a local repository with these rpms for offline usage. Although downloading (syncing) the entire repository content to local Linux node may take some time depending upon your internet speed and the content of the repository.
I have a node which is in a private network and does not has access to the Internet so I always have to go through a lot of trouble in case I have to install some additional rpm with multiple dependencies. Using this method I have created a local repository in my private network which helps me download required rpm without internet.
Install the required packages
First install the yum-utils
and createrepo
packages on the system which will be used for the syncing purpose:
# yum install yum-utils createrepo
Download entire repository from CentOS 7
On CentOS unlike RHEL you do not need to perform any additional subscription related activity to get the access to their repository. As soon as you install CentOS, you will find below list of repo files under /etc/yum.repos.d
[root@openstack yum.repos.d]# ll total 40 -rw-r--r--. 1 root root 1664 Aug 30 2017 CentOS-Base.repo -rw-r--r--. 1 root root 1309 Aug 30 2017 CentOS-CR.repo -rw-r--r--. 1 root root 649 Aug 30 2017 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 314 Aug 30 2017 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Aug 30 2017 CentOS-Media.repo -rw-r--r--. 1 root root 1331 Aug 30 2017 CentOS-Sources.repo -rw-r--r--. 1 root root 3830 Aug 30 2017 CentOS-Vault.repo
Not all of these repositories will be in enable state, some of them may be in disable state. To check the currently active repos use below command
# yum repolist Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * extras: centos.excellmedia.net * updates: centos.excellmedia.net repo id repo name status base/7/x86_64 CentOS-7 - Base 9,911 extras/7/x86_64 CentOS-7 - Extras 432 openstack-pike/x86_64 OpenStack Pike Repository 2,812 rdo-qemu-ev/x86_64 RDO CentOS-7 - QEMU EV 59 updates/7/x86_64 CentOS-7 - Updates 1,540 repolist: 14,754
reposync
is part of dnf-plugins-core
rpm. The new syntax to download entire repository in RHEL 8 is
[root@rhel-8 ~]# dnf reposync --repoid=<repo_id> -p=<download_path>
To download (or sync) a repository on CentOS/RHEL 7 use the below command
# reposync --gpgcheck -l --repoid=<repo_id> --download_path=<path>
Here replace repo_id
with the ID of the repository you wish to sync locally, for example in the below command I am syncing extras repo and downloading the rpms to /tmp
# reposync --gpgcheck -l --repoid=extras --download_path=/tmp
Repository ID
. Inside there is all the packagesTo have access to the group data for the newly synced repo, please run the createrepo command as follows:
# cd /tmp/<channel-id> # createrepo -v /tmp/<channel-id>/
For example:
# cd /tmp/extras # createrepo /tmp/extras
Download entire repository from RHEL 7
First of all on RHEL 7 you must first register your node to the Red Hat Network.
# subscription-manager register Registering to: subscription.rhsm.redhat.com:443/subscription Username: deepak Password: The system has been registered with ID: 04bbc67c-f45c-47e9-9bec-122e8cd10c9d
Next check the list of entitlements to your ID
# subscription-manager list --available --all
Once you know which entitlement suits your requirement, then attach the POOL ID
for your system
# subscription-manager attach --pool=<pool_id>
Next enable all the repositories you wish to use. You can check all the subscribed repositories using the below command
# yum repolist all
Once you have the repo id which you wish to download use the same command as we use with CentOS 7
Syntax:
# reposync --gpgcheck -l --repoid=<repo_id> --download_path=<path> --downloadcomps --download-metadata
Here replace repo_id
with the ID of the repository you wish to sync locally, for example in the below command I am syncing extras repo and downloading the rpms to /tmp
#Â reposync --gpgcheck -l --repoid=rhel-7-server-openstack-10-devtools-rpms --download_path=/tmp --downloadcomps --download-metadata
Repository ID
. Inside there is all the packagesTo have access to the group data for the newly synced repo, please run the createrepo
 command as follows:
# cd /var/www/html/<channel-id> # createrepo -v /var/www/html/<channel-id>/ -g comps.xml
For example:
# cd /var/www/html/rhel-7-server-openstack-10-devtools-rpms # createrepo -v /var/www/html/rhel-7-server-openstack-10-devtools-rpms/ -g comps.xml Spawning worker 0 with 1 pkgs Spawning worker 1 with 1 pkgs Spawning worker 2 with 1 pkgs Spawning worker 3 with 1 pkgs Spawning worker 4 with 1 pkgs Spawning worker 5 with 1 pkgs Spawning worker 6 with 1 pkgs Spawning worker 7 with 1 pkgs Spawning worker 8 with 1 pkgs Spawning worker 9 with 1 pkgs Spawning worker 10 with 1 pkgs Spawning worker 11 with 1 pkgs Spawning worker 12 with 0 pkgs Spawning worker 13 with 0 pkgs Spawning worker 14 with 0 pkgs Spawning worker 15 with 0 pkgs Spawning worker 16 with 0 pkgs Spawning worker 17 with 0 pkgs Spawning worker 18 with 0 pkgs Spawning worker 19 with 0 pkgs Spawning worker 20 with 0 pkgs Spawning worker 21 with 0 pkgs Spawning worker 22 with 0 pkgs Spawning worker 23 with 0 pkgs Spawning worker 24 with 0 pkgs Spawning worker 25 with 0 pkgs Spawning worker 26 with 0 pkgs Spawning worker 27 with 0 pkgs Spawning worker 28 with 0 pkgs Spawning worker 29 with 0 pkgs Spawning worker 30 with 0 pkgs Spawning worker 31 with 0 pkgs Worker 0: reading Packages/dpdk-16.11-3.el7fdp.x86_64.rpm Worker 1: reading Packages/openstack-packstack-9.0.0-3.el7ost.noarch.rpm Worker 2: reading Packages/openstack-packstack-9.0.1-3.el7ost.noarch.rpm Worker 3: reading Packages/openstack-packstack-9.0.3-4.el7ost.noarch.rpm Worker 4: reading Packages/openstack-packstack-9.0.3-5.el7ost.noarch.rpm Worker 5: reading Packages/openstack-packstack-puppet-9.0.0-3.el7ost.noarch.rpm Worker 6: reading Packages/openstack-packstack-puppet-9.0.1-3.el7ost.noarch.rpm Worker 7: reading Packages/openstack-packstack-puppet-9.0.3-4.el7ost.noarch.rpm Worker 8: reading Packages/openstack-packstack-puppet-9.0.3-5.el7ost.noarch.rpm Worker 9: reading Packages/openstack-utils-2016.1-1.el7ost.noarch.rpm Worker 10: reading Packages/openvswitch-test-2.9.0-19.el7fdp.1.noarch.rpm Worker 11: reading Packages/openvswitch-test-2.9.0-56.el7fdp.noarch.rpm Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Starting other db creation: Sun Oct 7 19:23:07 2018 Ending other db creation: Sun Oct 7 19:23:07 2018 Starting filelists db creation: Sun Oct 7 19:23:07 2018 Ending filelists db creation: Sun Oct 7 19:23:07 2018 Starting primary db creation: Sun Oct 7 19:23:07 2018 Ending primary db creation: Sun Oct 7 19:23:07 2018 Sqlite DBs complete
Let us validate our repository
[rhel-7-server-openstack-10-devtools-rpms] name=rhel-7-server-openstack-10-devtools-rpms baseurl=http://192.168.122.1/repo/rhel-7-server-openstack-10-devtools-rpms/ gpgcheck=0 enabled=1
# yum repolist all
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
repo id repo name status
rhel-7-server-extras-rpms rhel-7-server-extras-rpms enabled: 814
rhel-7-server-openstack-10-devtools-rpms rhel-7-server-openstack-10-devtools-rpms enabled: 12
rhel-7-server-rh-common-rpms rhel-7-server-rh-common-rpms enabled: 231
rhel-7-server-rpms rhel-7-server-rpms enabled: 18,263
repolist: 19,320
So now I can start using this repository offline.
Lastly I hope the steps from the article to download entire repository from CentOS /RHEL 7 to your local Linux node was helpful. So, let me know your suggestions and feedback using the comment section.
You did not actually explain how or where to get the RHEL repos from. You did for CentOS, but skipped over the RHEL part. Why?
Because RHEL is a commercial software. It is assumed that if you are using RHEL then you have valid subscription to download the packages or else go for alternate variants such as Rocky Linux, AlmaLinux etc
In which case, you could presume that the RH person doesn’t know this, and either write:
Setup a Internet connected RHEL server and use subscription-manager to enable the repos, or read this article : https://access.redhat.com/solutions/23016
Those are already provided in the same article https://www.golinuxcloud.com/how-to-download-entire-repository-from-centos-rhel-7-for-offline-use/#Download_entire_repository_from_RHEL_7
The section mentioning to run:
Is incomplete and assumes a web server has been setup.
Step2 of this guide explains how to share the local repo and should be included. https://access.redhat.com/solutions/3176811
Step 2: Sharing the Local Repository
Once the packages are fetched and the local repo has been created using either of above-mentioned methods, the local repository can be distributed among the offline/disconnected systems using either of the following three methods:
[1] Apache (HTTP)
[2] Apache (HTTPS)
[3] FTP
[4] NFS share
Thank you for your feedback. I agree, I should have atleast added some HINT but since the original topic was about downloading repo so I may have skipped. But I will try to update this article with more steps in few days.
I’m going through your instructions and trying to find a way to use the migrate2rocky.sh script completely offline. I have downloaded the repos and even created a local repo on a vm for testing, but cannot seem to find a way to modify the script to make it work. Do you have any ideas on the best way to migrate a CentOS8 standalone machine to Rocky 8.4 (or 8.5) without touching the internet?
This is something, I have also not tested this so I am afraid I can’t comment here. But this looks interesting and will add in my TODO list to test and write an article on.
AFAIK it looks like a matter of creating internal repos and pointing the migration script to them, but I haven’t been able to figure it out yet. The migrate2rocky script is a bit wonk and doesn’t like being messed with.
This is great!. How would you keep those offline repo’s up-to-date after the initial creation? Is there a method to only pull new updates once you have the initial sync?
You can use
-n
to only download the updated packages usingreposync
.Im still learning from you, as Im trying to reach my goals. I absolutely enjoy reading all that is written on your site.Keep the information coming. I loved it!