我要评分
获取效率
正确性
完整性
易理解

Configuring the OS Yum, APT, or Zypper Source

Skip this section if the OS environment can access the Internet and the default Yum, APT, or Zypper source of the OS is available.

Configuring the OS Yum Source (for CentOS/EulerOS/openEuler/RHEL/NeoKylin/Kylin/BC-Linux/iSoft)

The following describes how to configure the Yum source on CentOS 7.6. The configuration procedure is the same for other OSs.

  1. Download the CentOS image file CentOS-7-x86_64-Everything-1810.iso from the CentOS official website.
  2. Use an SSH remote login tool to upload the CentOS 7.6 image to the /root directory.
  3. Use an SSH tool to remotely log in to the CentOS CLI.
  4. Run the following command to mount the CentOS 7.6 ISO image to a local directory:
    1
    mount /root/CentOS-7-x86_64-Everything-1810.iso /media -o loop
    

    If the OS is restarted, you need to mount the image file again.

  5. Run the following commands to back up the original Yum source. In the mv command, path indicates the backup directory. Replace it with the actual backup directory.
    1
    2
    cd /etc/yum.repos.d/
    mv ./* path
    
  6. Configure the Yum source.
    1. Run the following command to open the media.repo file.
      1
      vi /etc/yum.repos.d/media.repo
      
    2. Press i to enter the insert mode and add the following content to the media.repo file:
      1
      2
      3
      4
      5
      6
      7
      [InstallMedia]
      name=CentOS7.6
      metadata_expire=-1
      gpgcheck=0
      cost=500
      baseurl=file:///media
      enabled=1
      
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  7. Run the following commands to update the local cache information of the Yum source:
    1
    2
    yum clean all
    yum makecache
    

Configuring the APT Source (for Ubuntu/Debian/Deepin/Linx/UOS)

The following describes how to configure the APT source on Ubuntu 18.04.1. The configuration procedure is the same for other OSs.

  1. Download the Ubuntu image file ubuntu-18.04.1-server-amd64.iso from the Ubuntu official website.
  2. Use an SSH remote login tool to upload the Ubuntu 18.04.1 image to the /root directory.
  3. Use an SSH tool to remotely log in to the Ubuntu CLI.
  4. Run the following command to mount the Ubuntu 18.04.1 ISO image to a local directory:
    1
    mount /root/ubuntu-18.04.1-server-amd64.iso /media -o loop
    
    • If the OS is restarted, you need to mount the image file again.
    • Some installation packages are missing in the local image sources of Debian OSs. Download the required installation packages from the Internet or using a proxy. The dependencies are listed as follows. If you cannot access the Internet or configure a proxy, check, download, and install the dependencies manually.

      expect GCC make zlib1g zlib1g-dev libpcre3 libpcre3-dev OpenSSL libssl-dev

      You can run the following commands to query and install dependency packages:

      1
      2
      dpkg -l Installation_package_name
      dpkg -i Installation_package_name
      
  5. Run the following commands to back up the original APT source:
    1
    2
    cd /etc/apt            
    mv -v sources.list{,.bak}   
    
  6. Configure the APT source.
    1. Run the following command to open the sources.list file.
      1
      vi sources.list
      
    2. Add the following content to the sources.list file:
      1
      deb file:///media wheezy main
      

      In the preceding command, wheezy main is the directory where Packages is located. Replace it with the actual directory.

    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  7. Run the following command to update the local cache information of the APT source:
    1
    apt update
    

Configuring the Zypper Source (for SUSE)

  1. Download the SUSE image file SLE-15-SP1-Packages-x86_64-GM-DVD1.iso from the SUSE official website.
  2. Use an SSH tool to remotely log in to the SUSE CLI and upload the SUSE image to the /root directory.
  3. Run the following command to mount the SUSE ISO image to a local directory:
    1
    mount /root/SLE-15-SP1-Packages-x86_64-GM-DVD1.iso /media -o loop
    

    If the OS is restarted, you need to mount the image file again.

  4. Run the following command to add the local Zypper source. local indicates the local source name.
    1
    zypper ar file:///media/ local
    
  5. Run the following command to check whether the local source is configured successfully:
    1
    zypper lr
    

    If command output is displayed, the local source is configured successfully.

    1
    2
    3
    4
    Repository priorities are without effect. All enabled repositories share the same priority.
    # | Alias | Name  | Enabled | GPG Check | Refresh
    --+-------+-------+---------+-----------+--------
    1 | local | local | Yes     | ( p) Yes  | No
    
  6. Clear the local cache and refresh the image source.
    1
    2
    zypper clean
    zypper ref