Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

@cdbdev

This comment has been minimized.

Copy link

@cdbdev cdbdev commented Sep 16, 2019

hello,

I didn't try this yet, but you forgot to exit the chroot environment ;-)

greetings

@varqox

This comment has been minimized.

Copy link
Owner Author

@varqox varqox commented Sep 16, 2019

Thanks for noticing, I made it more clear.

@Jonher937

This comment has been minimized.

Copy link

@Jonher937 Jonher937 commented Jan 3, 2020

Fixes:

  • deootstrap should be debootstrap
  • Remove trailing - on systemd-sysv- -> systemd-sysv
  • symply > simply

Ideas:

  • Might be time to change jessie for buster at this point
  • Point to a generic ftp endpoint and not a US one

Thanks :)

@varqox

This comment has been minimized.

Copy link
Owner Author

@varqox varqox commented Jan 4, 2020

I updated the tutorial.

For apt install and apt-get install, the trailing - in the package name marks that package for removal, so: apt install abc- xyz is a shorthand (in some way -- I think that the shorter version is superior because it is possible to easily handle package conflicts that way, as APT sees both operations before taking any action) for apt install xyz && apt remove abc.

Thank you for your suggestions :)

@Jonher937

This comment has been minimized.

Copy link

@Jonher937 Jonher937 commented Jan 5, 2020

I updated the tutorial.

For apt install and apt-get install, the trailing - in the package name marks that package for removal, so: apt install abc- xyz is a shorthand (in some way -- I think that the shorter version is superior because it is possible to easily handle package conflicts that way, as APT sees both operations before taking any action) for apt install xyz && apt remove abc.

Thank you for your suggestions :)

I did not know about the - in apt 👍
Thanks

@undecoded

This comment has been minimized.

Copy link

@undecoded undecoded commented May 7, 2021

Make partition bootable?

@varqox

This comment has been minimized.

Copy link
Owner Author

@varqox varqox commented May 7, 2021

Make partition bootable?

I don't understand what is an issue, could you clarify?

@marcusbritanicus

This comment has been minimized.

Copy link

@marcusbritanicus marcusbritanicus commented May 11, 2021

Hello...

Thanks for this wonderful tutorial. Really saved me quite a bit of time. I now have a blazing fast system, with only the packages I need!!
One of the problems that I did face was, I used a GPT partition table, and I was unable to install grub until I marked the partition as bootable. Perhaps, this is what @undecoded meant?

And yes, I installed Debian Sid. And it works perfectly fine.

@varqox

This comment has been minimized.

Copy link
Owner Author

@varqox varqox commented May 12, 2021

Hello...

Thanks for this wonderful tutorial. Really saved me quite a bit of time. I now have a blazing fast system, with only the packages I need!!
One of the problems that I did face was, I used a GPT partition table, and I was unable to install grub until I marked the partition as bootable. Perhaps, this is what @undecoded meant?

And yes, I installed Debian Sid. And it works perfectly fine.

This makes sense to me now.

So you propose adding a step to mark the partition bootable?
Could you share the commands you used and where would you add this step? Maybe the right place is just before or as a first substep of #install-boot-loader-1?

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