jk's notes
  • 在 CentOS 中挂在 iso 源

在 CentOS 中挂在 iso 源

场景: 在某些开发环境中, 无法访问互联网, Linux 无法安装软件. 使用完整的 iso 镜像来修改安装源.

步骤:

  1. 拷贝 iso 文件到 linux.
  2. 然后在特定文件夹下创建目录.
  3. 使用 mount 命令挂载 iso 文件. 就像挂载一个驱动器一样.
# 使用 scp 命令将 iso 文件拷贝到目标主机
scp /current/iso/file/name <user>@remote:/target/path
# 然后会被提示输入密码, 完成拷贝

在目标主机上

mkdir /mnt/iso # 创建挂在目录
mount -o loop /path/to/your.iso /mnt/iso # 进行挂载
mount | grep /mnt/iso # 检查是否挂载成功

源挂载完成后, 需要配置源的搜索地址:

  1. 在 /etc/yum.repos.d/ 目录下创建文件: myiso.repo

  2. 在文件中编辑如下:

    [myiso] 
    name=My ISO Repository
    baseurl=file:///mnt/iso
    enabled=1
    gpgcheck=0
    
  3. 然后执行 yum update 更新搜索路径即可.

Last Updated:
Contributors: jk