Create Local YUM Repository from Systemd Mounted DVD on RHEL 7

We can mount DVDs/partitions using systemd.mount by writing a mount unit file.

Ensure that a RHEL7 DVD is inserted (or attached if using a VM).

Create a mountpoint:

# mkdir /mnt/rhel7dvd

Note that mount units must be named after the mountpoint directories they control. In our case, the mountpoint /mnt/rhel7dvd has to be configured in the file mnt-rhel7dvd.mount. The unit file name has to match the mountpoint path.

Here’s the context of the newly created file /etc/systemd/system/mnt-rhel7dvd.mount:




Reload the systemd daemon and start the unit:

# systemctl daemon-reload
# systemctl start mnt-rhel7dvd.mount
# systemctl enable mnt-rhel7dvd.mount

Create a Yum repo file /etc/yum.repos.d/rhel7dvd.repo with the following content:

name=rhel7 dvd


# yum clean all && yum repolist
Cleaning repos: dvd
Cleaning up everything
dvd                                                                   | 4.1 kB  00:00:00
(1/2): dvd/group_gz                                                   | 136 kB  00:00:00
(2/2): dvd/primary_db                                                 | 3.9 MB  00:00:00
repo id                                  repo name                                     status
dvd                                      rhel7 dvd                                     4,751
repolist: 4,751

12 thoughts on “Create Local YUM Repository from Systemd Mounted DVD on RHEL 7

  1. Hi Tomas , just wanted to know what is the purpose of using a mount unit file instead of using normal mount command to mount the rhel7 DVD.

    • The fstab way is simpler, but I wouldn’t say that it’s any better compared to systemd, likely the opposite. For example, systemd gives you flexibility to specify when to mount each point.

    • The createrepo program creates a repomd repository from a set of rpms. There is no need to use it on a DVD because the content of the DVD is already a repository.

      When you install RedHat/CentOS from a DVD, you use that DVD as an installation media repository.

    • Strangely my experience was different… After I unpacked the .iso to a directory on an http server and configured the repo to download from there, I got errors 404 for the repodata files. It only got fixed after running createrepo on the extracted files.

Leave a Reply

Your email address will not be published. Required fields are marked *