Debian Live USB with Persistence

From Archive Debian Forums
Jump to navigation Jump to search

All commands are verified on Debian 13.4 (Trixie) / 6.12.74+deb13+1-amd64

Created: 2026-04-04

Updated: 2026-04-09 - added references and restructured heading order;

ID: 005146.11


A Debian Live USB with persistence boots a full Debian environment from a USB drive while retaining changes across sessions. Files you create, settings you change, and packages you install survive reboot—stored on a dedicated partition rather than the volatile live environment. Nothing is written to the host machine’s internal disk.

A standard live USB is stateless: each boot starts from the same ISO image. The persistence partition changes that. From a single drive you get your shell configuration, documents, utilities, browser profile, and scripts, available on any machine you boot it from.

What You’ll Need

A USB drive of at least 8 GB—the minimum is 4 GB, but that leaves little room for persistence. A 32 GB drive is a practical working size. Download the Debian Live ISO from the official Debian website: https://www.debian.org/CD/live

The tools required—dd, fdisk, and mkfs.ext4—are standard on Debian. On a minimal live environment, fdisk and mkfs.ext4 may not be present. Install them before starting:

$ sudo apt install fdisk e2fsprogs

These packages are available from the live session’s apt cache without adding sources. They don’t persist to the USB unless persistence is already active.

Identifying Your USB Device

Plug in the USB drive and run:

$ lsblk

Your USB device will appear as /dev/sdb, /dev/sdc, or similar, depending on what else is attached. Confirm it by cross-referencing the reported size with the known capacity of the drive.

Two placeholders are used throughout this document. /dev/sdX refers to the device itself—substitute your actual device identifier everywhere it appears. /dev/sdXN refers to the persistence partition—N is the partition number you’ll confirm from lsblk output after you've created it.

Use the device path, not a partition path: /dev/sdb is correct; /dev/sdb1 is not.

Boot Entry Selection

The firmware boot menu on many systems presents two entries for a USB device: one labeled with the device name alone, and one prefixed with UEFI:. On the hardware used for this document, selecting the UEFI:-prefixed entry after adding a persistence partition consistently produced a bare grub> prompt rather than the Debian live menu. Selecting the plain device entry booted correctly every time.

Throughout this procedure, select the plain device entry—not the one prefixed with UEFI:.

This behavior was observed on specific hardware. Whether it reproduces on all firmware is not established here. The mechanism and a possible explanation are in [1] If your firmware presents only a UEFI boot path, recovery from within a booted live session may be possible by correcting the GRUB prefix, but that procedure is outside the scope of this document.

Procedure

Clean the Drive

If the USB has been used before, you may have residual partition signatures or bootloader data in the early sectors, and they can interfere with the ISO write or the subsequent boot. Clear them before starting:

$ sudo wipefs -a /dev/sdX

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=200

wipefs removes filesystem and partition table signatures. The dd command zeros the first 200 MB, covering the MBR, GPT header, and any EFI data in the early sectors.

Write the ISO

Before running dd, confirm that sync resolves to the system binary and not a shell alias:

$ type sync

The output should be sync is /usr/bin/sync. If it returns an alias definition instead, unalias it with unalias sync, or substitute /usr/bin/sync explicitly at the end of the dd command.

Write the ISO:

$ sudo dd if=/path/to/debian-live-13.4.0-amd64-kde.iso of=/dev/sdX bs=4M status=progress && sync

status=progress shows the running transfer rate. sync flushes the write cache on completion—don’t remove the drive before it returns. The write will take a few minutes depending on the drive’s speed.

Verify the Base Boot

Before adding the persistence partition, confirm the ISO write produced a bootable drive. Boot from the USB, selecting the plain (non-UEFI:) device entry. If it reaches the Debian live menu and boots cleanly, you have a confirmed working baseline. If it doesn’t boot at this stage, don’t continue—go back to 4.1 Clean the Drive and continue from there.

Create the Persistence Partition

