Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tinti/31997cc49794312dda3fe5f0d78acc17 to your computer and use it in GitHub Desktop.
Save tinti/31997cc49794312dda3fe5f0d78acc17 to your computer and use it in GitHub Desktop.
Instruction how to install Debian using debootstrap

Warning

This is a tutorial from 2016, originally for installing debian jessie, it may work for newer versions of debian, but I haven't check it (however, it should mostly work because not that much changed since then). You may want to change every occurrence of buster to a name of a new version of debian.

Install debootstrap

Make work directory:

mkdir work
cd work

Go here and download latest. Now you can install it with dpkg:

dpkg -i debootstrap_X.X.X_all.deb

or copy files (of course you will need root privileges):

ar -x debootstrap_X.X.X_all.deb
cd /
zcat /full-path-to-work/work/data.tar.gz | tar xv

Set up file system

mkfs.ext4 /dev/sdaX

Mount

mount /dev/sdaX /mnt

Install system

Install base system

Usage: debootstrap --arch ARCH RELEASE DIR MIRROR

debootstrap --arch amd64 buster /mnt https://deb.debian.org/debian/

Chroot into installed system

mount -t proc /proc /mnt/proc/
mount -t sysfs /sys /mnt/sys/
mount -o bind /dev /mnt/dev/
chroot /mnt /bin/bash

Edit fstab file

editor /etc/fstab

Paste something like that

# <file system>        <dir>         <type>    <options>             <dump> <pass>
/dev/sda1              /             ext4      defaults              1      1

Instead of device you can use UUID (which you can obtain via command blkid) for example:

# <file system>        <dir>         <type>    <options>             <dump> <pass>
UUID=6a60524d-061d-454a-bfd1-38989910eccd              /             ext4      defaults              1      1

Configure apt sources

editor /etc/apt/sources.list

Example list:

deb https://deb.debian.org/debian buster main contrib non-free
deb-src https://deb.debian.org/debian buster main contrib non-free

deb https://deb.debian.org/debian buster-updates main contrib non-free
deb-src https://deb.debian.org/debian buster-updates main contrib non-free

deb http://security.debian.org/ buster/updates main contrib non-free
deb-src http://security.debian.org/ buster/updates main contrib non-free

It is a shame that security.debian.org cannot be used with https...

Update apt

apt-get update

Configure system

Choose timezone

dpkg-reconfigure tzdata

Configure locales

apt-get install locales
dpkg-reconfigure locales

Configure networking

To configure networking, edit /etc/network/interfaces, /etc/resolv.conf, /etc/hostname and /etc/hosts.

editor /etc/network/interfaces

Here are some simple examples from /usr/share/doc/ifupdown/examples:

######################################################################
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# See the interfaces(5) manpage for information on what options are
# available.
######################################################################

# We always want the loopback interface.
#
auto lo
iface lo inet loopback

# To use dhcp:
#
# auto eth0
# iface eth0 inet dhcp

# An example static IP setup: (broadcast and gateway are optional)
#
# auto eth0
# iface eth0 inet static
#     address 192.168.0.42
#     network 192.168.0.0
#     netmask 255.255.255.0
#     broadcast 192.168.0.255
#     gateway 192.168.0.1

Enter your nameserver(s) and search directives in /etc/resolv.conf:

editor /etc/resolv.conf

A simple example /etc/resolv.conf:

search hqdom.local
nameserver 10.1.1.36
nameserver 192.168.9.100
Enter your system's host name (2 to 63 characters):

echo DebianHostName > /etc/hostname

And a basic /etc/hosts with IPv6 support:

127.0.0.1 localhost
127.0.1.1 DebianHostName

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

If you have multiple network cards, you should arrange the names of driver modules in the /etc/modules file into the desired order. Then during boot, each card will be associated with the interface name (eth0, eth1, etc.) that you expect.

Install kernel

If you intend to boot this system, you probably want a Linux kernel and a boot loader. Identify available pre-packaged kernels with:

apt-cache search linux-image

Then install the kernel package of your choice using its package name.

apt-get install linux-image-arch-etc

Install boot Loader

apt-get install grub2

Install drivers

apt-get install firmware-linux firmware-linux-free firmware-linux-nonfree

Install additional software

tasksel install standard

Set root's password

passwd

Finish installation

Optionally you can clean apt downloaded archives:

apt-get clean

Now exit the chroot environment simply by typing:

exit

And then:

umount /mnt/proc
umount /mnt/sys
umount /mnt/dev

Install boot loader

apt-get install grub2
grub-install --root-directory=/mnt /dev/sda

And finally:

umount /mnt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment