我用的镜像是:CentOS-8.5.2111-x86_64-dvd1.iso
[root@localhost ~]# mount /dev/sr0 /mnt //挂载本地源
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@localhost ~]# df -Th //查看是否挂载
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 363M 0 363M 0% /dev
tmpfs tmpfs 392M 0 392M 0% /dev/shm
tmpfs tmpfs 392M 6.4M 385M 2% /run
tmpfs tmpfs 392M 0 392M 0% /sys/fs/cgroup
/dev/mapper/cl-root xfs 66G 4.9G 61G 8% /
/dev/mapper/cl-home xfs 32G 260M 32G 1% /home
/dev/nvme0n1p1 xfs 1014M 259M 756M 26% /boot
tmpfs tmpfs 79M 60K 79M 1% /run/user/0
/dev/sr0 iso9660 11G 11G 0 100% /mnt
[root@localhost ~]# rm -rf /etc/yum.repos.d/* //删除其他的源也可以把他们放在其他的位置(为了后面使用网络源)
[root@localhost ~]# vim /etc/yum.repos.d/local.repo //配置本地源文件local.repo
[local]
name=local
baseurl=file:///mnt/BaseOS
gpgcheck=0
enabled=1
[AppStream]
name=AppStream
baseurl=file:///mnt/AppStream
gpgcheck=0
enabled=1
[root@localhost ~]# yum clean all //清除缓存
0 files removed
[root@localhost ~]# yum makecache //创建缓存
local 42 MB/s | 2.6 MB 00:00
AppStream 90 MB/s | 7.5 MB 00:00
Metadata cache created.
[root@localhost ~]# yum install -y lrzsz //例子
Last metadata expiration check: 0:00:15 ago on Mon 05 Dec 2022 08:02:37 AM EST.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
lrzsz x86_64 0.12.20-43.el8 local 84 k
Transaction Summary
================================================================================
Install 1 Package
Total size: 84 k
Installed size: 190 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : lrzsz-0.12.20-43.el8.x86_64 1/1
Running scriptlet: lrzsz-0.12.20-43.el8.x86_64 1/1
Verifying : lrzsz-0.12.20-43.el8.x86_64 1/1
Installed:
lrzsz-0.12.20-43.el8.x86_64
Complete!
[root@localhost ~]#
Centos8配置本地源(简单步骤)
于 2022-12-05 21:15:57 首次发布