· 操作步骤
无网络连接时使用
1.连接光盘
2.挂载光盘
[root@xiudaochengxian ~]
mount: /dev/sr0 is write-protected, mounting read-only
[root@xiudaochengxian ~]
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 17G 3.5G 14G 21% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 36M 1.9G 2% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 165M 850M 17% /boot
tmpfs 378M 44K 378M 1% /run/user/0
/dev/sr0 4.2G 4.2G 0 100% /mnt
3.编写挂载信息使其永久生效
[root@xiudaochengxian ~]
12 /dev/cdrom /media/cdrom iso9660 defaults 0 0
相关参数 | 作用 |
---|
/dev/cdrom | 设备名称 | /media/cdrom | 挂载点名称 | iso9660 | 光盘格式 | defaults 0 0 | 权限默认是否备份是否自动校验 |
4.进入yum仓库路径
[root@xiudaochengxian ~]
[root@xiudaochengxian yum.repos.d]
CentOS-Base.repo CentOS-fasttrack.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-Media.repo
CentOS-Debuginfo.repo CentOS-Sources.repo
5.做备份
[root@xiudaochengxian yum.repos.d]
[root@xiudaochengxian yum.repos.d]
CentOS-Base.repo CentOS-fasttrack.repo
CentOS-Base.repo.bak CentOS-Media.repo
CentOS-CR.repo CentOS-Sources.repo
CentOS-Debuginfo.repo CentOS-Vault.repo
6.编写yum仓库
[root@xiudaochengxian yum.repos.d]
1.[base]
2 name=CentOS-$releasever - Base
3 baseurl=file:///mnt
4 gpgcheck=0
yum仓库模板
[ ]
name=
baseurl=
enabled=
gpgcheck=
7.清理缓存
[root@xiudaochengxian yum.repos.d]
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Cleaning repos: base
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
8.新建缓存
[root@xiudaochengxian yum.repos.d]
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
base | 3.6 kB 00:00
(1/4): base/group_gz | 166 kB 00:00
(2/4): base/primary_db | 3.1 MB 00:00
(3/4): base/filelists_db | 3.1 MB 00:00
(4/4): base/other_db | 1.3 MB 00:00
Metadata Cache Created
9.刷新仓库
[root@xiudaochengxian yum.repos.d]
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
repo id repo name status
base CentOS-7 - Base 3,971
repolist: 3,971
注:以上方法仅用于无网络连接,只有光盘镜像时使用
|