File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ centos_version=" $1 "
4+
5+ # 更换镜像为华为云 centos
6+ echo " ==> 更换镜像为华为云"
7+ cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
8+ wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-" $centos_version " -reg.repo
9+ dnf -y clean all
10+ dnf -y update
11+
12+ # 更换终端名
13+ hostname=" centos$centos_version "
14+ echo " ==> 修改hostname为$hostname "
15+ hostnamectl set-hostname centos
16+ hostnamectl --pretty
17+ hostnamectl --static
18+ hostnamectl --transient
19+
20+ # 安装基础组件
21+ dnf install -y curl wget vim
22+
23+ # 配置交换分区
24+ echo " ==> 修改之前交换分区"
25+ swapon -s
26+ free -m
27+ echo " ==> 开始配置交换分区"
28+ fallocate -l 2G /swap
29+ chmod 600 /swap
30+ mkswap /swap
31+ swapon /swap
32+ echo " /swap swap swap sw 0 0" >> /etc/fstab
33+ echo " ==> 修改之后交换分区"
34+ swapon -s
35+ free -m
36+
37+
You can’t perform that action at this time.
0 commit comments