[教程向]使用debootstrap安装debian最小系统

准备
需要一个debian或其衍生发行版的livecd,需要网络

启动livecd
用livecd启动系统,确保网络正常连接。

系统分区
进行系统分区,假设系统分三个区:

EFI分区 : 1G
SWAP分区 : 10G
系统分区 : the rest

格式化分区

[code]# mkfs.vfat /dev/sda1

mkswap /dev/sda2

mkfs.btrfs /dev/sda3

[/code]
挂载分区,安装基本系统

[code]# mount /dev/sda3 /mnt

debootstrap --include linux-image-amd64,locales,grub-efi-amd64,vim,btrfs-grops,sudo --arch amd64 sid /mnt http://mirrors.163.com/debian/

mkdir -p /mnt/boot/efi

mount -t vfat -o umask=0077 /dev/sda1 /mnt/boot/efi[/code]

chroot进入系统

[code]# mount -t proc proc /mnt/proc

mount --rbind /sys /mnt/sys

mount --rbind /dev mnt/dev

chroot /mnt /bin/bash[/code]

以下命令需要在chroot环境中执行。

[code]# PS1="(live)$PS1"
编辑fstab文件
adduser 添加用户
passwd 修改root用户密码
修改hostname
修改/etc/network/interfaces文件以使能开机自动使用dhcp配置网卡

echo Asia/Shanghai > /etc/timezone

update-iniramfs -u -k all

grub-efi-install /dev/sda && update-grub

reboot[/code]