Debian也可以像Arch一样最小化安装, 不同的是Debian使用的是Debootstrap, 相当于arch的pacstrap, 甚至还可以在一台Debian电脑上, 向另一个硬盘安装Debian

本教程仅展示一些通用的步骤, 具体的需要根据自己的需要自行定制

工具

任意Debian livecd或Debian系统
良好的互联网连接

准备安装

顺便说一下, 我的分区是提前分好的, 就不再介绍分区了, 分区步骤可以在网上自行查阅, 下面以一个efi分区和一个btrfs分区为例

nmtui

sudo apt update&&sudo apt install debootstrap arch-install-scripts

挂载分区

以我的机器为例, 需要自行根据实际情况修改

mount /dev/nvme0n1p3 /mnt -o subvol=@ 挂载根分区

mount /dev/nvme0n1p3 /mnt/home -o subvol=@home --mkdir挂载home分区

mount /dev/nvme0n1p3 /mnt/swap -o subvol=swap --mkdir 挂载swap

mount /dev/nvme0n1p1 /mnt/boot/efi --mkdir 挂载efi分区

swapon /mit/swap/swapfile 启用swap

安装基本系统

stable为例, 也可以改成testingsid, 架构以amd64为例

debootstrap --include linux-image-amd64,linux-headers-amd64,firmware-linux-free,grub-efi,man-db,bash-completion,vim,network-manager,build-essential,sudo --arch=amd64 stable /mnt https://mirrors.bfsu.edu.cn/debian

通过chroot配置

chroot

arch-chroot /mnt

fstab

genfstab -U /mnt >> /mnt/etc/fstab

vim /etc/fstab

文件应该是这样式的, 需要删去多余的部分, 否则系统会无法启动

# UNCONFIGURED FSTAB FOR BASE SYSTEM
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# /dev/nvme0n1p3
UUID=36c72ca7-4226-44e1-983d-abf41c41f6c2 / btrfs rw,relatime,ssd,space_cache=v2,subvolid=260,subvol=/@ 0 0

# /dev/nvme0n1p1
UUID=569A-5EA5 /boot/efi vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2

# /dev/nvme0n1p3
UUID=36c72ca7-4226-44e1-983d-abf41c41f6c2 /home btrfs rw,relatime,ssd,space_cache=v2,subvolid=261,subvol=/@home 0 0

# /dev/nvme0n1p3
UUID=36c72ca7-4226-44e1-983d-abf41c41f6c2 /swap btrfs rw,relatime,ssd,space_cache=v2,subvolid=264,subvol=/swap 0 0



/swap/swapfile none swap defaults 0 0

时间

ln -sf /usr/share/zoneinfo/*Region*/*City* /etc/localtime 选择时区, 比如*Region*/*City*可替换成Asia/Shanghai

hwclock --systohc

软件源

vim /etc/apt/sources.list

文件示例(以stable为例, 也可以改成testingsid):

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.bfsu.edu.cn/debian/ stable main contrib non-free non-free-firmware
# deb-src https://mirrors.bfsu.edu.cn/debian/ stable main contrib non-free non-free-firmware

deb https://mirrors.bfsu.edu.cn/debian/ stable-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.bfsu.edu.cn/debian/ stable-updates main contrib non-free non-free-firmware

deb https://mirrors.bfsu.edu.cn/debian/ stable-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.bfsu.edu.cn/debian/ stable-backports main contrib non-free non-free-firmware

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb https://mirrors.bfsu.edu.cn/debian-security stable-security main contrib non-free non-free-firmware
# deb-src https://mirrors.bfsu.edu.cn/debian-security stable-security main contrib non-free non-free-firmware

apt update

语言

apt install locales

dpkg-reconfigure locales

首先选择想要安装的语言,按空格勾选, 然后回车, 选择默认显示语言

键盘布局

sudo dpkg-reconfigure keyboard-configuration

主机名

echo "*yourhostname*" >> /etc/hostname

Initramfs

apt install btrfs-progs

update-initramfs

root密码

passwd

GRUB

grub-install --target=x86_64-efi --efi-directory=*esp* --bootloader-id=GRUB (*esp* 换成自己的efi分区, 我这里是/dev/nvme0n1p1)

apt install os-prober

vim /etc/default/grub

添加一行GRUB_DISABLE_OS_PROBER=false 确保os-prober打开以检测其他操作系统

update-grub

安装固件

刚才安装的基本系统只包含自由固件, 有些电脑可能需要非自由固件才能正常使用, 比如网卡, wifi等, 可以根据自己的需要安装

apt install firmware-linux-nonfree firmware-realtek firmware-iwlwifi

重启系统

一切搞定后, Ctrl+D 退出chroot, 运行reboot 重启系统

重启后配置

联网

nmtui

创建用户

useradd user

passwd user

sudo usermod -aG sudo user

安装图形界面和必要软件

apt install task-mate-desktop i3 ayatana-* lunar liblunar* lunar-date picom rofi fonts-noto fonts-noto-cjk fonts-noto-cjk-extra fonts-noto-color-emoji fonts-noto-extra fonts-hack-ttf git clang python-is-python3 fcitx5 lightdm slick-greeter firefox-esr fcitx5-chinese-addons kitty kdeconnect pulseaudio ranger moc wget

启用显示服务器

systemctl enable lightdm

重启

一切搞定后, 运行reboot 重启系统

一个带图形界面的Debian系统到此安装完成, 后面的可以根据自己的需要来配置和使用