# Debian Live Build Notes

> **Archived developer notes.** This document was the original [`README.md`](../README.md) for this repository when it was primarily a Debian live-build tutorial. It has been moved here to preserve the reference material now that [`README.md`](../README.md) focuses on the n-OS-tr product vision.
>
> Nothing in this document is a contract — it is a collection of live-build recipes, package-discovery tips, GUI options, minimization tactics, and persistence notes we accumulated while bootstrapping the ISO build. Anything that is part of the real product lives elsewhere (typically in [`plans/`](../plans/) or under [`iso/`](../iso/)).

## Debian Live Build Setup and Tutorial 1 Implementation

This document covers the complete process of setting up live-build and implementing Tutorial 1 from the Debian Live Manual.

### System Requirements

Tested on Pop!_OS 22.04 LTS (Ubuntu-based system).

### Phase 1: Installing Dependencies

The following packages are required for building Debian Live images:

```bash
sudo apt update
sudo apt install debootstrap xorriso squashfs-tools syslinux-utils cpio gzip gettext
```

**Package purposes:**
- `debootstrap`: Creates minimal Debian base system
- `xorriso`: Creates ISO images
- `squashfs-tools`: Creates compressed filesystem
- `syslinux-utils`: Boot loader utilities
- `cpio`, `gzip`, `gettext`: Archive and localization utilities

### Phase 2: Setting up Live-Build from Repository

Instead of installing live-build via system packages (which may be outdated), we use the repository directly for the most current version.

#### Creating the Wrapper Script

Create `lb-wrapper.sh` for convenient access to live-build commands:

```bash
#!/bin/bash

# Set the LIVE_BUILD environment variable to point to our repository
export LIVE_BUILD="$(dirname "$0")/live-build"

# Execute the live-build frontend with all arguments passed through
"$LIVE_BUILD/frontend/lb" "$@"
```

Make it executable:
```bash
chmod +x lb-wrapper.sh
```

**Usage:** Replace all `lb` commands with `./lb-wrapper.sh` to use the repository version.

### Phase 3: Tutorial 1 - Default Image Creation

Following the Debian Live Manual Tutorial 1 to create a basic live system:

```bash
mkdir tutorial1
cd tutorial1
../lb-wrapper.sh config
```

This creates the basic configuration structure in the `config/` directory.

### Phase 4: Building the Image

**Important:** Due to keyring compatibility issues between Ubuntu/Pop!_OS and Debian, we need to bypass GPG verification for development builds.

Build the image as root with security bypass:

```bash
sudo ../lb-wrapper.sh config --apt-secure false --distribution stable
sudo ../lb-wrapper.sh build 2>&1 | tee build.log
```

### Keyring Issues and Troubleshooting

**Problem:** Pop!_OS/Ubuntu keyrings are incompatible with both Debian testing and stable distributions, causing GPG verification failures.

**Error examples:**
- Debian testing: `The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 78DBA3BC47EF2265`
- Debian stable: `The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 762F67A0B2C39DE4`

**Solution:** Use `--apt-secure false` flag to bypass GPG verification for development purposes.

**Production note:** For production builds, proper keyring setup should be implemented instead of disabling security checks.

### Expected Results

- Build time: Varies based on internet connection and system performance
- Output file: `live-image-amd64.hybrid.iso` (approximately 298MB)
- This ISO can be:
  - Tested in virtual machines (QEMU, VirtualBox)
  - Written to USB drives
  - Burned to optical media

### Command Summary

Complete sequence for Tutorial 1:

```bash
# 1. Install dependencies
sudo apt install debootstrap xorriso squashfs-tools syslinux-utils cpio gzip gettext

# 2. Create wrapper script (if not exists)
# [Create lb-wrapper.sh as shown above]
chmod +x lb-wrapper.sh

# 3. Create and configure tutorial
mkdir tutorial1
cd tutorial1
../lb-wrapper.sh config --apt-secure false --distribution stable

# 4. Build image
sudo ../lb-wrapper.sh build 2>&1 | tee build.log

# 5. Result: live-image-amd64.hybrid.iso ready for testing
```

### Notes

