linux 掛載光碟ISO映像檔修改yum來源

使用Centos shell 指令下掛載光碟ISO映像檔

首先使用root登入centos系統

建立一個掛載點目錄, 掛載的ISO映像檔會經由這個目錄存取:

/root > mkdir /mnt/iso

然後就可以掛載ISO映像檔到掛載點, 以下例子是掛載 /home/myimage.iso:

/root > mount -o loop /home/myimage.iso /mnt/iso

進入 /mnt/iso 存取 ISO 映像檔內容:

/root > cd /mnt/iso

/root > ls -l

要卸載 ISO 映像檔, 也是像其他分割區一樣用 unmount 指令:

/root > umount /mnt/iso

如果遇到卸載有問題 先執行

/root > fuser -m -v -i -k /mnt/iso

/root > umount -l /mnt/iso

接下來修改yum來源為光碟片
修改yum來源為本地Local光碟片安裝:

/etc/yum.repos.d下兩個文件CentOS-Base.repo(Internet安裝) CentOS-Media.repo(本地Local來源)

修改CentOS-Media.repo

[c5-media]
name=CentOS-$releasever - Media
baseurl=file:///media/ 此處為掛載目錄掛載點
gpgcheck=1
enabled=0 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 千萬不要註釋掉,否則後面yum時提示沒有KEY

解決 sh: lsb_release: command not found 的問題
lsb_release -a
bash: lsb_release: command not found
我要安裝lsb相關套件,執行以下指令即可安裝光碟裡的相關套件

yum --disablerepo=\* --enablerepo=c5-media install redhat-lsb

採用上面的yum方式,則會從本地光碟安裝 redhat-lsb 套件

如果我要替換其他地方,一樣是修改CentOS-Media.repo
我把光碟片的內容都 Copy到 /home/Centos511裡面
修改CentOS-Media.repo

[Local]
name=Local
baseurl=file:///home/Centos511
enable=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

執行

yum --disablerepo=\* --enablerepo=Local install redhat-lsb

安裝完套件後檢查lsb_release
執行

lsb_release -a

LSB Version:    :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 5.11 (Final)
Release:        5.11
Codename:       Final

RHEL8 修改 local Repo

 vi /etc/yum.repos.d/rhel8.repo
[BaseOS]
name=Red Hat Enterprise Linux 8 - BaseOS
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///root/cdrom/BaseOS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[AppStream]
name=Red Hat Enterprise Linux 8 - AppStream
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///root/cdrom/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

2017-03-19-08-07-00

上一篇 FTP Filezilla 如何取消自動更新
下一篇 Linux Flexlm License Server 管理