Install Debian with debootstrapDecember 31, 2017
A driver on Ubuntu 16.04 was giving me some trouble, so I wanted to quickly install Debian sid on an external hard drive to see if later versions of Debian/Ubuntu fixed the issue. However, I didn’t want to bother with downloading and booting from an installer disc, so took the following chroot approach.
This bootstrap-and-chroot process isn’t new and is documented in bits and pieces all over the web (some other distributions even use it as their official install process!) but I wanna put all the steps for Debian here, in one place. For my personal reference, at least.
Partition the disk
I used gparted for this since I was feeling lazy, but all I had to do was shrink an existing NTFS partition, create a new partition, and format it as ext4.
Mount the partition
So that I could chroot into the disk, create a mountpoint and mount it (the device was
/dev/sda2in this case):
# mkdir /mnt/sid # mount /dev/sda2 /mnt/sid
Bootstrap the partition
Then, I installed a base Debian sid system to the partition. This will take a while.
# debootstrap sid /mnt/sid/ http://www.gtlib.gatech.edu/pub/debian/
Now I’ve got a system I can chroot into, which is nice, but it doesn’t won’t have a kernel or anything, so it’s not something I can boot into really. The first step to fixing this is to chroot in:
# mount -t sysfs sysfs /mnt/sid/sys # mount -t proc proc /mnt/sid/proc # mount -o bind /dev /mnt/sid/dev # chroot /mnt/sid/dev bash
At the least, you gotta tell a new system where to find the root filesystem, what its hostname is, what its timezone is, what locale to use, and the root password.
You can find the UUID used below by running
blkidin the chroot or on the host. And I chose
en_US.UTF-8 UTF-8as my locale when prompted.
(chroot)# printf 'UUID=0592bfeb-0f9a-415f-be4a-b10948b25e63 / ext4 errors=remount-ro 0 1\n' >/etc/fstab (chroot)# printf 'pretentiousanimehostname\n' >/etc/hostname (chroot)# printf '127.0.0.1\tpretentiousanimehostname\n'>>/etc/hosts (chroot)# ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime (chroot)# dpkg-reconfigure locales (chroot)# passwd
Install nonfree packages
debootstrapconfigures the package manager not to install nonfree packages. I needed some wireless firmware, so I changed the following line in
deb http://www.gtlib.gatech.edu/pub/debian sid main
deb http://www.gtlib.gatech.edu/pub/debian sid main contrib non-free
and then ran
(chroot)# apt-get update
Then I could install whatever gross nonfree stuff I needed, like
apt-get install firmware-atherosfor my wireless card firmware.
Now, install the good stuff:
(chroot)# apt-get install vim tmux htop sudo gnome linux-image-amd64 initramfs-tools
The last two are really the most important ones here, at least for getting the dang thing to boot. In particular, installing
initramfs-toolsshould generate an initramfs, which you’ll need to boot.
Create your user
Finally, I created my user account:
(chroot)# adduser austin
Since I installed sudo above and wanted to actually use it, I put myself in the
(chroot)# usermod -aG sudo austin
The system from which I was doing all this already had a bootloader, GRUB 2, which has really nice autodetection, so I all I had to use it to boot my system was (on the original system, not the chroot):
(which is equivalent to
grub-mkconfig -o /boot/grub/grub.cfg)
Then I simply rebooted and chose my new installation at the GRUB menu! Tada!