免U盘安装debian系统
·
使用 debootstrap 构建一个原生 Debian 系统并引导启动(推荐)
这是最干净、最安全、完全不需要U盘的方法。 你会在 Ubuntu 里“手工安装”一个 Debian,然后让 grub 启动它。
如果没有空闲分区, 缩小 Ubuntu 的根分区,腾出 20GB 以上空间,创建一个 ext4 分区。
lsblk
sudo apt update
sudo apt install debootstrap grub2 systemd-container
# debootstrap 安装 Debian(例如 Debian 13 Trixie)
sudo debootstrap trixie /mnt/debian http://deb.debian.org/debian
这一步会自动在 /mnt/debian 下生成一个完整的 Debian 根文件系统。
# 挂载关键目录并进入 Debian 环境
sudo mount --bind /dev /mnt/debian/dev
sudo mount --bind /proc /mnt/debian/proc
sudo mount --bind /sys /mnt/debian/sys
sudo chroot /mnt/debian
# 在 chroot 中配置系统(此时你“已经在 Debian 中”)
# 设置主机名
echo debian > /etc/hostname
# 配置 apt 源
cat > /etc/apt/sources.list <<EOF
deb http://deb.debian.org/debian trixie main contrib non-free-firmware
deb http://security.debian.org/debian-security trixie-security main contrib non-free-firmware
deb http://deb.debian.org/debian trixie-updates main contrib non-free-firmware
EOF
apt update
apt install linux-image-amd64 grub-pc locales sudo vim network-manager
adduser yourname
adduser yourname sudo
blkid # 查看新分区 UUID
cat<<EOF >> /etc/fstab
UUID=你的新分区UUID / ext4 defaults 0 1
EOF
# 安装 grub 到磁盘并更新菜单
grub-install /dev/nvme0n1
update-grub
# 它会检测到你的 Ubuntu + Debian 双系统。
# 重启后你会在 GRUB 菜单里看到 “Debian GNU/Linux”。
sudo reboot
使用 systemd-nspawn 启动完整 Debian 容器系统
如果你暂时不想重启,可以直接在 Ubuntu 下运行“原生 Debian 系统容器”:
sudo debootstrap trixie /srv/debian http://deb.debian.org/debian
sudo systemd-nspawn -D /srv/debian
# 这会直接进入一个 Debian 容器(有独立的 /etc、/usr、apt、systemd),
# 就像一个轻量虚拟机,非常适合测试迁移。
使用 grub 引导 ISO 镜像直接安装 Debian(无U盘安装)
可以让 grub 直接从 Debian ISO 启动:
wget https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-13.0.0-amd64-netinst.iso -O /boot/debian.iso
cat <<EOF | sudo tee -a /etc/grub.d/40_custom
menuentry "Install Debian 13 (from ISO)" {
set isofile="/boot/debian.iso"
loopback loop (hd0,3)$isofile
linux (loop)/install.amd/vmlinuz boot=install iso-scan/filename=$isofile
initrd (loop)/install.amd/initrd.gz
}
EOF
sudo update-grub
# 重启,选择 “Install Debian 13 (from ISO)”
# 安装时选择 保留 /home 分区,即可实现无U盘切换系统。
EOF
网络启动(PXE)或 iPXE(高级)
若你的笔记本支持 PXE 网络启动,可通过局域网加载 Debian 安装器。 需另一台电脑作为 TFTP/DHCP 服务器,配置复杂,一般用户不推荐。
创建虚拟磁盘作为临时“Live 环境”(极不推荐)
理论上可用 kexec 加载新内核 + initrd 实现“内存中切换”,但操作复杂、风险极高,且仍需处理分区缩小问题。