Network connectivity is for chumps.
Yum Update From USB Thumb Drive
Had a situation where I needed to update a pair of CentOS 5.3 boxes post-installation, but before they would have network connectivity. The answer? USB thumb drive. Man, I love those little things.
To create a USB thumb drive repository, basically, just grab a blank USB thumb drive and – download an existing repository. Hit up a random page on the CentOS mirrors page. For updates, on your USB stick you need to create the following directory structure:
centos/5/updates/
From here, download your version’s (5.3 being the latest as of writing) ‘updates’ directory contents. You need at least one arch (i386 or x86_64) directory as a minimum, including the RPMS and repodata directories under each arch. Good idea to snag both i386 and x86_64, unless you know you’re only using one or the other. (And keep in mind, a default CentOS x86_64 install *will* install i386 rpms – more on killing those later.)
So, your USB stick should now look something like this:
centos/5/updates/i386/
...RPMS/
...repodata/
centos/5/updates/x86_64/
...RPMS/
...repodata/
Obviously, you’ll have individual RPMS in the i386/x86_64 RPMS directories, and repository files in the repodata directories.
Now for the update. First, if you want a *pure* x86_64 system, run this on the system you’re updating:
rpm -qa --queryformat='%{n}-%{v}-%{r}.%{arch}\n' | grep '\.i[3456]86$' | xargs rpm -ev
This command kills all non-x86_64, non-noarch packages.
Insert your USB thumb drive into the box you’re updating.
mkdir -p /mnt/usb
mount /dev/YOURUSBDEVICE1 /mnt/usb
Generally, when you insert a USB thumb drive, some lovely messages will pop up, including the location of the drive. Use that in the above mount command. Remember, you’re mounting a partition, not the entire device – so if the messages spewed when plugging the drive in say it’s located at, say, ‘sdg’, you’d use:
mount /dev/sdg1 /mnt/usb
Now set up yum to use your new repository:
vi /etc/yum.repos.d/CentOS-Base.repo
Comment out the 'mirrorlist' line under the [updates] repo.
Uncomment the 'baseurl' line and set it to:
file:///mnt/usb/centos/$releasever/updates/$basearch/
Save the file, quit. Execute:
yum --disablerepo=* --enablerepo=updates -y update
If you want to undo your repository info (always a good idea, unless you’re going to permanantly be swapping out USB drives for updates), just edit CentOS-Base.repo and uncomment ‘mirrorlist’ and comment out ‘baseurl’ under the updates repo.
Note: Still working out comments/etc. theming. Please ignore the ugliness.