一键网络重装CentOS 7系统

Nicky 2.5K 0
摘要:

截至2022年5月,能在CentOS 6中正确重装Centos 7的方式

之前在上篇文章中提到了费了很大劲才重装到了CentOS 7。所以这篇文章来记录一下。

之所以费劲,主要是包括两个方面。一是CentOS 6现在已经结束了生命周期(EOL),linux社区已经不再维护该操作系统的版本,导致无法执行redhat-upgrade-tool的升级工具,很多软件安装会有问题。二是之前有人制作的网络恢复镜像跟恢复镜像代码,恢复完毕以后,部分组件安装不成功。系统一直处于重装死循环。

CentOS 6系统yum无法使用

首先我们解决第一个问题。

第一个问题主要是造成yum无法使用的问题。因为我们后期需要update或是需要安装xz-utils openssl gawk file等等,都需要通过yum解决。

之前国内的一部分镜像还保留了CentOS 6的Packages,但是现在很多都已经搜不到了,幸亏网络的力量强大,更换更新源即可。

sed -i “s|enabled=1|enabled=0|g” /etc/yum/pluginconf.d/fastestmirror.conf
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://file.kangle.odata.cc/repo/Centos-6.repo
curl -o /etc/yum.repos.d/epel.repo http://file.kangle.odata.cc/repo/epel-6.repo
yum clean all
yum makecache

当然如果这个文件下载比较慢,大家也可以手动建立。

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
        http://mirrors.aliyuncs.com/centos-vault/6.10/os/$basearch/
        http://mirrors.cloud.tencent.com/centos/$releasever/os/$basearch/
        http://mirrors.tencentyun.com/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
        http://mirrors.aliyuncs.com/centos-vault/6.10/updates/$basearch/
        http://mirrors.cloud.tencent.com/centos/$releasever/updates/$basearch/
        http://mirrors.tencentyun.com/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
        http://mirrors.aliyuncs.com/centos-vault/6.10/extras/$basearch/
        http://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/
        http://mirrors.tencentyun.com/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos-vault/6.10/centosplus/$basearch/
        http://mirrors.cloud.tencent.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.tencentyun.com/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos-vault/6.10/contrib/$basearch/
        http://mirrors.cloud.tencent.com/centos/$releasever/contrib/$basearch/
        http://mirrors.tencentyun.com/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

顺便跟大家说https://mirrors.cloud.tencent.com/centos-vault/跟https://vault.centos.org/6.10/os/x86_64/Packages/也都是可以的。

一键安装CentOS 7

实际上使用CentOS 6升级工具也可以,但是如果是空的系统,推荐直接用一键安装就可以了。最早的版本是萌咖做的,不支持自动安装 CentOS 7 的原因是 7 只能使用grub2引导,与我们常见的其他系统的grub不同。dd的方式导致引导也有一些问题。CXT大佬以前专门研究过这一块,但是好像网站也没维护,很多代码跟镜像大家都习惯从他网站直接获取了,所以之前下载的很多的镜像都有问题。

最终还是看到了GitHub上留的资料,修改了对应链接,才可以正常恢复。

目前支持的版本包括:

Alpine Linux、Anarchy Linux、Arch Linux、Backbox、BlackArch Linux、Bluestar Linux、Bodhi Linux、CentOS、CoreOS、Debian、Deepin、Devuan、Elementary OS、Fedora、Feren OS、Flatcar Linux、FreeBSD、FreeDOS、Gentoo、IPFire、Kali Linux、KDE Neon、Kodachi、Linux Lite、Q4OS、Microsoft Windows、Mageia、Manjaro、Mint、MirOS、Nitrux、NixOS、OpenBSD、OpenSUSE、Oracle Linux、Parrot Security、Peppermint、Proxmox-VE、Pop OS、Red Hat Enterprise Linux、Regolith、RancherOS、Scientific Linux、Slackware、SparkyLinux、Tails、Tiny Core Linux、Ubuntu、Velt、Voyager、Zen Installer、Zorin OS、ALT Linux Rescue、Boot Repair CD、Breakin、CAINE、Clonezilla、DBAN、GParted、Grml、Memtest、Rescatux、Super Grub2 Disk、System Rescue CD、Ultimate Boot CD

