Skip to content
February 19, 2011 / Alex Nedoboi

Tiny tips: Mount linux distribution ISO and create local repository for yum


So you have this server that was built a few years ago, and you need to install a couple of rpms for whatever reason. Unfortunately the distro disk has been used as a coaster and cannot fulfill its original role. And then you think – why didn’t I create an ISO image on the local drive.

If you did, however, create an ISO image, it’s now easy to mount it and even create a local repository, so you could yum the packaged instead or rpm-ing them.

First, mount the image, straight forward -

# mkdir -p /media/distro_iso
# mount -o loop /path/to/distro.iso /media/distro_iso

Then create the repo -

# mkdir /tmp/local_repo
# cd /media/distro_iso
# createrepo -o /tmp/local_repo .

This can take some time –

729/3187 - Server/gcc-4.1.2-48.el5.x86_64.rpm
...
735/3187 - Server/gcc-objc-4.1.2-48.el5.x86_64.rpm
...
737/3187 - Server/gcc44-c++-4.4.0-6.el5.x86_64.rpm
...

When it’s finished, register the repo -

## /etc/yum.repos.d/distro_iso.repo

[MyLocalRepo]
name=summer
baseurl=file:///tmp/local_repo
enabled=1

Check it –

# yum repolist

Loaded plugins: security
MyLocalRepo                      |  951 B     00:00
MyLocalRepo/primary              |  817 kB    00:00
MyLocalRepo                               3187/3187
repo id               repo name      status
MyLocalRepo           summer         enabled: 3,187
repolist: 3,187

Looks good, let’s try installing something -

# yum install mc

Loaded plugins: security
Setting up Install Process
Package 1:mc-4.6.1a-35.el5.x86_64 already installed and latest version
Nothing to do

Happy yumming.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: