Translation(s): none
DebianOn is an effort to document how to install, configure and use Debian on some specific hardware. Therefore potential buyers would know if that hardware is supported and owners would know how get the best out of that hardware. The purpose is not to duplicate the Debian Official Documentation, but to document how to install Debian on some specific hardware. If you need help to get Debian running on your hardware, please have a look at our user support channels where you may find specific channels (mailing list, IRC channel) dedicated to certain types of hardware. |
Models covered
Generic Single Board Computer
This page explains one possibility to install Debian on a Generic Single Board Computer for which no official Debian Installer exists, but that allows you to plug in an external storage medium such as an SD Card or an USB Storage Medium.
The idea is to use debootstrap and qemu-user on a regular computer such as an x86 laptop or desktop computer to prepare the medium and then just to plug the storage medium to the target computer.
The Raspberry Pi is a classical example, and in fact you will notice that this page was written while doing installation on a Raspberry Pi 4B.
Instructions
Prerequisites
You need:
- your normal desktop or laptop computer running Debian (the "host system").
- This was tested with Debian unstable, but the process is likely to work in Debian 13 Trixie or later as well.
- the target system
- peripherals for the target system to access the console.
- either: screen or keyboard
- or: serial console
using a serial console might be easier since you can cut&paste there
- the medium for installation (for example: an SD card or an USB stick)
- a proven good method to bring the target system online.
- wired Ethernet might be the easiest way if the target systems has an RJ45 port
- Wifi might need firmware, Wifi tools and software to to WPA authentication
- peripherals for the target system to access the console.
Partition and Mount Medium
Use gparted, parted or any other partitioning tool to write the right kind of volume label (the kind your target system will boot from) to the medium and partition the medium as you want to have it (as long as the target system is fine with that). This can, for example, include specially labeled and formatted partitions that the target system might use for its firmware, boot manager and boot control files.
Choose whether you want a dedicated /boot or whether /boot should reside on your root file system.
Format the partitions with the required/intended file systems. Mount the (still empty) target root fs somewhere (for example /mnt/target), mount /boot and firmware partitions where they belong under your target root fs.
Debootstrap
install qemu-user qemu-user-binfmt debootstrap on the host system.
invoke (as root) debootstrap --arch=<arch> <suite> /path/to/target_root <your mirror>, for example: debootstrap --arch=arm64 trixie /mnt/target http://deb.debian.org/debian
This will implicitly run the architecture dependent parts of the bootstrap process under qemu. Don't worry if it's slow: Emulating another CPU is likely to be one order of magnitude slower than your target system will be.
chroot into your new system
(as root) chroot /mnt/target /bin/bash will give you a shell in the target system. dpkg --print-architecture will print the target architecture, and uname -a will claim to run Linux <hostname> x.y.z-<host_arch> but on your target architecture.
Then:
edit /etc/hostname or your target system will have the same hostname as your host
rm /etc/machine-id so that a new one will be generated
write an /etc/fstab that reflects your partitioning scheme. Set "nofail" as options in fstab if you are not sure whether you got it right the first time to make systemd continue the system boot.
passwd and set a password for root
- apt install locales dbus
- optionally:
adduser an administration account that you can later ssh into
install sudo, adduser <your admin account> sudo
- install lvm2 and other filesystem related tools that your target system needs for the partitioning scheme you chose
- adapt apt sources.list, optionally: add non-free-firmware if you need that
- tasksel install --new-install standard
- if you don't have a serial console:
- install the packages you need to configure your network
- write the correct configuration files to configure your network
- install sshd
- this will create ssh host keys that have your host's name, not the name of the target machine, in their comments. It is recommended to delete /etc/ssh/ssh_host_* and to apt --reinstall install openssh-server to have new keys created on the actual target system
- do additional configuration that your target system / target architecture needs to boot
apt install <linux-image for your architecture>. This is the last step on purpose so that the initramfs does only get created once
Next, unmount the file systems, pull the medium from the host, plug it into the target system, try booting.
You may plug the medium back into the host, remount the file systems and chroot into the target tree at any time to debug or fix things.
Credits
?CategoryEmbeddedComputer