如果单纯执行一键安装,可以先执行以下命令:

wget --no-check-certificate -qO ~/Network-Reinstall-System-Modify.sh 'https://www.cxthhhhh.com/CXT-Library/Network-Reinstall-System-Modify/Network-Reinstall-System-Modify.sh' && chmod a+x ~/Network-Reinstall-System-Modify.sh

如果大佬网站无法访问,可以使用Github的代码。

wget --no-check-certificate -qO ~/Network-Reinstall-System-Modify.sh 'https://raw.githubusercontent.com/MeowLove/Network-Reinstall-System-Modify/master/Network-Reinstall-System-Modify.sh' && chmod a+x ~/Network-Reinstall-System-Modify.sh

如果只想安装CentOS 7,可以执行以下命令:

bash ~/Network-Reinstall-System-Modify.sh -CentOS_7

看代码,实际上是可以简化的。

最终代码可以简化为:

wget --no-check-certificate -qO Core_Install.sh 'https://www.cxthhhhh.com/CXT-Library/Network-Reinstall-System-Modify/CoreShell/Core_Install_v3.1.sh' && bash Core_Install.sh -dd 'https://odc.cxthhhhh.com/SyStem/CentOS/CentOS_7.X_NetInstallation_Final_v9.2.vhd.gz'

或者Github的链接。

wget --no-check-certificate -qO Core_Install.sh 'https://raw.githubusercontent.com/MeowLove/Network-Reinstall-System-Modify/master/CoreShell/Core_Install_v3.1.sh' && bash Core_Install.sh -dd 'https://odc.cxthhhhh.com/SyStem/CentOS/CentOS_7.X_NetInstallation_Final_v9.2.vhd.gz'

从以上链接按到的实际执行的是dd的这个压缩包。https://odc.cxthhhhh.com/SyStem/CentOS/CentOS_7.X_NetInstallation_Final_v9.2.vhd.gz,如果大家需要更新的系统位于境内,大家可以下载下来,更换相应的地址。

可以查看相关注意事项:https://odc.cxthhhhh.com/SyStem/CentOS/ReadMe.md,与下载CentOS列表。https://odc.cxthhhhh.com/SyStem/CentOS/

注意事项
  • root 密码默认为cxthhhhh.com,为保证安全请第一时间修改密码。
  • 安装需耗时 15-45 分钟,并且系统首次启动后,请等待自动安装完成,系统将自动重启。
  • IPv4 和 IPv6 为 DHCP 获取 IP 的模式,所以需要提前将网络信息记录下来,如果是需要手动设置的需要在VNC下重新配置。
  • 系统 DNS 为8.8.8.8、4.2.2.2、1.1.1.1
  • 登录信息如果不需要可以修改掉

 

参考链接

  • CentOS6 解决Error: Cannot retrieve repository metadata (repomd.xml):https://www.djc8.cn/archives/centos6-cannot-error-retrieve-repository-repomdxml-metadata.html
  • Centos6 配置最新yum源 :https://www.cnblogs.com/syy1757528181/p/14327112.html
  • Centos6系统yum无法使用-最新解决办法:https://blog.csdn.net/qq_41938046/article/details/110920247
  • CentOS6目前还可用的源-腾讯源(20200129亲测可用,记录):https://blog.csdn.net/zgnckzn/article/details/113370508
  • CentOS6.8重新安装yum:https://blog.csdn.net/baidu_29701003/article/details/117416792
  • linux之Centos6升级至centos7:https://blog.csdn.net/carefree2005/article/details/115176089
  • CentOS6.x 版本升级到 CentOS7 的方法:https://www.cnblogs.com/rubekid/p/15222431.html
  • Linux VPS纯净版CentOS系统一键安装脚本:https://www.moerats.com/archives/559/
  • Linux VPS纯净版Debian/Ubuntu/CentOS/Windows系统一键安装脚本:https://www.moerats.com/archives/574/
  • [Linux] 网络脚本一键重装 Ubuntu/CentOS/Debian:https://moe.best/yoimono/linux-reinstall-vicer.html
  • 一键网络重装系统 - 魔改版(适用于Linux / Windows):https://www.cxthhhhh.com/network-reinstall-system-modify

发表评论 取消回复
表情 图片 链接 代码

分享