UEFI BIOS + GRUB Bootloader Debian Install

Making a Clone/Backup of a Working System

Many PCs have only UEFI firmware, while older machines may use legacy BIOS/MBR booting. Debian and GRUB generally cope well with the variations encountered in UEFI implementations.

It is often useful to duplicate an existing, configured Debian installation rather than repeat package installation and configuration from scratch.

debclone is a small Python 3 utility which copies an installed Debian system to another whole disk and makes the target bootable. It supports both UEFI/GRUB and legacy BIOS/Syslinux targets.

The current programs are available as two Debian packages:

debclone 2.0-2
Main cloning utility.

shellpython 0.2-2
A small companion utility used to provide conventional command names for Python programs.

WARNING

debclone repartitions and formats the target device. Any existing operating system, including Windows, and ALL DATA on the target device will be destroyed.

The source installation is not modified.

Operation

The boot method is selected explicitly:

--uefi — GPT disk, FAT32 EFI System Partition and GRUB bootloader.

--bios — MBR disk, FAT32 boot partition and Syslinux bootloader.

The remaining space is used for an ext4 root filesystem.

The target root filesystem is identified by UUID rather than by a device name such as /dev/sda2, allowing disks to be moved between suitable machines or interfaces without relying on Linux device-name ordering.

For UEFI installations, GRUB is also placed in the standard removable/fallback EFI boot location. This reduces dependence on firmware NVRAM boot entries when a disk is moved to another machine.

Safety and Testing

debclone is a dry-run program by default. Destructive operations are performed only when --execute is specified.

The operation is divided into seven stages:

  1. Unmount target partitions
  2. Partition the target disk
  3. Format the new filesystems
  4. Copy the source system using rsync
  5. Configure the target, including /etc/fstab and optional swapfile
  6. Install the selected bootloader
  7. Synchronize and clean up

Individual stages can be selected with --steps. For example:

--steps 6

runs only the bootloader-installation stage, provided the required earlier state already exists.

Ranges and lists can also be used, for example:

--steps 4-6

or:

--steps 1-3,6

Selecting a later stage does not implicitly execute earlier stages.

Swap

No swap partition is created.

An optional swapfile can be requested, for example:

--swapfile 500M

or:

--swapfile 10.6G

The swapfile is created as part of target configuration in stage 5.

Help

Running:

debclone --help

shows the available options.

A sensible first run is without --execute, so that the intended operations can be inspected before allowing any changes to the target disk.

shellpython

shellpython is a small naming helper for Python programs.

shellfrompython foo

uses foo.py to provide an executable command named foo.

When run as root, it installs the Python program and launcher in /usr/local/bin.

When run without root privilege, the Python file remains where it is and the executable launcher is placed beside it.

No guarantees are made. These programs are supplied because they have proved useful in maintaining and duplicating Debian installations.