mkdir my_rootfs
rpm --root /root/my_rootfs/ --initdb #设置rpm操作的根目录
下载包:http://vault.centos.org/
wget http://vault.centos.org/7.5.1804/os/x86_64/Packages/centos-release-7-5.1804.el7.centos.x86_64.rpm
rpm -ivh --nodeps --root /root/my_rootfs/ --package ./centos-release-7-5.1804.el7.centos.x86_64.rpm #这里安装的时候需要忽略dependency.
yum --installroot=/root/my_rootfs/ install yum
转自:https://cloud.tencent.com/developer/article/1640161