# 建立 Local Yum/DNF Repository on RHEL 8 `參考連結:https://www.linuxtechi.com/setup-local-yum-dnf-repository-rhel-8/` > 透過安裝的DVD或ISO檔來建立本地 Yum/DNF Repository RHEL 8 需要兩個package repositories: * BaseOS * Application Stream ([詳細功能](https://www.redhat.com/en/blog/introduction-appstreams-and-modules-red-hat-enterprise-linux)) ## 步驟 `以下步驟請使用root帳號執行` 1. 到RedHat官網下載最新版本ISO檔(如:rhel-8.5-x86_64-dvd.iso) 2. `$ mount -o loop rhel-8.5-x86_64-dvd.iso /opt/` > 要依照下載的RHEL iso檔版本修改 > 下指令時要在iso檔在的那個目錄下 3. ``` $ cp -v /opt/media.repo /etc/yum.repos.d/rhel8.repo '/opt/media.repo' -> '/etc/yum.repos.d/rhel8.repo' ``` 5. `$ chmod 644 /etc/yum.repos.d/rhel8.repo` 6. 修改rhel8.repo ==原始內容== ``` $ cat /etc/yum.repos.d/rhel8.repo [InstallMedia] name=Red Hat Enterprise Linux 8.6.0 mediaid=None metadata_expire=-1 gpgcheck=0 cost=500 ``` ==修改後的內容== ``` [InstallMedia-BaseOS] name=Red Hat Enterprise Linux 8 - BaseOS metadata_expire=-1 gpgcheck=1 enabled=1 baseurl=file:///opt/BaseOS/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release [InstallMedia-AppStream] name=Red Hat Enterprise Linux 8 - AppStream metadata_expire=-1 gpgcheck=1 enabled=1 baseurl=file:///opt/AppStream/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release ``` 7. 清理 Yum / DNF 跟 Subscription Manager 快取 ``` $ dnf clean all $ subscription-manager clean All local data removed ``` 8. 確認 Yum / DNF 從本地儲存庫取得 package  :::info :warning: 顯示未訂閱的警告,可以透過以下指令隱藏 ``` $ vi /etc/yum/pluginconf.d/subscription-manager.conf [main] enabled=0 #將enabled由1改為0 ``` ::: 9. 測試 Yum / DNF 安裝包  :warning: 使用一段時間後安裝新的package出現error(incorrect checksum),是要重新mount iso檔 --- ## 方法二 `參考連結:https://blog.csdn.net/weixin_42077546/article/details/107049880` 1. 輸入指令 df -h,RHEL8.4的image已自動掛載  2. 修改 /etc/yum.repo.d/ 底下的.repo檔  3. 確認Yum是否可以取得package 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up