Skip to content

Instantly share code, notes, and snippets.

@rwcitek
Last active April 24, 2021 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rwcitek/ffe6590fa1bcd45d9be4 to your computer and use it in GitHub Desktop.
Save rwcitek/ffe6590fa1bcd45d9be4 to your computer and use it in GitHub Desktop.
Mostly automated install of Debian Squeeze in a VirtualBox VM using Knoppix 7.2 and debootstrap
# based in part on information from here:
# http://www.linuxquestions.org/questions/debian-26/how-to-install-debian-using-debootstrap-4175465295/
#### Part 1 - Knoppix
# boot Knoppix 7.2
knoppix64 2 vga=788 noaudio
# configure networking
passwd
/etc/init.d/ssh restart
ip addr
# ssh into knoppix
#### Part 2 - disk setup
# reset disk partitions and mountpoints
ls /dev/sda* | xargs -r -i dd if=/dev/zero bs=1M count=1 of={}
echo -e "o\np\nw" | fdisk /dev/sda
rm -rf /mnt/deboot
# partition disk
echo -e "o\nn\np\n1\n\n\np\nw" | fdisk /dev/sda
sleep 5
mkfs.ext4 /dev/sda1
mkdir /mnt/deboot
mount /dev/sda1 /mnt/deboot
ls -la /mnt/deboot/lost+found/ || exit
#### Part 3 - debootstrap
# run debootstrap
# x86
# debootstrap --include=linux-image-686,grub-pc --arch i386 squeeze /mnt/deboot http://ftp.us.debian.org/debian
# amd64
debootstrap --include=linux-image-amd64,grub-pc --arch amd64 squeeze /mnt/deboot http://ftp.us.debian.org/debian
#### Part 4 - chroot
# mount
mount -o bind /dev /mnt/deboot/dev
mount -o bind /proc /mnt/deboot/proc
mount -o bind /sys /mnt/deboot/sys
mount | grep deboot
{ cat <<'xeof'
# configure mounts
grep -v rootfs /proc/mounts > /etc/mtab
getuuid=$(blkid | grep /dev/sda1 | cut -d '"' -f2) && echo "UUID=$getuuid / ext4 defaults 0 1" >> /etc/fstab
# configure grub
export LC_ALL=C
grub-install /dev/sda
update-grub
# set root password == 123456
usermod -p '$6$gPYxIBPl$T7GdADne..st6WUgxX2Ea7uIW3dqbsE0Zbl8zfcMQvrwIIdRmEHycC24fU5RRFu0eVdFrZoq0x6wZ.4l3XfqM0' root
# configure hostname
echo "test.example.com" > /etc/hostname
xeof
} > /mnt/deboot/tmp/setup.sh
# enter chroot environment
chroot /mnt/deboot /bin/bash -x -c 'source /tmp/setup.sh'
#### Part 5 - finish
# clean up
cd
> /mnt/deboot/root/.bash_history
umount /mnt/deboot/{sys,proc,dev}
umount /mnt/deboot/
# reboot
{ sleep 3 ; reboot ; } & exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment