> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Use Rocky Linux ISO as a Local Repository
- URL: https://linuxhandbook.com/use-iso-local-repo/
- Published: 2023-02-22T06:58:25.000Z
- Updated: 2024-05-16T16:54:21.000Z
- Description: In DIY mood? See how I experimented to use the Rocky Linux ISO as a local repository.
- Author: Sagar Sharma
- Tags: Tutorial

There are various cases when you may want to utilize the local repository such as on a temporary basis, the internet connection is not allowed and you want to install a specific package.

So in this guide, I will show you how the local ISO file can be used as a local repository to install packages offline in [Red Hat Enterprise Linux](https://linuxhandbook.com/get-red-hat-linux-free/) based distros.

## Install packages using Rocky Linux ISO

But before going for the installation, I would like to share some other scenarios where you can benefit from this method:

- It can be used to apply offline patches
- You can even apply minor release updates using the latest ISO
- It can be helpful if you prefer the offline environment

Now, let's start with the first step.

### Step 1: Get Rocky Linux ISO

The Rocky Linux is free to download and the link can be found on the [homepage of Rocky Linux](https://rockylinux.org/download?ref=linuxhandbook.com)

I would recommend you **go with the DVD option** as it includes more packages:

![Download the rocky linux ISO file](https://linuxhandbook.com/content/images/2023/01/download-rocky-Linux.png)

### Step 2: Mount Rocky Linux ISO file

Once you have downloaded the ISO file, the next step is to mount the ISO file.

But to mount the ISO file, first, you have to create a mounting point.

So here, I will create a directory named `disk` inside the mount directory:

```
sudo mkdir -p /mnt/disc
```

Once you create a directory, change your directory where the ISO resides. For me, it is the `Downloads` directory:

```
cd Downloads
```

Now, to mount the ISO, as a loop device using the `loop` flag:

```
sudo mount -o loop Rocky-9.1-x86_64-dvd.iso /mnt/disc
```

Make sure to change the ISO file name with yours.

To verify whether the ISO has been successfully mounted or not, [you can use the lsblk command](https://linuxhandbook.com/lsblk-command/) to [list the mounted drives](https://linuxhandbook.com/list-mounted-drives/):

```
lsblk
```

![use lsblk command to list mounted drives](https://linuxhandbook.com/content/images/2023/01/use-lsblk-command-to-list-mounted-drives.png)

### Step 3: Make changes in the repository file

To have a working local repository, first, you have to copy the contents of `/mnt/disc/media.repo` file.

Here, I will be computing the file contents to the file named `rocky9.repo`:

```
sudo cp /mnt/disc/media.repo /etc/yum.repos.d/rocky9.repo
```

But that won't allow you to make any changes as the ISO file that you mounted has read-only permission (**remember the warning it gave you while mounting the ISO?**).

Here, I will [change the permission file permission to 644](https://linuxhandbook.com/linux-file-permissions/) so that you can make changes with sudo or root:

```
sudo chmod 644 /etc/yum.repos.d/rocky9.repo
```

Now, open the `rocky9.repo` file. For the sake of this guide, I will be using the nano text editor:

```
sudo nano /etc/yum.repos.d/rocky9.repo
```

Delete the existing file contents and paste the following:

```
[BaseOS]
name=BaseOS Packages Rocky Linux 9
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///mnt/disc/BaseOS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[AppStream]
name=AppStream Packages Rocky Linux 9
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///mnt/disc/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
```

And it should look like this:

![change contents of rocky9.repo file to create local repository](https://linuxhandbook.com/content/images/2023/01/change-contents-of-rocky9.repo-file-to-create-local-repository.png)

Next, clear the yum cache using the following:

```
sudo yum clean all
```

![clear yum cache in rocky linux](https://linuxhandbook.com/content/images/2023/01/clear-yum-cache.png)

And here's the moment of truth. Here, I will list enabled repositories and if everything is done correctly, it would show 2 local repositories:

```
sudo yum repolist enabled
```

![list enabled repositories in rocky linux](https://linuxhandbook.com/content/images/2023/01/list-enabled-repositories-in-rocky-linux.png)

### Step 4: Install packages from the local repository in Rocky Linux

Here, I will show you how you can install the package from the local repository that you've just enabled.

To list available packages in the both `AppStream` and `BaseOS` repository, you can use the following command:

For AppStream repository:

```
dnf --disablerepo="*" --enablerepo="AppStream" list available
```

![check availabe packages in specific repository in rocky linux](https://linuxhandbook.com/content/images/2023/01/chack-availabe-packages-in-specific-repository-in-rocky-linux.png)

And for the BaseOS repository:

```
dnf --disablerepo="*" --enablerepo="BaseOS" list available
```

![find availabe packages in baseos repository in rocky linux](https://linuxhandbook.com/content/images/2023/01/find-availabe-packages-in-baseos-repository-in-rocky-linux.png)

For example, here I will be using the both `AppStream` and `BaseOS` repositories to install GIMP:

```
sudo yum --disablerepo="*" --enablerepo="AppStream BaseOS" install gimp
```

![use ISO as a local repository to install packages offline in rocky linux](https://linuxhandbook.com/content/images/2023/01/use-ISO-as-a-local-repository-to-install-packages-offline-in-rocky-linux.png)

Don't worry about the `--disablerepo="*"` flag. It will ignore the repositories for the sake of single command execution.

As you can clearly see, it is only using the local repositories to install GIMP. 

You can also use the command in the same way to update the system (minor release):

```
sudo yum --disablerepo="*" --enablerepo="AppStream BaseOS" update
```

## Wrapping Up

In this guide, I covered how you can use the Rocky Linux ISO image as a local repository and install packages.

I hope you will find this guide helpful in crucial times and if you want me to cover similar topics, let me know in the comments.