Installing Linux on Bare Metal: The Physical Foundation
·Tech

Installing Linux on Bare Metal: The Physical Foundation

Master the art of physical Linux installation. Learn about bootable media creation, BIOS/UEFI settings, disk partitioning strategies (GPT vs MBR), and post-installation hardware verification.

Installing Linux on Bare Metal: Turning Hardware into a Linux Machine

"Bare metal" refers to actual physical hardware—your laptop, a desktop PC, or a rack-mount server. While many developers today start with cloud instances or virtual machines, installing Linux directly on hardware is the best way to understand the intimate relationship between the operating system and the physical components.

In this lesson, we will walk through the professional workflow for installing a Linux distribution on a physical machine. We will focus on the the common pitfalls, such as Secure Boot and partitioning schemes, that often trip up beginners.


1. The Installation Workflow

Installing an OS is a multi-step process. If you miss one step, you might end up with an unbootable system or, worse, accidental data loss on your primary drive.

graph TD
    ISO[1. Download ISO Image] --> USB[2. Flash ISO to USB Drive]
    USB --> BIOS[3. Adjust BIOS/UEFI Settings]
    BIOS --> Boot[4. Boot from USB]
    Boot --> Partition[5. Disk Partitioning Selection]
    Partition --> Install[6. Base System Installation]
    Install --> Reboot[7. First Boot & Setup]

2. Step 1: Choosing and Downloading your Image

As we learned in Module 1, your distribution choice depends on your goal.

  • For Desktop: Ubuntu 24.04 LTS or Fedora.
  • For Server: Debian or AlmaLinux.

Always download the ISO (Internal Standards Organization) image directly from the official website. This ensures you have a clean, untampered version.


3. Step 2: Creating Bootable Media

Gone are the days of burning CDs. Today, we use USB flash drives. You cannot simply "drag and drop" an ISO file onto a USB drive. You must perform a bit-level copy so that the drive becomes a "Bootable" device.

Recommended Tools:

  • BalenaEtcher: Simple, cross-platform, and safe.
  • Rufus: Highly customizable (Windows only).
  • dd: The powerful command-line tool (Linux/macOS).

The "dd" command (For Professionals)

If you are already on a Unix-like system, you can use dd (Data Duplicator). Warning: Be extremely careful with the drive identifier (of=/dev/sdX). If you pick your internal drive, it will be erased immediately.

# Example: Copying ubuntu.iso to a USB drive
# if = Input File, of = Output File, bs = Block Size (for speed)
sudo dd if=ubuntu-24.04.iso of=/dev/sdb bs=4M status=progress conv=fdatasync

4. Step 3: Preparing the Hardware (BIOS/UEFI)

Before the USB can boot, you must tell your motherboard to look for it.

  1. Entering Setup: Press F2, F12, or Del immediately after power-on.
  2. Disable Secure Boot (maybe): Some distributions require this to be disabled, though modern Ubuntu and Fedora work fine with it enabled.
  3. Boot Order: Move your USB drive to the top of the list.
  4. AHCI Mode: Ensure your SATA controller is in AHCI mode, not "RAID/RST" mode, for maximum compatibility.

5. Step 4: Partitioning Strategies

This is the most critical stage of the installation.

Option A: Erase Disk and Install

The easiest choice. The installer will create a partition table for you.

  • The Result: Usually one big partition for everything.

Option B: Manual Partitioning

For a professional workstation or server, you might want to separate your data.

  1. EFI Partition (/boot/efi): 512MB - Essential for UEFI systems.
  2. Root Partition (/): 30GB - 100GB - Where the OS and apps live.
  3. Home Partition (/home): The rest of the space - Separates your personal files from the OS. This allows you to reinstall your OS without losing your documents.
  4. Swap: 2GB - 16GB - Virtual memory used when your RAM is full.

6. Post-Installation: Hardware Verification

Once the installation is complete and you have rebooted, your first task is to ensure Linux "sees" all your hardware correctly.

Checking the CPU and Memory

lscpu # Detailed info about your processor
free -h # Check RAM (Human-readable)

Checking Peripheral Devices (PCI and USB)

lspci # List all PCI devices (Graphics card, Network card)
lsusb # List all USB devices

7. Example: A Hardware Compatibility Script (Python)

If you are managing a fleet of bare-metal servers, you need an automated way to verify that the hardware matches your purchase order. Here is a Python script that uses basic Linux command utilities to generate a hardware manifest.

import subprocess
import json

def get_hw_manifest():
    """
    Runs low-level Linux tools to gather hardware specs.
    """
    manifest = {}
    
    # Get CPU info
    cpu = subprocess.check_output(['lscpu'], text=True)
    for line in cpu.split('\n'):
        if "Model name:" in line:
            manifest['cpu'] = line.split(":", 1)[1].strip()
            break
            
    # Get Memory info
    mem = subprocess.check_output(['free', '-b'], text=True)
    total_bytes = int(mem.split('\n')[1].split()[1])
    manifest['ram_gb'] = round(total_bytes / (1024**3), 2)
    
    # Get Disk info (lsblk)
    lsblk = subprocess.check_output(['lsblk', '-J', '-o', 'NAME,SIZE,TYPE'], text=True)
    manifest['disks'] = json.loads(lsblk)
    
    return manifest

if __name__ == "__main__":
    hw = get_hw_manifest()
    print("--- Bare Metal Hardware Manifest ---")
    print(f"Processor: {hw['cpu']}")
    print(f"Memory:    {hw['ram_gb']} GB")
    
    print("\nStorage Layout:")
    # Pretty print the disk JSON
    print(json.dumps(hw['disks'], indent=2))

8. Summary

Installing on bare metal gives you total ownership of the hardware.

  • Use Etcher or dd to create the media.
  • Configure UEFI and Boot Order correctly.
  • Use Manual Partitioning if you want to keep your /home folder separate.
  • Verify hardware with lspci, lsusb, and lscpu.

In the next lesson, we will explore a much safer way to practice: Installing Linux in Virtual Machines.

Quiz Questions

  1. Why is it a good idea to put /home on a separate partition?
  2. What does the dd command do in the context of OS installation?
  3. What is the purpose of the "Swap" space on a Linux system?

Continue to Lesson 2: Installing Linux in Virtual Machines—Safe Exploration with VirtualBox and VMware.

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn