mount -t proc /proc /debian/proc mount --rbind /dev /debian/dev mount --rbind /sys /debian/sys
生成 /etc/fstab 文件,以确保分区能够正确挂载:
1
genfstab -U /debian > /debian/etc/fstab
接下来,进入chroot环境:
1
chroot /debian /usr/bin/bash
配置APT源
为Debian系统配置APT源,以确保软件包的顺利安装:
1 2 3 4 5
cat << EOF > /etc/apt/sources.list deb http://deb.debian.org/debian/ bookworm main contrib non-free-firmware deb http://deb.debian.org/debian/ bookworm-updates main contrib non-free-firmware deb http://deb.debian.org/debian-security/ bookworm-security main contrib non-free-firmware EOF
国内用户可以使用清华大学的镜像源:
1 2 3 4 5
cat << EOF > /etc/apt/sources.list deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free-firmware deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free-firmware deb http://mirrors.tuna.tsinghua.edu.cn/debian-security/ bookworm-security main contrib non-free-firmware EOF
更新软件包列表:
1
apt update
如果遇到DNS解析问题,可以手动配置DNS:
1
echo"nameserver 8.8.8.8" > /etc/resolv.conf
国内用户可以使用:
1
echo"nameserver 223.5.5.5" > /etc/resolv.conf
安装内核和基本工具
安装云服务器常用的Linux内核:
1
apt install linux-image-cloud-amd64
安装常用的工具和服务:
1
apt install htop vim lsof curl wget bash-completion ssh