The ISO write leaves unallocated space at the end of the drive. The persistence partition goes there. The Debian live ISO uses an isohybrid layout—a hybrid MBR/GPT partition table that supports both BIOS and UEFI boot paths. Adding a partition requires an explicit start sector; without it, fdisk’s default placement can conflict with the hybrid structure in ways that affect the boot. The failure modes of parted and gdisk with this layout are documented in [2]

Launch fdisk:

$ sudo fdisk /dev/sdX

Print the current partition table:

Command (m for help): p

Two partitions will be present: the main ISO partition (type 0 or Empty—this is expected for an isohybrid layout) and a small EFI partition of approximately 3.2 MB. The p output shows the end sector of the last partition in the End column. The persistence partition must start at the next sector—that value plus one. On the test hardware with a Debian 13.4 live ISO written to the drive, the last partition ended at sector 8175999 and the persistence partition started at sector 8176000. This figure will vary with the ISO version and release; read your own p output and don’t use the test value without verifying it matches.

Create the new partition:

Command (m for help): n

When fdisk prompts for the first sector, enter the start sector you identified from the p output—do not accept the default. Accept the default for the last sector to use the remaining space on the drive.

If fdisk asks whether to remove an existing ext4 signature, answer Y. This clears a remnant from a previous attempt.

Write the changes and exit:

Command (m for help): w

After fdisk writes the new partition table, the running kernel may not immediately recognize the change. partprobe signals the kernel to re-read the partition table on the device without requiring a reboot:

$ sudo partprobe /dev/sdX

Once it completes, confirm the new partition is visible:

$ lsblk /dev/sdX

Your new partition will appear beneath the device in the output. Note its full identifier—for example, sdb3 or sdc4—as you’ll need it in the next two steps. If it doesn’t appear immediately, wait a moment and run lsblk again before proceeding.

Format the Partition

Format the new partition as ext4 with the label persistence. The Debian live system identifies the persistence partition by this label at boot:

$ sudo mkfs.ext4 -L persistence /dev/sdXN

Create the Persistence Configuration

Mount the partition:

$ sudo mount /dev/sdXN /mnt

Create the configuration file:

$ echo "/ union" | sudo tee /mnt/persistence.conf

The / union directive instructs the live system to mount the entire filesystem as a union overlay. Changes made during a session are written to the persistence partition rather than discarded on shutdown.

Unmount the partition:

$ sudo umount /mnt

Boot with Persistence

Boot from the USB, selecting the plain (non-UEFI:) device entry in the firmware boot menu. At the Debian live GRUB menu, press Tab to edit the selected boot entry. On the line beginning with linux, append persistence after boot=live components. Press Enter to boot.

The first boot with persistence active will be slower than a standard live session—the system is running entirely from the USB drive, and the persistence overlay adds a layer of I/O. This is normal.

Verify Persistence

After booting, confirm the persistence partition is mounted:

$ lsblk -f

The output should show sdXN mounted at /run/live/persistence/sdXN.

Create a test file:

$ touch ~/persistence-test.txt

Reboot with persistence enabled. If the file is present after reboot, persistence is working.

What Didn’t Work, and Why

parted

parted misreported the capacity of the test USB drive: a 32 GB device was reported as approximately 125 GB. Determining where the free space began or how large to make the persistence partition was not possible from that output. parted was not used further. The broader behavior—libparted-based tools handling the isohybrid format unreliably—is documented on the Debian User mailing list [9].

gdisk / sgdisk

gdisk and sgdisk are GPT-aware tools and would seem the logical choice for a drive with a hybrid partition table. On the test USB, sgdisk produced:

Found invalid GPT and valid MBR; converting MBR to GPT format in memory.

Warning! Secondary partition table overlaps the last partition by 33 blocks!

Could not create partition 3 from 14580 to 8177663

Non-GPT disk; not saving changes. Use -g to override.

Error encountered; not saving changes.

The isohybrid layout places the secondary GPT header in a location that overlaps the last partition. sgdisk identifies this as invalid and refuses to proceed. Using -g to override would corrupt the hybrid layout and break the boot. sgdisk can’t be used here.

cp was also tested as an alternative to dd for writing the ISO, on the theory that it might handle the isohybrid structure differently. It produced an identical partition layout. It’s not an alternative—it’s a slower write with the same result.

The UEFI grub> Prompt

On the test hardware, adding a persistence partition and then selecting the UEFI:-prefixed boot entry consistently dropped to a bare grub> prompt. Running ls from that prompt showed the internal drive’s partitions; the USB’s live partition was unreachable from there.

What was observed: the USB’s own GRUB appeared briefly—visible as a rapid flash on screen with a “no such…” error—then failed, after which the firmware handed control to the internal drive’s GRUB, which presented its own grub> prompt.

The UEFI specification states that firmware may remove boot options it considers invalid [7]; the ArchWiki documents firmware removing entries for drives it detects as changed as a known occurrence [8]. After adding the persistence partition, the USB’s EFI entry—pointing to EFI/boot/bootx64.efi—may no longer have been treated as valid by the firmware, causing it to fall through to the next available bootloader on the internal drive. Whether modifying the partition table on a removable device is sufficient to trigger this behavior, and under what firmware conditions, wasn’t reproducible in a controlled way during testing.

Selecting the plain (non-UEFI:) device entry uses the legacy MBR boot path, which loads the USB’s own GRUB directly and has no dependency on the UEFI NVRAM or EFI boot entries. On the test hardware, this path was unaffected by partition table changes.

Anonymity

A Debian Live USB with persistence, used correctly, writes nothing to the host machine’s internal disk. It doesn’t modify the installed OS, create logs on the host filesystem, or leave traces in the usual locations.

It doesn’t provide anonymity. Boot events may be logged by firmware or enterprise management systems. Network activity is visible to routers, ISPs, and network administrators regardless of which OS is running. Mounting the internal disk during a live session makes its contents accessible to the live environment, and any writes to it are permanent. A live USB is a portable, self-contained Debian environment—it isn’t a privacy tool by design.

A Note on Carrying Data

The persistence partition is a practical place to keep working data alongside the system state—documents, scripts, configuration files, anything you’d normally keep in ~/Documents or ~/bin. It travels with the drive.

Installed packages persist across sessions but may have hardware-specific dependencies. For general desktop use this isn’t usually an issue, but it’s worth keeping in mind if you’re installing drivers or kernel modules that assume specific hardware.

Citations

Syslinux Project. “Isohybrid.” Syslinux Wiki.

[2] Linux Command Library. “isohybrid(1) man page.” https://linuxcommandlibrary.com/man/isohybrid

[3] Smith, Roderick W. “Hybrid MBRs.” GPT fdisk documentation. https://www.rodsbooks.com/gdisk/hybrid.html

[4] Debian Manpages. “persistence.conf(5).” live-boot-doc, Trixie. https://manpages.debian.org/trixie/live-boot-doc/persistence.conf.5.en.html

[5] Debian Live Team. “Customizing Run-Time Behaviours.” Debian Live Manual. https://live-team.pages.debian.net/live-manual/html/live-manual/customizing-run-time-behaviours.en.html

[6] Debian Manpages. “live-boot(7).” live-boot-doc. https://manpages.debian.org/unstable/live-boot-doc/live-boot.7.en.html

[7] UEFI Forum. “Boot Manager.” UEFI Specification 2.10, §3. https://uefi.org/specs/UEFI/2.10/03_Boot_Manager.html

[8] ArchWiki. “Unified Extensible Firmware Interface.” https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface

[9] Debian User Mailing List. “Error message from GParted, means what?” November 2016. https://lists.debian.org/debian-user/2016/11/msg01017.html



Contributed by distro-nix on Debian User Forums on 2026-04-06. Comments, corrections, suggestions or resources are welcome.