ubuntu官网
https://cn.ubuntu.com/
选择continue without updating
磁盘选择自定义配置
选择空闲分区敲回车,选择增加一个GPT分区
boot分区分配1G空间
其余的容量都分配给根分区,容量不填写表示分配剩余的所有容量
分区设置好后,点击完成
1.2.3 用户设置
创建一个用户,设置主机名
安装ssh服务
选择需要在安装系统时安装的服务,不需要的话可以直接跳过,这一步选择过后会开始安装系统
安装完成后直接重启,view full log可以查看安装时的日志
使用安装系统时创建的用户登录系统
Ubuntu 22需要在安装系统后设置ubuntu的root密码才能正常登录。
zl@ubuntu:~$ sudo passwd root ##为root用户设置密码
[sudo] password for zl: ##输入zl用户的密码
New password: ##设置root用户的密码
Retype new password: ##重复root用户的密码
passwd: password updated successfully
zl@ubuntu:~$
zl@ubuntu:~$ su root ##尝试是否能登录root用户
Password:
root@ubuntu:/home/zl# id
uid=0(root) gid=0(root) groups=0(root)
root@ubuntu:/home/zl#
需要使用root用户编辑和重启ssh服务
root@ubuntu:/home/zl# grep PermitRoot /etc/ssh/sshd_config
#PermitRootLogin prohibit-password
PermitRootLogin yes
# the setting of "PermitRootLogin without-password".
root@ubuntu:/home/zl# systemctl restart sshd
dhcp配置较为简单
root@ubuntu:/etc/netplan# pwd
/etc/netplan
root@ubuntu:/etc/netplan# cat 00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens3:
dhcp4: true
version: 2
root@ubuntu:/etc/netplan# netplan apply ##应用配置
在上面的文件中,我们使用了以下内容:
在 Ubuntu Server 22.04 中,网络由 NetPlan Utility 控制,因此我们将使用 NetPlan 在 Ubuntu Server 上配置静态 IP 地址。
登录到您的服务器,查找 NetPlan 配置文件。它位于 /etc/netplan 目录下,是一个yaml格式的文件。
root@ubuntu:/etc/netplan# pwd
/etc/netplan
root@ubuntu:/etc/netplan# cat 00-installer-config.yaml ##修改如下内容,设置网卡ip及密码
# This is the network config written by 'subiquity'
network:
renderer: networkd
ethernets:
ens3:
addresses:
- 172.18.100.112/16
nameservers:
addresses: [114.114.114.114, 8.8.8.8]
routes:
- to: default
via: 172.18.0.1
version: 2
在上面的文件中,我们使用了以下内容:
要使上述更改生效,请使用以下 netplan 命令应用这些更改
root@ubuntu:/etc/netplan# netplan apply
每个版本的源不同,本例为22.04版本的配置方式
root@ubuntu:/etc/netplan# mv /etc/apt/sources.list /etc/apt/sources.list.bak
root@ubuntu:/etc/netplan# cat /etc/apt/sources.list ##新编辑一个文件,内容如下
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse