首页 使用命令行安装ubuntu最小化系统
文章
取消

使用命令行安装ubuntu最小化系统

使用命令行安装ubuntu

文件系统格式化及挂载

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
mkfs.btrfs /dev/sda4
mkfs.vfat -F32 /dev/sda5
mount /dev/sda4 /mnt
# btrfs 添加子卷
cd /mnt
btrfs subvolume create @rootfs
btrfs subvolume create @home
# 重新挂载
cd ~
umount /mnt
mount -t btrfs -o subvol=@rootfs /dev/sda4 /mnt
mkdir -p /mnt/home
mount -t btrfs -o subvol=@home /dev/sda4 /mnt/home
mkdir -p /mnt/boot
mount /dev/sda5 /mnt/boot

使用debootstrap安装基础系统组件:

1
2
# debootstrap [选项] [开发版代号] [根分区目录] [仓库链接]
debootstrap --arch=amd64 jammy /mnt http://mirrors.ustc.edu.cn/kali

基础系统配置

fatab分区配置,使用genfstab生成挂载信息

1
2
3
4
# genfstab [选项] [已挂载的分区] 
# -U 使用UUID代替分区分区名称
# 并重定向到fstab文件
genfstab -U /mnt > /mnt/etc/fstab

chroot进入系统并配置,这里使用systemd-nspawn

1
2
# 使用-D选项指定目录
systemd-nspawn -D /mnt

开始配置系统

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 设定root密码
passwd

# 修改软件源
nano /mnt/etc/apt/sources.list
# 添加中科大源
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb http://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb http://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src http://mirrors.ustc.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse

# 软件更新
apt update && apt upgrade

# 时区配置
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# 本地化
apt install locales
echo "LANG=en_US.UTF-8" > /etc/locale.conf
dpkg-reconfigure locales
# 配置主机名
echo "kali" > /etc/hostname

# 配置主机名解析
echo -e "127.0.0.1\tkali" >> /etc/hosts

# 安装自己需要的固件文件
apt install linux-firmware amd64-microcode bluez-firmware

# 安装linux内核
apt install linux-image-generic

# 安装ppa
apt install software-properties-common

# 安装 ubuntudde ppa
add-apt-repository ppa:ubuntudde-dev/stable

#安装深度桌面
apt install ubuntudde-dde

# 配置启动文件(由于本人的主系统已有refind,只需要加一个配置文件即可,
# 也可以额外安装grub等启动管理器)
# 在boot分区新建文件
touch /boot/refind_linux.conf
# 添加根分区信息
"Boot with standard options"  "root=UUID=31d828ea-acfc-4391-bbd8-ccdeeb6b6993 rw rootflags=subvol=/ loglevel=5"
"Boot to single-user mode"    "root=UUID=31d828ea-acfc-4391-bbd8-ccdeeb6b6993 rw rootflags=subvol=/ loglevel=5 single"
"Boot with minimal options"   "ro root=/dev/nvme0n1p2"

经过以上配置,可以基本正常的启动到新系统了,以下额外配置可以使用chroot的方式配置,也可以在新系统启动后配置

额外配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 使用systemd-nspawn进入新系统
systemd-nspawn -D /mnt -b

# 新建普通用户
adduser fly

# 添加sudo
apt install sudo
# 配置sudoers文件
nano /etc/sudoers
# 添加以下配置
fly     ALL=(ALL:ALL) ALL

# 安装系统信息查看工具
sudo apt install neofetch

# 安装bash命令行补全工具
sudo apt install bash-completion

# 安装fcitx5输入法
sudo apt install fcitx5  fcitx5-chinese-addons  fcitx5-config-qt

# 输入法配置
sudo nano /etc/environment
# 添加以下内容
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx

# 安装网页浏览器
sudo apt install firefox-esr

# 其他软件包随用随装即可
本文由作者按照 CC BY 4.0 进行授权
文章内容
热门标签