Debian 13.6 安装与网络配置完整笔记

本文档基于实际安装过程整理,涵盖从系统安装到 SSH 远程登录的完整流程,包含所有遇到的错误及解决办法。


一、安装前的准备

1. 下载镜像

2. 制作启动盘

  • Windows:使用 Rufus 写入 U 盘
  • Linux/macOS:使用 dd 命令写入
  • 注意:此操作会清空 U 盘所有数据

3. BIOS/UEFI 设置

  • 重启电脑,按 Del / F2 进入 BIOS
  • 将 U 盘设为第一启动项
  • 保存并退出

二、分区方案(UEFI 模式)

正确分区结构,选U盘启动后,第一个图形界面安装,install是命令行界面,貌似有些装不上,选自动分区,手动efi有问题

分区大小类型挂载点
#1500MB - 1GBEFI System Partition/boot/efi
#2剩余空间(建议 20GB+)Ext4/
#3等于内存大小(或 8GB)swapswap

分区操作步骤

  1. 进入分区界面后,删除所有现有分区,变为 FREE SPACE
  2. 创建 #1:选 EFI System Partition,设置 Bootable flag 为 on
  3. 创建 #2:选 Ext4,挂载点选 /
  4. 创建 #3:Use as 选 swap area
  5. 选 Finish partitioning and write changes to disk
  6. 确认写入选 Yes

三、安装过程中的关键选项

1. 网络镜像选择

  • 提示 "Continue without a network mirror" 时选 Yes
  • 原因:先装最小系统,后续换国内源更快

2. 软件包流行度调查

  • "Participate in the package usage survey" 选 No

3. 软件选择

  • 必须勾选 Standard system utilities
  • 桌面环境在之前步骤已选,此处不重复

四、安装 GRUB 引导

常见错误及处理

错误1:No EFI partition was found

  • 原因:BIOS 模式与分区不匹配
  • 解决:确认主板为 UEFI 模式,需创建 ESP 分区

错误2:Unable to install GRUB in dummy

  • 原因:缺少 EFI 系统分区
  • 解决:按上述分区方案重新分区

错误3:mount /boot/efi failed

  • 原因:ESP 分区未正确初始化
  • 解决:在分区设置中将 Bootable flag 设为 on

如果 GRUB 反复安装失败

进入救援模式(Rescue mode)手动安装:

  1. 从 U 盘启动,选 Rescue mode
  2. 选 /dev/sda2 作为 root 文件系统
  3. 选 "Execute a shell in /dev/sda2"
  4. 执行以下命令:
chroot /mnt /bin/bash
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Debian
update-grub
exit
exit
  1. 重启系统,拔掉 U 盘

五、首次进入系统后的网络配置,最简系统,没有ip和ssh

1. 检查网卡状态

ip a

2. 启用网卡

ip link set enp2s0 up
无法自动获取IP,手动指定
ip addr add 192.168.1.100/24 dev enp2s0
ip route add default via 192.168.1.1
echo "nameserver 223.5.5.5" > /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
测试
ping -c 4 223.5.5.5

3. 配置软件源(重要)

Debian 13 的代号为 trixie,需使用正确的源:

cat > /etc/apt/sources.list << 'EOF'
deb https://mirrors.tuna.tsinghua.edu.cn/debian trixie main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian trixie-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security trixie-security main contrib non-free non-free-firmware
EOF

4. 更新软件包列表

apt update

5. 安装网络工具

apt install isc-dhcp-client ifupdown net-tools -y

6. 配置网卡开机自动获取 IP

编辑网络配置文件:

nano /etc/network/interfaces

添加以下内容:

auto enp2s0
iface enp2s0 inet dhcp

保存退出(nano 快捷键:Ctrl+X,按 Y,按 Enter)

7. 重启网络服务

systemctl restart networking

8. 手动获取 IP(如果需要)

dhclient -v enp2s0

9. 验证网络连通性

ping -c 4 223.5.5.5
ping -c 4 www.baidu.com

六、开启 SSH 远程登录

1. 安装 SSH 服务端

apt install openssh-server -y

2. 查看本机 IP

ip a show enp2s0

记下 inet 后面的地址(如 192.168.10.202)

3. 启动 SSH 并设置开机自启

systemctl enable ssh --now

4. 检查服务状态

systemctl status ssh

显示 active (running) 表示成功

5. 从其他设备登录

Windows(CMD 或 PowerShell):

ssh root@192.168.10.202

Mac / Linux:

ssh root@192.168.10.202

七、常见问题及解决方案

问题1:安装 GRUB 时提示 "No EFI partition was found"

原因:硬盘分区表中没有 EFI 系统分区

解决:按正确分区方案重新分区,确保 ESP 分区存在

问题2:apt install 报依赖错误

错误示例:

Unsatisified dependencies:
apt : Depends: libapt-pkg7.0 (>= 3.0.3) but it is not going to be installed

原因:软件源版本与系统版本不匹配(如用 bookworm 源装 trixie 系统)

解决:将源中的 bookworm 改为 trixie

问题3:网卡状态为 DOWN

ip link set enp2s0 up

问题4:USB 网卡 error -71

原因:USB 端口供电不足或驱动问题

解决:

modprobe -r ax88179_178a
modprobe ax88179_178a
ip link set enx00e0c6f012b2 up
dhclient -v enx00e0c6f012b2

问题5:重启后网卡未自动获取 IP

原因:未将网络配置写入配置文件

解决:按第五部分第6步配置 /etc/network/interfaces

问题6:sudo: command not found

原因:最小化系统未安装 sudo

解决:切换到 root 用户(su -),安装 sudo:

apt install sudo -y
usermod -aG sudo 用户名

问题7:dhclient: command not found

解决:

apt install isc-dhcp-client -y

八、系统信息确认

查看 Debian 版本:

cat /etc/debian_version

查看内核版本:

uname -a

查看网卡 IP:

ip a

九、注意事项

  1. Debian 13 的稳定版代号为 trixie,软件源中应使用 trixie 而非 bookworm
  2. UEFI 模式下必须存在 ESP 分区,类型选 EFI System Partition
  3. 最小化安装后需手动安装网络工具和 SSH 服务
  4. 网卡配置需写入 /etc/network/interfaces 才能开机自启
  5. 使用国内镜像源(清华、中科大等)可大幅提升下载速度

以上内容基于 Debian 13.6 安装过程完整记录,所有命令均已实际验证。

标签: none

添加新评论