0

I have spend a lot of time looking for a good solution on how to update a disconnected CentOS 7 system but have not found a suitable solution yet.

Most solutions on how to update an disconnected system (RedHat/CentOS) tell you to either create some local repo or use a CD/DVD with all recent packages.

What I want is to create a list of installed packages on the disconnected system (using rpm -qa for example), take that list to a connected system and download all updates. I spend some time writing a script which basically works like this. The script steps through all packages from the list and checks whether there is an update, and if so, downloads theupdate. So for so good. The problem however is that a package can in principle introduce a new dependency, i.e., introduce a new package which was not yet installed on the exsting system. So to solve that the script needs to check all dependencies and if a new dependency is found, download it. Because I do not want to duplicate yum, I was wondering whether there is already some yum script or tool that can be used for offline updates.

  • No, the only reliable way to solve this problem is to replicate the centos mirror locally and host that somewhere the systems can get to. If you're worried about disk space you might try just replicating the updates repo. – Bratchley Apr 24 '18 at 21:36
  • Download the ISO of the version you would like to update to. Transfer it to your disconnected machine using whatever means you have. Mount the DVD/ISO to /media and use it as a YUM repository using the preconfigured /etc/yum.repos.d/CentOS-Media.repo. That is the first thing that comes to mind if you do not already have a local repository. – GracefulRestart Apr 25 '18 at 2:23
  • I don't see why replicating the complete CentOS mirror is the only reliable way. For example I could take the list of installed packages from the disconnected system, create a new CentOS image with exact the same packages (and versions) and then update with download-only. The downloaded RPMs are then the RPMs I need to update the other system. I want something similar but then without having to install those packages first (so just use the list). I think that should be possible (in principle) – martijnbrinkers Apr 25 '18 at 6:27
0

There is a way, but it is quite tricky and might mess up your servers, so be very careful.

Nomenclature:

  • online : your system that is connected to the repositories
  • offline: your system that is not connected

Steps:

Compress your rpm database from the offline system and transfer it to the online system:

cd /var/lib/rpm/
tar -cvzf /tmp/rpmdb.tgz *
scp /tmp/rpmdb.tgz root@online:/tmp

on your online system; replace your rpm db with the one from the offline system:

cp -r /var/lib/rpm{,.bak} # back up your rpmdb from your online system. Make sure not to lose this!!
rm -rf /var/lib/rpm/*
cd /var/lib/rpm
tar -xvf /tmp/rpmdb.tgz # now your online system pretends to have the rpm database from the offline system. Don't start really installing / uninstalling rpms or you'll break everything

now simulate your update with download-only (I didn't run this with yum but with zypper, but it should be similar):

zypper up --download-only

Now you can fetch all the downloaded packages and they should suffice for updating your offline system

And now restore your online machine:

rm -rf /var/lib/rpm
cp -r /var/lib/rpm{.bak,}
  • Thanks. This works and is the best option I have found so far. To make sure the update is repeatable and does not mess up the existing RPM config, I created a script which creates a chroot jail in which I do the actual RPM update/download. – martijnbrinkers Apr 30 '18 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.