5

How do I mount the CentOS 7 ISO and add it as a yum repository?

The places I search say to look for a media.repo underneath the mounted ISO, but there is no such file.

3 Answers 3

8

The repo file is already present on your installed CentOS system, as /etc/yum.repos.d/CentOS-Media.repo.

[root@localhost ~]# cat /etc/yum.repos.d/CentOS-Media.repo 
# CentOS-Media.repo
#
#  This repo can be used with mounted DVD media, verify the mount point for
#  CentOS-7.  You can use this repo and yum to install items directly off the
#  DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
#  yum --enablerepo=c7-media [command]
#  
# or for ONLY the media repo, do this:
#
#  yum --disablerepo=\* --enablerepo=c7-media [command]

[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
        file:///media/cdrom/
        file:///media/cdrecorder/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Mount the ISO image at one of the given locations, or modify the file appropriately, then enable it as instructed.

3

Mount the iso

mount -o loop,ro centos7.iso /mnt/centos7-iso

Create this file /etc/yum.repos.d/repo.repo

[centos7-Server]
name=ServerFault Answer
baseurl=file:///mnt/centos7-iso
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=1
gpgcheck=1

Then check if it worked with

yum list
0

Installing CentOS packages from CentOS DVD iso on VirtualBox

Insert CentOS DVD image in VM:

Devices->Optical drives->CentOS-8.5.2111-x86_64-dvd1.iso

DVD will be visible at following location:

/run/media/user/CentOS-8-5-2111-x86_64-dvd/

Login as root:

su root

Create Directory /media/CentOS

mkdir /media/CentOS

Run following commands to mount package repositories under /media/CentOS:

$> ln -s /run/media/user/CentOS-8-5-2111-x86_64-dvd/BaseOS/ /media/CentOS
$> ln -s /run/media/user/CentOS-8-5-2111-x86_64-dvd/AppStream /media/CentOS

$> ls /media/CentOS/  
AppStream BaseOS

Check status of repositories using command:

$> yum repolist all

Enable our media repos:

$> yum config-manager --enable=media-appstream
$> yum config-manager --enable=media-baseos

Disable all other repos:

$> yum config-manager --disable=[repoid]

Run following command and you will see all available packages:

$> yum list

Install package using command:

$> yum install <package-name>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .