01-操作系统安装初始化


https://developer.aliyun.com/mirror/   阿里云镜像

https://mirrors.aliyun.com/rockylinux/8.5/isos/x86_64/Rocky-8.5-x86_64-dvd1.iso

https://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso

https://mirrors.aliyun.com/ubuntu-releases/focal/ubuntu-20.04.4-live-server-amd64.iso

1,Rockey

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33 #配置Rocky ip
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=ens33
UUID=7912e195-405a-4fde-8ef4-dabf653a975e
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.80.171
NETMASK=255.255.255.0
GATEWAY=192.168.80.2
cat > /etc/sysconfig/network-scripts/ifcfg-ens33 <<EOF
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=ens33
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.80.171
NETMASK=255.255.255.0
GATEWAY=192.168.80.2
DNS1=8.8.8.8
DNS1=8.8.4.4
EOF
[root@localhost mnt]# ls /dev/cdrom 
/dev/cdrom
mount -t iso9660 /dev/cdrom /mnt/cdrom  #将镜像挂在到目录
[root@localhost cdrom]# ls  #挂载成功
AppStream  BaseOS  EFI  images  isolinux  LICENSE  media.repo  TRANS.TBL
[root@localhost yum.repos.d]# cat base.repo 
[BaseOS]   #yum id,本地唯一
name=mnt/cdrom #描述信息
baseurl=file:///mnt/cdrom/BaseOS  #前面file://是协议,后面/mnt/cdrom/BaseOS是挂载点
gpgcheck=0  #1.使用公钥验证rpm的正确性,0为不验证
[AppStream]
name=mnt/cdrom
baseurl=file:///mnt/cdrom/AppStream
gpgcheck=0

yum clean all && yum makecache

cat /etc/fstab
/dev/sr0 /mnt/cdrom iso9660 defaults 0 0

关闭防火墙,seliux,swap

systemctl stop firewalld.service
systemctl disable firewalld.service
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
swapoff -a
sed -i 's/.*swap.*/#&/' /etc/fstab  

2,ubuntu

https://mirrors.aliyun.com/ubuntu/ 

 done 等待安装

 wang 密码

wang@ubuntu2004:/etc/netplan$ cat 00-installer-config.yaml 
# This is the network config written by 'subiquity'
network:
  ethernets:
    ens33:
      dhcp4: true
  version: 2
wang@ubuntu2004:/etc/netplan$ sudo passwd  #更改root密码
[sudo] password for wang: 
New password: 
Retype new password: 
passwd: password updated successfully
wang@ubuntu2004:/etc/netplan$ su - root
Password: 
root@ubuntu2004:~#
root@ubuntu2004:~# cat /etc/ssh/sshd_config  #允许root远程登陆
#PermitRootLogin prohibit-password
PermitRootLogin yes
systemctl restart sshd.service
root@ubuntu2004:/etc/netplan# cat 00-installer-config.yaml #配置ubuntu ip
# This is the network config written by 'subiquity'
network:
  version: 2
  ethernets:
    ens33:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.80.181/24]
      gateway4: 192.168.80.2
      nameservers:
        addresses: [8.8.8.8]
        addresses: [8.8.4.4]
SRE