#3656 PR merged: BLOCKCLONE: support GPT disks, and fix two unset variables and a silent sfdisk failure¶
Labels: enhancement, minor bug, ready-to-merge?
abdelhaleemahmed opened issue at 2026-10-16 17:11:¶
Relax-and-Recover (ReaR) Pull Request Template¶
Pull Request Details:¶
-
Type: Bug Fix
-
Impact: Normal
-
Reference to related issue (URL): https://github.com/rear/rear/issues/3655
-
How was this pull request tested?
On Ubuntu 24.04.4 (kernel 6.8.0-107-generic), ReaR 2.9,
BACKUP=BLOCKCLONEwithBACKUP_URL="file://...", both partition table types, with the exact files in this branch:GPT, 1 GB loop device, 64 MiB ESP + NTFS partition. Before the change,
rear mkbackuponlyaborts withBUG ... Unknown partition table on /dev/loop0. After it:Copying /var/lib/rear/layout/testvol_partitions.conf to /var/lib/rear/gpttest/<host> Creating /var/lib/rear/gpttest/<host>/testvol.ntfsclone.img from /dev/loop0p2 using ntfscloneRestoring onto a second, blank 1 GB loop device reproduced the layout with both partition GUIDs intact, and a marker file inside the NTFS volume came back with the same md5 it went in with.
msdos, same shape, to confirm nothing regressed: the layout is still saved as an
sfdisk -dtext dump,mbrvol_boot_strap.imgis still written and still copied, the restore still takes thesfdiskbranch, and the round trip is byte-identical.A real machine: a UEFI Windows Server 2022 guest (GPT, 128 GiB, ESP + MSR + NTFS) was imaged from a Linux system with these changes, its disk destroyed, and the GPT, the ESP and the NTFS volume restored onto an empty 128 GiB disk. It booted unaided with the same
MachineGuid, the same three partition GUIDs, the same filesystem serials, byte-identical registry hives and a clean NTFS dirty bit.ntfscloneput the 136,778,350,592-byte partition into 8,269,323,012 bytes (6.0% in use) and restored it in 92 seconds. -
Description of the changes in this pull request:
Three commits, one problem each. All of them are in the
BLOCKCLONEpaths; both msdos paths are unchanged and were re-tested as described above.1.
BLOCKCLONE: save the partition layout of GPT diskslayout/save/default/350_save_partitions.shhad the("gpt")case present but commented out with#~, so a GPT disk fell through to theBugError. This enables it using thesgdisk -bcall that was already written there, and removes the# TODO: @gozora add gpt supportabove it. No bootstrap code area is saved in that branch, deliberately: on a GPT disk the boot loader is a file in the EFI System Partition rather than code in the MBR gap.2.
BLOCKCLONE: set the URL scheme and path before computing the backup pathbackup/BLOCKCLONE/default/400_copy_disk_struct_files.shused$schemeand$pathwithout ever assigning them, sobackup_path()was called with two empty arguments and returned a different directory from the one200_make_prefix_dir.shhad just created:cp: cannot create regular file '/var/tmp/rear.XXXXXXXX/outputfs/<hostname>': No such file or directoryIt now assigns both the way the sibling script that creates the directory does. This also drops the
local backup_path=..., which shadowed the name of thebackup_pathfunction called on the next line. The same two lines appear inrestore/BLOCKCLONE/default/390_create_partitions.shand are fixed there in commit 3.3.
BLOCKCLONE: restore GPT layouts, and do not copy a bootstrap that was not saved390_create_partitions.shalways restored the layout withsfdisk. For a GPT disk the saved file is ansgdiskbinary backup, and feeding that tosfdiskdoes not fail — it declines and exits 0:# sfdisk /dev/loop1 < testvol_partitions.conf >>> line 1: unsupported command New situation: Leaving. # echo $? 0so
StopIfErrornever fires and the restore continues against a disk that still has no partitions. The tool is now chosen from what was actually saved rather than from a new configuration variable, since350_save_partitions.shwrites a text dump beginninglabel:for msdos and a binary backup for GPT.sgdisk -lrestores the disk GUID and the partition GUIDs along with the sizes, which matters because a UEFI boot configuration can name the partition it boots from by GUID.The same commit guards the
BLOCKCLONE_MBR_FILEcopy in400_copy_disk_struct_files.sh, since that file only exists for msdos labelled disks.
Note on scope¶
doc/user-guide/12-BLOCKCLONE.adoc lists GPT and UEFI as unsupported
work in progress, so parts 1 and 3 could reasonably be called a feature
rather than a fix, and I am happy to split them out if you would prefer
the variable fix on its own. Part 2, and the silent exit 0 in part 3,
look like plain bugs independent of that decision.
I have not touched doc/user-guide/12-BLOCKCLONE.adoc, since what to
say about GPT support there seemed better decided by the maintainers
than by me. Restoring a UEFI system still needs one BLOCKCLONE
configuration per partition — one for the ESP with BLOCKCLONE_PROG=dd
and one for the NTFS volume — and that is worth documenting if these
changes are taken.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KqVBvx74iXKfBoQ9F1RhxL
codacy-production commented at 2026-10-16 17:12:¶
Not up to standards ⛔¶
🔴 Issues 2 medium
> > > **Alerts:** > ⚠ 2 issues (≤ 0 issues of at least minor severity) > > **Results:** > `2` new issues > >
| Category | >Results | >
|---|---|
| BestPractice | >2 medium |
>
NEW Get contextual insights on your PRs based on Codacy's
metrics, along with PR and Jira context, without leaving GitHub. Enable
AI
reviewer
TIP This summary will be updated as you push new changes.
gdha commented at 2026-10-26 11:28:¶
@abdelhaleemahmed See comments https://app.codacy.com/gh/rear/rear/pull-requests/3656/issues
gdha commented at 2026-11-02 14:25:¶
@rear/contributors if there are no objections would like to merge this PR by then end of this week.
[Export of Github issue for rear/rear.]