Skip to content

Instantly share code, notes, and snippets.

@rwcitek
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwcitek/df49bb1c3b2020170097 to your computer and use it in GitHub Desktop.
Save rwcitek/df49bb1c3b2020170097 to your computer and use it in GitHub Desktop.
Installing Ubuntu Precise (12.04) 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 - VM and Knoppix
# create a VM with an 8GB /dev/sda, a bridged eth0, and KNOPPIX_V7.2.0DVD-2013-06-16-EN.iso attached
# boot Knoppix 7.2 with options
knoppix64 2 vga=788 noaudio
# configure networking
passwd
/etc/init.d/ssh restart
ip addr
# ssh into knoppix from host
#### 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
debootstrap --arch amd64 precise /mnt/deboot http://archive.ubuntu.com/ubuntu
#### 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
# enter chroot environment
chroot /mnt/deboot /bin/bash
# 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
# install minimal extra packages
export LC_ALL=C
apt-get update
apt-get install -y grub linux-image openssh-server
# configure grub
grub-install /dev/sda
update-grub -y
# install an initial user - password == 123456
useradd -m -s /bin/bash -G sudo ubuntu
usermod -p '$6$gPYxIBPl$T7GdADne..st6WUgxX2Ea7uIW3dqbsE0Zbl8zfcMQvrwIIdRmEHycC24fU5RRFu0eVdFrZoq0x6wZ.4l3XfqM0' ubuntu
# configure networking
cat <<'eof' >> /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
eof
echo "test.example.com" > /etc/hostname
# leave the chroot
exit
#### 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