UEFI BIOS + GRUB Bootloader Debian Install



Making Clone/Backup of Working System


Many PC's have only UEFI bioses, other older PC's only have MBR. Mostly Debian boot USB sticks using Grub seem able to cope with most of the UEFI bios quirks.
It was helpful to duplicate existing installations rather than going through the rigmarole of package installation and configuration.
I have made a python3 script which duplicates an installed system and makes a bootable target (either UEFI+grub or MBR+syslinux) copy or vice versa. It has proved useful so I am making it downloadable with no guarantees as two files here.
Main File and Includes
If the script is executed without parameters a helpfile is printed as is a list of any missing packages needed. Sudo must be installed to provide passwordless command input.
The script will overwrite any existing operating systems on the target device such as Windows and all data!
The target drive is divided into two partitions (minimal boot and remaining root) and assumes a swapfile is to be used. The target partition is upgraded using apt and initramfs before executing grub.
After using this script to install a release on a pc the hostname needs to updated, and a swapfile generated. I may update the script to include this as an option. Since a lot of UEFI bioses have bugs, it is often easier to use the "-m" option and generate an MBR clone, so long as the bios can handle MBR formatted disks, and so long as the active partion holds less than 2gb.