How to update OS packages

  • el7

    Please check the latest version for CentOS/RHEL 7.4 on the web site http://mirror.centos.org/centos-7/. The below steps assume the latest version is 7.4.1708.

    • Prepare packages

      For Red Hat Enterprise Linux, if you have subscribed Red Hat Enterprise Linux, you should update package repository from Red Hat.

      For CentOS, you should prepare one CentOS 7.4 node which can access the Internet, then run the below command to create update package repository.
      centos7_4_latest_version=7.4.1708
      
      $ sudo cat << eof > /etc/yum.repos.d/centos7_4_update.repo
        [centos7_4_update]
        name=centos7_4_update
        baseurl=http://mirror.centos.org/centos/$centos7_4_latest_version/updates/x86_64/
        mirrorlist=http://mirrorlist.centos.org/?release=$centos7_4_latest_version&arch=x86_64&repo=updates
        gpgcheck=0
        enabled=1
        eof
      
      $ sudo yum -y install createrepo
      $ sudo yum -y install yum-utils
      $ sudo mkdir -p /opt/update
      $ sudo cd /opt/update
      $ sudo reposync --download-metadata -r centos7_4_update -e ./cache -n -a x86_64 -d
      $ sudo createrepo .
      $ sudo rm -rf cache
      $ sudo tar -zcf update.tgz centos7_4_update repodata
      
    • Update packages

      Run command on management node.
      $ sudo mkdir -p /install/custom/update
      
      Upload created update.tgz file to /install/custom/update of the management node. Then run the command on the management node.
      $ sudo tar -xf update.tgz -C /install/custom/update
      $ sudo cat << eof > /etc/yum.repos.d/centos7_4_update.repo
        [centos7_4_update]
        name=centos7_4_update
        baseurl= http://${sms_name}/install/custom/update
        gpgcheck=0
        enabled=1
        eof
      $ sudo xdcp all /etc/yum.repos.d/centos7_4_update.repo /etc/yum.repos.d/centos7_4_update.repo
      
      Run command on management node.
      $ sudo yum -y update
      $ sudo psh all yum -y update
      
  • sle12

    • Prepare packages

      For SLES, you need subscribe from SUSE to get package repository.

    • Update packages

      Upload repository getting from SUSE to the /install/custom on management node. Assume the directory name of this repository is update. Then run the below command on the management node.
      $ sudo cat << eof > /etc/zypp/repos.d/sles12_3_update.repo
        [sles12_3_update]
        name= sles12_3_update
        baseurl= http://${sms_name}/install/custom/update
        gpgcheck=0
        enabled=1
        eof
      $ sudo xdcp all /etc/zypp/repos.d/sles12_3_update.repo /etc/zypp/repos.d/sles12_3_update.repo
      $ sudo zypper -y dup
      $ sudo psh all zypper -y dup