- The `--distribution stable` ensures we use Debian stable instead of the default testing
- Build logs are automatically saved due to the wrapper script configuration
- The `--apt-secure false` flag is a workaround for keyring issues on Ubuntu-based systems
- For clean rebuilds, use `sudo ../lb-wrapper.sh clean` before building again

## FAQ

### Q: What are the auto, config, and local directories created by `lb config` for?

**A:** When you run `lb config`, three directories are created:

1. **auto/** - Created but empty by default
   - Used for optional automation scripts that you create yourself
   - You can add `auto/config`, `auto/build`, `auto/clean` scripts that run automatically before their respective `lb` commands
   - Most basic builds (like Tutorial 1) don't need these files
   - Useful for advanced scenarios where you want reproducible builds with version control

2. **config/** - This is where the real configuration lives
   - Contains all the subdirectories for customizing your live system
   - Has the main config files (binary, bootstrap, chroot, common, source) with your build parameters
   - This is where you add package lists, custom files, hooks, etc.
   - Most important directory for customization

3. **local/** - For local customizations
   - Also typically empty unless you have custom executables or files to include
   - Used for build-time scripts and tools, not files to include in the final system

### Q: How do I add files to specific locations in the final live system?

**A:** Several directories in the config structure map directly to the final system filesystem:

**For files you want in the final live system:**

1. **config/includes.chroot/** - Maps directly to the root filesystem (`/`)
   - To put a file in `/usr/local/bin/myscript` in the final system
   - Place it at `config/includes.chroot/usr/local/bin/myscript`
   - Everything in this directory gets copied to `/` in the live system

2. **config/includes.chroot_after_packages/** - Same mapping, but copied after packages are installed
   - Use when you want to overwrite files that packages might have installed
   - Same directory mapping as above

3. **config/includes.chroot_before_packages/** - Copied before packages are installed
   - Less commonly used, but available if needed

**For files you want on the ISO/boot media itself (not in the live system):**

4. **config/includes.binary/** - Files that go on the boot media
   - These appear on the USB/CD itself, not inside the running live system
   - Useful for documentation, additional tools, etc.

**Example:** To put a custom script in `/usr/local/bin/hello` in your live system:
```bash
# 1. Create the directory structure
mkdir -p config/includes.chroot/usr/local/bin/

# 2. Put your script there
cp myscript config/includes.chroot/usr/local/bin/hello

# 3. Make it executable
chmod +x config/includes.chroot/usr/local/bin/hello
```

The build process will automatically copy it to the correct location in the live system.

### Q: How would I add a splash screen that would come up upon booting?

**A:** There are several methods to add splash screens to your Debian Live system, depending on when and how you want the splash to appear:

#### Method 1: Boot Loader Splash (Easiest - SYSLINUX)

For a simple graphical background during boot menu selection:

**1. Prepare your splash image:**
```bash
# Create the bootloader directory
mkdir -p config/bootloaders/syslinux

# Your image should be:
# - PNG or JPEG format
# - 640x480 resolution (for best compatibility)
# - Named something like splash.png
cp your-splash-image.png config/bootloaders/syslinux/splash.png
```

**2. Create custom syslinux configuration:**
```bash
# Copy the default syslinux config to customize
cp live-build/share/bootloaders/syslinux/* config/bootloaders/syslinux/

# Edit config/bootloaders/syslinux/syslinux.cfg
# Add this line after the first line:
# MENU BACKGROUND splash.png
```

#### Method 2: Plymouth Boot Splash (Advanced - Animated)

For professional animated boot screens like Ubuntu's spinning logo:

**1. Add Plymouth to your package list:**
```bash
echo "plymouth plymouth-themes" >> config/package-lists/splash.list.chroot
```

**2. Configure Plymouth theme:**
```bash
# Create Plymouth configuration directory
mkdir -p config/includes.chroot/etc/plymouth

# Set the default theme (example: solar theme)
echo "[Daemon]" > config/includes.chroot/etc/plymouth/plymouthd.conf
echo "Theme=solar" >> config/includes.chroot/etc/plymouth/plymouthd.conf
```

**3. Enable Plymouth in boot parameters:**
```bash
# When running lb config, add:
../lb-wrapper.sh config --bootappend-live "boot=live components splash quiet"
```

#### Method 3: GRUB Graphical Splash (For EFI systems)

For systems using GRUB (EFI boot):

**1. Create GRUB bootloader directory:**
```bash
mkdir -p config/bootloaders/grub-pc
```

**2. Add custom GRUB background:**
```bash
# Copy your background image (PNG, JPG, or TGA format)
# Recommended size: 1024x768 or your target resolution
cp your-background.png config/includes.binary/boot/grub/background.png
```

**3. Create custom GRUB configuration:**
```bash
# Create config/bootloaders/grub-pc/grub.cfg with:
cat > config/bootloaders/grub-pc/grub.cfg << 'EOF'
if background_image /boot/grub/background.png; then
  set color_normal=white/black
  set color_highlight=black/light-gray
else
  set menu_color_normal=cyan/blue
  set menu_color_highlight=white/blue
fi
EOF
```

#### Method 4: Desktop Splash Screen

For splash screens that appear when the desktop environment starts:

**1. Add to package list (example with LXDE):**
```bash
echo "lxsplash" >> config/package-lists/desktop.list.chroot
```

**2. Configure desktop splash:**
```bash
# Create desktop configuration directory
mkdir -p config/includes.chroot/etc/xdg/lxsession/LXDE

# Configure lxsession to show splash
echo "lxsplash -s" > config/includes.chroot/etc/xdg/lxsession/LXDE/autostart
```

#### Quick Start Recommendation

**For beginners:** Start with Method 1 (SYSLINUX background) - it's simple and works reliably.

**Example complete setup:**
```bash
# 1. Create bootloader directory and add image
mkdir -p config/bootloaders/syslinux
cp ~/my-logo.png config/bootloaders/syslinux/splash.png

# 2. Copy default syslinux files to customize
cp -r live-build/share/bootloaders/syslinux/* config/bootloaders/syslinux/

# 3. Edit the main config file
sed -i '2i MENU BACKGROUND splash.png' config/bootloaders/syslinux/syslinux.cfg

# 4. Build with your custom splash
sudo ../lb-wrapper.sh build
```

**Notes:**
- Image formats: PNG works best for syslinux, JPG for GRUB
- Keep images reasonably sized to avoid slowing boot time
- Test your splash screen in a virtual machine first
- For production systems, ensure images are properly licensed

### Q: What are the main options for adding a GUI? How do I add them?

**A:** Debian Live supports several GUI options, from lightweight window managers to full desktop environments. Here are the main options and how to implement them:

#### Lightweight Window Managers (Minimal Resource Usage)

##### 1. Openbox (Very Light)
```bash
echo "openbox obconf obmenu tint2 pcmanfm lxappearance" >> config/package-lists/gui.list.chroot
```
**Features:** Basic window manager, highly customizable, ~50MB additional space
**Best for:** Minimal systems, older hardware, custom interfaces

##### 2. i3 (Tiling Window Manager)
```bash
echo "i3 i3status dmenu i3lock" >> config/package-lists/gui.list.chroot
```
**Features:** Tiling window manager, keyboard-driven, very efficient
**Best for:** Power users, developers, keyboard-focused workflows

##### 3. Fluxbox
```bash
echo "fluxbox fbpanel pcmanfm" >> config/package-lists/gui.list.chroot
```
**Features:** Fast, simple, tabbed windows
**Best for:** Minimal desktop needs, simple interfaces

#### Desktop Environments (Full-Featured)

##### 4. LXDE (Lightweight Desktop Environment)
```bash
echo "task-lxde-desktop" >> config/package-lists/gui.list.chroot
```
**Features:** Complete desktop with panel, file manager, settings
**Size:** ~400MB additional
**Best for:** Beginner-friendly, low resource usage, complete desktop experience

##### 5. Xfce (Moderate Resource Usage)
```bash
echo "task-xfce-desktop" >> config/package-lists/gui.list.chroot
```
**Features:** Full-featured, customizable, good performance
**Size:** ~600MB additional
**Best for:** Balance between features and performance

##### 6. GNOME (Full-Featured)
```bash
echo "task-gnome-desktop" >> config/package-lists/gui.list.chroot
```
**Features:** Modern interface, many applications, polished experience
**Size:** ~1.5GB additional
**Best for:** Modern desktop experience, touch interfaces, latest features

##### 7. KDE Plasma (Full-Featured)
```bash
echo "task-kde-desktop" >> config/package-lists/gui.list.chroot
```
**Features:** Highly customizable, many applications, modern interface
**Size:** ~1.2GB additional
**Best for:** Power users who want customization and modern features

#### Quick Setup Examples

##### Example 1: Minimal GUI System (LXDE + Firefox)
```bash
# Create tutorial directory
mkdir tutorial-gui
cd tutorial-gui

# Configure with GUI
../lb-wrapper.sh config --apt-secure false --distribution stable

# Add desktop and browser
echo "task-lxde-desktop firefox-esr" >> config/package-lists/desktop.list.chroot

# Optional: Add useful applications
echo "synaptic gdebi leafpad galculator" >> config/package-lists/apps.list.chroot

# Build
sudo ../lb-wrapper.sh build
```

##### Example 2: Kiosk System (Single Application)
```bash
# Minimal X11 setup for single application
echo "xorg gdm3 openbox firefox-esr" >> config/package-lists/kiosk.list.chroot

# Auto-start Firefox in kiosk mode
mkdir -p config/includes.chroot/etc/skel
cat > config/includes.chroot/etc/skel/.xsession << 'EOF'
#!/bin/sh
openbox &
firefox --kiosk https://example.com
EOF
```

##### Example 3: Developer Workstation
```bash
# Add Xfce desktop with development tools
echo "task-xfce-desktop" >> config/package-lists/desktop.list.chroot
echo "code git build-essential python3 nodejs npm" >> config/package-lists/dev.list.chroot
echo "terminator vim emacs" >> config/package-lists/editors.list.chroot
```

#### GUI Components Explanation

##### Essential X11 Components (Required for any GUI)
```bash
# Always needed for graphical interface
echo "xorg" >> config/package-lists/x11.list.chroot
```

##### Display Managers (Login Screen)
```bash
# Lightweight
echo "lightdm" >> config/package-lists/dm.list.chroot

# GNOME/modern
echo "gdm3" >> config/package-lists/dm.list.chroot

# Simple
echo "slim" >> config/package-lists/dm.list.chroot
```

##### Common Applications by Category
```bash
# File managers
echo "pcmanfm nautilus thunar" >> config/package-lists/filemanagers.list.chroot

# Text editors
echo "gedit mousepad kate" >> config/package-lists/editors.list.chroot

# Web browsers
echo "firefox-esr chromium" >> config/package-lists/browsers.list.chroot

# Media players
echo "vlc mpv rhythmbox" >> config/package-lists/media.list.chroot

# Graphics
echo "gimp inkscape" >> config/package-lists/graphics.list.chroot
```

#### Resource Usage Comparison

| Desktop Environment | RAM Usage | Disk Space | Boot Time | Complexity |
|-------------------|-----------|------------|-----------|------------|
| Openbox alone     | ~100MB    | ~50MB      | Fast      | Simple     |
| LXDE              | ~200MB    | ~400MB     | Fast      | Easy       |
| Xfce              | ~300MB    | ~600MB     | Medium    | Medium     |
| GNOME             | ~800MB    | ~1.5GB     | Slow      | Complex    |
| KDE Plasma        | ~600MB    | ~1.2GB     | Medium    | Complex    |

#### Advanced GUI Configuration

##### Custom Desktop Theme
```bash
# Create theme directory
mkdir -p config/includes.chroot/usr/share/themes/MyTheme

# Add custom wallpaper
mkdir -p config/includes.chroot/usr/share/pixmaps
cp my-wallpaper.jpg config/includes.chroot/usr/share/pixmaps/

# Set default wallpaper for LXDE
mkdir -p config/includes.chroot/etc/xdg/pcmanfm/LXDE
cat > config/includes.chroot/etc/xdg/pcmanfm/LXDE/desktop-items-0.conf << 'EOF'
[*]
wallpaper_mode=stretch
wallpaper_common=1
wallpaper=/usr/share/pixmaps/my-wallpaper.jpg
EOF
```

##### Auto-login Configuration
```bash
# For LXDE with automatic login
mkdir -p config/includes.chroot/etc/lightdm
cat > config/includes.chroot/etc/lightdm/lightdm.conf << 'EOF'
[Seat:*]
autologin-user=user
autologin-user-timeout=0
EOF
```

#### Recommendation Guide

**For new users:** Start with LXDE (`task-lxde-desktop`)
- Easy to use
- Good performance
- Includes essential applications
- Well documented

**For minimal systems:** Use Openbox + essential apps
- Very low resource usage
- Fast boot times
- Customizable

**For modern experience:** Choose Xfce or GNOME
- Modern interface
- Good hardware support
- Regular updates

**For specific use cases:** Custom combinations
- Kiosk systems: Openbox + single application
- Developer workstations: Xfce + development tools
- Media centers: Minimal WM + media applications

### Q: How do I look up applications on my current system to get package names for config/package-lists?

**Q: I want to include applications I currently use in my live system. How do I find the exact package names to add to my config/package-lists files?**

**A:** There are several methods to discover package names from installed applications. Here are the most effective approaches:

#### Method 1: List All Installed Packages

##### Using dpkg (Debian Package Manager)
```bash
# List all installed packages with descriptions
dpkg -l | grep -i "search-term"

# Examples:
dpkg -l | grep -i firefox          # Find Firefox packages
dpkg -l | grep -i editor           # Find text editors
dpkg -l | grep -i media            # Find media applications
```

##### Using apt
```bash
# List all manually installed packages
apt list --installed | grep -i "search-term"

# Show only manually installed (not dependencies)
apt-mark showmanual | grep -i "search-term"

# Examples:
apt list --installed | grep -i gimp
apt-mark showmanual | grep -i code
```

#### Method 2: Find Package for Specific Application

##### Using which and dpkg
```bash
# Find which package provides a specific command
which firefox
dpkg -S $(which firefox)

# Or in one command:
dpkg -S $(which firefox) | cut -d: -f1

# Examples:
dpkg -S $(which code)              # Find VS Code package
dpkg -S $(which vlc)               # Find VLC package
dpkg -S $(which gimp)              # Find GIMP package
```

##### Using apt-file (if installed)
```bash
# First install and update apt-file
sudo apt install apt-file
sudo apt-file update

# Find package containing a file
apt-file search /usr/bin/firefox
apt-file search gimp

# Find package containing any file with name
apt-file search -x '/usr/bin/.*firefox.*'
```

#### Method 3: Application-Specific Discovery

##### Desktop Applications (.desktop files)
```bash
# List all desktop applications
ls /usr/share/applications/*.desktop | while read app; do
    name=$(basename "$app" .desktop)
    echo "Desktop entry: $name"
    # Find which package provides this .desktop file
    dpkg -S "$app" 2>/dev/null | cut -d: -f1
done
```

##### GUI Application Discovery
```bash
# Find packages by searching application menu names
dpkg -l | awk '/^ii/{print $2}' | while read pkg; do
    if dpkg -L "$pkg" 2>/dev/null | grep -q "/usr/share/applications/"; then
        echo "Package with GUI: $pkg"
    fi
done
```

#### Method 4: Category-Based Package Discovery

##### By Package Sections
```bash
# Find packages by category
dpkg-query -W -f='${Package} ${Section}\n' | grep -E "(graphics|video|audio|editors|web|games)" | sort

# Specific categories:
dpkg-query -W -f='${Package} ${Section}\n' | grep graphics
dpkg-query -W -f='${Package} ${Section}\n' | grep editors
dpkg-query -W -f='${Package} ${Section}\n' | grep web
```

##### By Description Content
```bash
# Search package descriptions for keywords
apt-cache search "text editor" | head -10
apt-cache search "media player" | head -10
apt-cache search "graphics" | head -10
apt-cache search "development" | head -10
```

#### Method 5: Practical Examples

##### Common Applications and Their Package Names

**Web Browsers:**
```
Firefox         → firefox-esr
Google Chrome   → google-chrome-stable (requires external repository)
Chromium        → chromium
```

**Text Editors:**
```
VS Code         → code (requires external repository)
Sublime Text    → sublime-text (requires external repository)
Vim             → vim
Emacs           → emacs
Nano            → nano
Gedit           → gedit
```

**Media Applications:**
```
VLC             → vlc
GIMP            → gimp
Inkscape        → inkscape
Audacity        → audacity
OBS Studio      → obs-studio
```

**Development Tools:**
```
Git             → git
Node.js         → nodejs
Python          → python3
Docker          → docker.io
```

#### Method 6: Generate Package List from Current System

##### Create Complete Package List
```bash
# Generate a list of all manually installed packages
apt-mark showmanual > my-current-packages.txt

# Clean up the list (remove system packages you don't want)
# Then use in your live-build:
cp my-current-packages.txt config/package-lists/current-system.list.chroot
```

##### Create Filtered Package List
```bash
# Create list excluding system packages
apt-mark showmanual | grep -v -E "^(linux-|grub-|systemd|udev|apt|dpkg)" > config/package-lists/applications.list.chroot
```

#### Method 7: Interactive Package Discovery

##### Using Synaptic Package Manager
```bash
# Install Synaptic for GUI package browsing
sudo apt install synaptic

# Launch Synaptic, browse categories, note package names
# Then add them to your package lists
```

##### Using aptitude (Text UI)
```bash
# Install aptitude for interactive package management
sudo apt install aptitude

# Launch aptitude, browse packages interactively
aptitude
```

#### Tips and Best Practices

**Package Name Variations:**
- Some applications have different names in Debian repositories
- Use `apt search application-name` to find alternatives
- Check both the main package and `-dev` packages if you need development files

**Metapackages vs Individual Packages:**
- `task-*` packages install complete desktop environments
- Individual packages give more control over what's installed
- You can mix both approaches in different `.list.chroot` files

**External Repositories:**
- Some applications (VS Code, Chrome) require external repositories
- Consider using alternative packages available in Debian repos (Chromium instead of Chrome)
- Document external repository requirements separately

**Testing Package Lists:**
- Test your package lists in a virtual machine before final build
- Use `apt-cache policy package-name` to verify package availability
- Check package dependencies with `apt-cache depends package-name`

### Q: This is live-build, so it runs in memory. Can you also install it to disk if you want?

**A:** Yes! Debian Live systems are designed to run both ways - as temporary live systems in memory AND as permanent installations to disk.

#### Live vs Installed - The Difference

**Live Mode (Default):**
- Runs entirely from USB/CD/DVD in RAM
- No changes are saved (unless using persistence - see below)
- Perfect for testing, troubleshooting, portable computing
- No installation required - boot and go

**Installed Mode:**
- Permanently installed to hard disk like any other OS
- All changes saved normally
- Full desktop OS experience
- Can dual-boot with other operating systems

#### Installation Methods

##### Method 1: Include Debian Installer (Recommended)

Add the installer to your live build configuration:

```bash
# When configuring your build, enable the installer
../lb-wrapper.sh config --debian-installer live --apt-secure false --distribution stable

# Add installer launcher to desktop
echo "debian-installer-launcher" >> config/package-lists/installer.list.chroot
```

##### Method 2: Text-based Installer

```bash
# Add text installer to config
../lb-wrapper.sh config --debian-installer true --apt-secure false --distribution stable
```

##### Method 3: Live-Installer (Simpler)

```bash
# Add live-installer package
echo "live-installer" >> config/package-lists/installer.list.chroot
```

#### Persistence (Hybrid Approach)

##### Create Persistent USB

```bash
# Create persistence partition on USB after writing ISO
# (This example assumes USB device is /dev/sdb - VERIFY YOUR DEVICE!)

# 1. Write ISO to USB first
sudo dd if=live-image-amd64.hybrid.iso of=/dev/sdb bs=4M status=progress

# 2. Create additional partition for persistence
sudo fdisk /dev/sdb
# Create new partition using remaining space

# 3. Format persistence partition
sudo mkfs.ext4 -L persistence /dev/sdb2

# 4. Mount and create persistence.conf
sudo mkdir -p /mnt/persistence
sudo mount /dev/sdb2 /mnt/persistence
echo "/ union" | sudo tee /mnt/persistence/persistence.conf
sudo umount /mnt/persistence
```

##### Enable Persistence at Boot

```bash
# Add to boot parameters
boot=live components persistence
```

> **Note for n-OS-tr**: persistence is **explicitly discouraged** for this project — see [`plans/threat_model.md`](../plans/threat_model.md) for why ephemerality is a privacy property we refuse to weaken by default. Persistence is kept here only as reference material.

### Q: How small can you go?

**A:** System minimization in Debian Live is possible, but there are important limitations. Core utilities like `ls` are part of essential packages that cannot be safely removed.

#### Understanding Essential vs Optional Packages

**Essential Packages (Cannot Remove):**
- **coreutils** (includes `ls`, `cp`, `mv`, `cat`, `mkdir`, etc.)
- **bash** (shell interpreter)
- **init systems** (systemd or equivalent)
- **libc6** (core C library)
- **dpkg** (package manager)

**Why `ls` Cannot Be Removed:**
```bash
dpkg -S $(which ls)
# Output: coreutils: /bin/ls

dpkg -s coreutils | grep Essential
# Output: Essential: yes
```

Essential packages are marked as such because removing them would break the system fundamentally.

#### Minimization Strategies

##### Strategy 1: Minimal Debootstrap (Recommended)

```bash
../lb-wrapper.sh config \
    --apt-secure false \
    --distribution stable \
    --debootstrap-options "--variant=minbase" \
    --apt-recommends false \
    --apt-indices false \
    --firmware-chroot false \
    --memtest none \
    --binary-image hdd

echo "user-setup sudo" > config/package-lists/essential.list.chroot
echo "ifupdown isc-dhcp-client" >> config/package-lists/essential.list.chroot
```

**Results:** ~298MB system (compared to ~380MB default)

##### Strategy 2: Remove Non-Essential Recommended Packages

```bash
../lb-wrapper.sh config --apt-recommends false
echo "live-tools eject" > config/package-lists/minimal-live.list.chroot
```

##### Strategy 3: Custom Package Exclusions

```bash
mkdir -p config/hooks/normal
cat > config/hooks/normal/0010-remove-optional.hook.chroot << 'EOF'
#!/bin/bash

# Remove documentation to save space
rm -rf /usr/share/doc/*
rm -rf /usr/share/man/*
rm -rf /usr/share/info/*

# Remove locale data except for English
find /usr/share/locale -mindepth 1 -maxdepth 1 -type d ! -name 'en*' -exec rm -rf {} \;

# Remove cached package files
apt-get clean
EOF
```

**Warning:** This violates package integrity and may cause issues.

#### Size Comparison Table

| Configuration Type | Size | Boot Time | Functionality |
|-------------------|------|-----------|---------------|
| Default Tutorial 1 | ~380MB | Medium | Basic console + live tools |
| Minimal (minbase) | ~280MB | Fast | Essential console only |
| Ultra-minimal hook | ~250MB | Very fast | Bare minimum (risky) |
| Minimal GUI | ~450MB | Medium | Basic graphical interface |
| Full LXDE | ~800MB | Slow | Complete desktop |

#### The Bottom Line: Practical Limits

- **Theoretical minimum:** ~180-200MB (unstable, breaks functionality)
- **Practical minimum:** ~250-280MB (stable, console-only)
- **Recommended minimum:** ~350-400MB (includes basic GUI capability)

#### Best Practices for Minimization

1. **Start with `--debootstrap-options "--variant=minbase"`** — safest reduction
2. **Disable recommendations** with `--apt-recommends false`
3. **Remove documentation/locales** via hooks if space is critical
4. **Test thoroughly** — minimal systems may lack expected tools
5. **Document what you removed** for troubleshooting
6. **Consider alternatives** like Alpine Linux for truly minimal containers

**Remember:** Core utilities like `ls`, `cp`, `mv` are fundamental to Unix-like systems. Focus on removing optional packages, documentation, and recommended packages instead of core system utilities.

The goal should be "minimal but functional" rather than "absolutely smallest possible" for any system you plan to actually use.
