How to Install Debian 12 Bookworm with Custom Partitions

This guide walks you through the installation process of Debian 12 Bookworm with custom partitions, ensuring efficient disk usage and better performance.

Debian 12 “Bookworm” is a robust, flexible Linux distribution that allows for extensive customization, including the ability to set up custom partitions during installation. Proper partitioning ensures efficient disk usage, better performance, and easier system maintenance. This guide walks you through the installation process with custom partitions.

Prerequisites

Before proceeding, ensure you have:

  • A USB drive (at least 4GB) with Debian 12 ISO written using tools like Rufus or Balena Etcher.
  • A backup of important data, as partitioning involves modifying disk layouts.
  • A working internet connection (optional but recommended for package updates).
  • Basic knowledge of disk partitioning concepts (primary, logical, swap, etc.).

Step 1: Booting from the Installation Media

  1. Insert the USB drive into your computer.
  2. Restart your system and enter the BIOS/UEFI settings (usually by pressing F2, F12, DEL, or ESC).
  3. Set the USB drive as the primary boot device.
  4. Save changes and exit BIOS/UEFI. Your system should now boot into the Debian installer.

Step 2: Choosing the Installation Mode

Once the Debian installer loads, you will be presented with different options:

  • Graphical Install – Recommended for most users.
  • Text Mode Install – A lightweight alternative.
  • Advanced Options – Used for expert configurations.

Select Graphical Install and proceed.

Step 3: Setting Up Language, Keyboard, and Network

Follow the guided steps to select:

  • Language (e.g., English)
  • Location (e.g., United States)
  • Keyboard Layout (e.g., US, UK, etc.)
  • Network Configuration – If connected via Ethernet, it will be auto-detected. If using Wi-Fi, select your network and enter the credentials.

Step 4: Partitioning the Disk

This is the most critical step. When prompted for partitioning, choose Manual instead of Guided Partitioning.

Understanding Partition Types

Before proceeding, decide on your partitioning scheme. A common setup includes:

  1. EFI Partition (For UEFI Systems) – 512MB, formatted as FAT32, mounted at /boot/efi.
  2. Root Partition (/) – 20-50GB, formatted as ext4, where the OS will be installed.
  3. Home Partition (/home) – Stores user data; size depends on available space.
  4. Swap Partition – Equal to or double the size of RAM (not required if using swap file).
  5. Boot Partition (/boot) – Optional, but recommended in some setups; 1GB is sufficient.

Creating Partitions Manually

  1. Select the disk you want to partition.
  2. Delete existing partitions if applicable (ensure you have backups).
  3. Create a new partition table (GPT for UEFI, MBR for BIOS systems).
  4. Create partitions as needed:
    • EFI Partition: Select free space → New Partition → 512MB → Format as FAT32 → Mount at /boot/efi.
    • Root Partition (/): Select free space → New Partition → Assign required size (20GB+) → Format as ext4 → Mount at /.
    • Home Partition (/home): Select free space → Assign large portion → Format as ext4 → Mount at /home.
    • Swap Partition: Select free space → Assign recommended size → Set as “swap area”.
    • Boot Partition (/boot) (if needed): Create a separate partition of 1GB → Format as ext4 → Mount at /boot.
  5. Finalize Partitioning – Confirm and write changes to disk.

Step 5: Installing the Base System

Once partitioning is complete:

  1. Confirm partition layout and proceed.
  2. The installer will now copy system files to the root partition.
  3. Wait for the base installation to finish.

Step 6: Configuring the Package Manager

  • Choose whether to use a network mirror for package updates (recommended for the latest software versions).
  • Select your nearest mirror for faster downloads.

Step 7: Installing the Bootloader

  1. If using UEFI, the bootloader (GRUB) should automatically install on the EFI partition.
  2. If using BIOS, install GRUB on the main disk (/dev/sda or /dev/nvme0n1).
  3. Confirm the installation and proceed.

Step 8: Finalizing Installation and First Boot

  • Once installation is complete, the installer will prompt for a restart.
  • Remove the installation USB drive and reboot.
  • If everything is set up correctly, Debian 12 should boot into the login screen.

Post-Installation Steps

1. Updating the System

Run the following commands to update your system:

sudo apt update && sudo apt upgrade -y

2. Installing Essential Packages

Depending on your needs, install additional packages:

sudo apt install build-essential vim git curl

3. Configuring Swap (If Not Created During Installation)

If you skipped creating a swap partition, you can add a swap file:

sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

To make it permanent, add this line to /etc/fstab:

/swapfile none swap sw 0 0

4. Enabling Firewall

sudo apt install ufw
sudo ufw enable
sudo ufw allow ssh

5. Installing a Desktop Environment (If Using Minimal Install)

For GNOME:

sudo apt install gnome

For KDE Plasma:

sudo apt install kde-plasma-desktop

Conclusion

Installing Debian 12 “Bookworm” with custom partitions provides better control over disk space and system performance. By following this guide, you ensure a structured and optimized Debian installation tailored to your needs.