There are various scenarios in which one might need to install a Debian-based system (e.g., Debian, Ubuntu, etc.) from another distribution (e.g., Arch Linux, Gentoo, Debian/Ubuntu distributions, Fedora, etc.). One common reason is when a user wants to set up a Debian-based system alongside an existing distribution. This could be for the purpose of testing software compatibility, development, or simply to have a dual-boot.
A Debian-based distribution can be installed from any other distribution using debootstrap
. The debootstrap
command-line tool allows installing a Debian or Ubuntu base system within a subdirectory of an existing, installed system. Unlike traditional installation methods using a CD or a USB Key, debootstrap
only requires access to a Debian repository.
There are several reasons why this approach is advantageous:
- No need for a bootable USB/CD: Install Debian without external installation media.
- Dual-boot without reinstalling the host OS: Easily add Debian alongside another Linux system.
- Minimal and customizable installation: Install only essential packages for a lightweight system (the installer sometimes installs more than necessary).
- Remote server installations: Install Debian on a remote machine without physical access.
- System recovery: Reinstall or repair a broken Debian system from another Linux distribution.
- Automated and scripted deployments: Useful for mass deployments in enterprise environments.
- Maintaining a multi-distro workflow: Run both a stable Debian system and a rolling-release distribution.
Step 1: Create a new LVM partition, format it, and mount it
# Create the root LVM partition
lvcreate -L 20G -n debian_root VOL_NAME
# Format the partition
mkfs.ext4 /dev/VOL_NAME/debian_root
# Mount the partition
mkdir /mnt/debian_root
mount /dev/VOL_NAME/debian_root /mnt/debian_root
Code language: plaintext (plaintext)
Step 2: Install the debootstrap command-line tool
On Arch Linux, debootstrap
can be installed using:
pacman -Sy debian-archive-keyring debootstrap
Code language: plaintext (plaintext)
On Gentoo, it can be installed using:
emerge -a dev-util/debootstrap
Code language: plaintext (plaintext)
On Debian/Ubuntu based distributions:
apt-get install debootstrap
Code language: JavaScript (javascript)
Step 3: Install the Debian base system
Use the debootstrap
command to install Debian into the target directory:
debootstrap --arch=amd64 stable /mnt/debian_root http://deb.debian.org/debian
Code language: plaintext (plaintext)
You can replace stable
with another Debian release like testing
or unstable
if desired. You can also add the flag --force-check-gpg
to force checking Release file signatures.
In the above example, it will install the Debian-based system from the repository http://deb.debian.org/debian
into the local directory /mnt/debian_root
.
Step 4: Chroot into the Debian system
Since you are installing a Debian-based system inside another distribution (Arch Linux, Gentoo, etc.), you’ll need to ensure that the directory where the Debian system is mounted is ready. You can achieve this by mounting certain directories and chrooting into the Debian system:
sudo mount --bind /dev /mnt/debian_root/dev
sudo mount --bind /proc /mnt/debian_root/proc
sudo mount --bind /sys /mnt/debian_root/sys
sudo mount --bind /boot /mnt/debian_root/boot
sudo cp /etc/resolv.conf /mnt/debian_root/etc/resolv.conf
sudo cp /etc/fstab /mnt/debian_root/etc/fstab
sudo chroot /mnt/debian_root /bin/bash -l
Code language: plaintext (plaintext)
The chroot
command will open a new shell in the Debian environment.
Step 5: Configure the Debian-based system
Now that you’re inside the Debian-based system, you can configure it as desired. You can install packages, modify configurations, set up users, etc.
Here is an example:
apt-get update
# Install the Linux Kernel
apt-get install linux-image-amd64 firmware-linux-free firmware-misc-nonfree
# Install cryptsetup if you are using a LUKS encrypted partition
apt-get install cryptsetup cryptsetup-initramfs
# Install misc packages
apt-get install console-setup vim lvm2 sudo
# Reconfigure locales
dpkg-reconfigure locales
# Configure the host name and the time zone
echo yourhostname > /etc/hostname
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
Code language: plaintext (plaintext)
Do not forget to:
- Modify /mnt/debian_root/etc/fstab (The mount point “/” has to point to the Debian system)
- Modify /mnt/debian_root/etc/crypttab (If you are using a LUKS encrypted partition)
How to boot into the newly installed system?
You can, for example, configure GRUB to boot your newly configured operating system.
You can either use the new Debian-based system’s GRUB as the default (replace the existing one) or configure additional GRUB entries in an existing system. For instance, if your base system is Debian-based, you can add your entry using /etc/grub.d/40_custom
:
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry 'Debian 2' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'debian_fallback' {
insmod part_gpt
insmod fat
search --no-floppy --fs-uuid --set=root 00000000-000a-00a0-a0a0-000000a0000a
linux /backup/vmlinuz-6.12.12+bpo-amd64 root=/dev/MY_LVM_VOLUME/debian ro fsck.mode=auto fsck.repair=yes nowatchdog apparmor=1 acpi_backlight=native
initrd /initrd.img-6.12.12+bpo-amd64
Code language: plaintext (plaintext)
(Replace /dev/mapper/MY_LVM_VOLUME_debian with your root partition and 00000000-000a-00a0-a0a0-000000a0000a with your actual UUID that you can find using the command: lsblk -o +UUID
)
In my case, I am using bootctl
, which I installed using Gentoo. I simply added /boot/loader/entries/debian.conf
with the following configuration:
title Debian
linux /vmlinuz-6.12.12+bpo-amd64
initrd /initrd.img-6.12.12+bpo-amd64
options rw root=/dev/volume1/debian
Code language: plaintext (plaintext)
Congratulations! You have successfully installed a Debian-based system using debootstrap
from another distribution such as Arch Linux, Gentoo, etc.