GOAL : Debian 11 minimal server, size 700 MB
TOOL :
- Linux : Debian 11 at
/dev/sda
, Target at/dev/sdb
- Application : debootstrap, parted
- User : root
apt-get update
apt-get install debootstrap
apt-get install parted
parted /dev/sdb
mklabel msdos
mkpart primary ext4 1MB 1800MB
mkpart primary linux-swap 1800MB 2000MB
set 1 boot on
quit
mkfs.ext4 /dev/sdb1
mkswap /dev/sdb2
mount /dev/sdb1 /mnt
debootstrap --arch amd64 stable /mnt http://cdn-fastly.deb.debian.org/debian
NOTE : Don't use --variant=minbase, it gonna screw the build, because default debootstrap already small
mount -o bind /dev /mnt/dev
mount -o bind /proc /mnt/proc
mount -o bind /sys /mnt/sys
mount -o bind /run /mnt/run
Copy host network configuration
cp /etc/mtab /mnt/etc/mtab
cp /etc/network/interfaces /mnt/etc/network/interfaces
chroot /mnt /bin/bash
Make chroot bash color different than host
PS1="\e[99;32m$PS1\e[m"
blkid /dev/sdb1 >> /etc/fstab && blkid /dev/sdb2 >> /etc/fstab
nano /etc/fstab
My configuration of fstab, change the UUID with yours
# UNCONFIGURED FSTAB FOR BASE SYSTEM
# <file system> <dir> <type> <options> <dump> <pass>
UUID=3ce8b8a7-18e1-4818-908c-e31e53602f04 / ext4 defaults 0 0
UUID=5be3a736-701c-4c2c-a6f8-0d78e565ac4c swap swap defaults 0 0
apt-get update
apt-get install linux-image-amd64
apt-get install grub-pc
update-grub && grub-install --root-directory / /dev/sdb
passwd
apt-get autoremove
apt-get clean
exit
umount -l /mnt
shutdown now
Remove the target hardisk /dev/sdb
and boot it from new Computer or new Virtual Machine.
After boot, update the grub because there lelfover of old Debian (Host).
update-grub
Check the hardisk size, mine 658MB
df -h
Now you have Debian minimal installation with the size of 700MB
Next step, you can reduce the size of hardisk Reduce Debian