Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
## rpi-clone
Latest version: 2.0.22
## rpi-clone - Actively Maintained Fork
Latest version: 2.0.23

> **🔧 This is an actively maintained fork** of the original rpi-clone by billw2. The original repository hasn't been updated since 2020, leaving critical compatibility issues unresolved. This fork includes essential fixes for modern Raspberry Pi OS and ongoing maintenance.

### Key Improvements in This Fork:
- ✅ **Fixed boot partition detection** for modern Raspberry Pi OS (Bookworm/2024+) that uses `/boot/firmware`
- ✅ **Backward compatible** with older systems using `/boot`
- ✅ **Actively maintained** with bug fixes and compatibility updates
- ✅ **Responsive to issues** and pull requests

### Why Use This Fork?
The original rpi-clone fails on modern Raspberry Pi OS systems because the boot partition location changed from `/boot` to `/boot/firmware`. This results in cloned SD cards that won't boot. This fork fixes that critical issue and maintains compatibility with both old and new systems.

---

Version 2 is a complete rewrite with improved capability over
the original. See the examples below.
Expand Down Expand Up @@ -45,7 +58,7 @@ only Debian packages with apt-get.

#### On a Raspberry Pi:
```
$ git clone https://github.com/billw2/rpi-clone.git
$ git clone https://github.com/KenAdamson/rpi-clone.git
$ cd rpi-clone
$ sudo cp rpi-clone rpi-clone-setup /usr/local/sbin
```
Expand All @@ -66,7 +79,7 @@ add them to the rpi-clone-setup script.
To install on another OS, rpi-clone may be renamed to suit. For example,
on my Debian desktop I rename:
```
$ git clone https://github.com/billw2/rpi-clone.git
$ git clone https://github.com/KenAdamson/rpi-clone.git
$ cd rpi-clone
$ sudo cp rpi-clone /usr/local/sbin/sys-clone
$ sudo cp rpi-clone-setup /usr/local/sbin/sys-clone-setup
Expand Down
51 changes: 42 additions & 9 deletions rpi-clone
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# https://github.com/billw2/rpi-clone


version=2.0.22
version=2.0.23

# setup trusted paths for dependancies (like rsync, grub, fdisk, etc)
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Expand Down Expand Up @@ -586,7 +586,13 @@ get_src_disk()

# ==== source (booted) disk info and default mount list
#
src_boot_dev=`findmnt /boot -o source -n | grep "/dev/"`
# Check for boot partition at /boot/firmware (modern Raspberry Pi OS) first,
# then fall back to /boot (legacy location) for backward compatibility
src_boot_dev=`findmnt /boot/firmware -o source -n 2>/dev/null | grep "/dev/"`
if [ "$src_boot_dev" == "" ]
then
src_boot_dev=`findmnt /boot -o source -n 2>/dev/null | grep "/dev/"`
fi
src_root_dev=`findmnt / -o source -n | grep "/dev/"`
SD_slot_boot=0
SD_slot_dst=0
Expand Down Expand Up @@ -971,7 +977,13 @@ then
cp $fstab_tmp $fstab
printf "Your original fstab is backed up to $fstab_save\n"

cmdline_txt=/boot/cmdline.txt
# Check for cmdline.txt in both locations
if [ -f /boot/firmware/cmdline.txt ]
then
cmdline_txt=/boot/firmware/cmdline.txt
else
cmdline_txt=/boot/cmdline.txt
fi
cmdline_save=$cmdline_txt.${PGM}-save
if [ -f $cmdline_txt ] && grep -q "$src_root_dev" $cmdline_txt
then
Expand Down Expand Up @@ -1503,7 +1515,8 @@ Use -U for unattended even if initializing.
mkfs_type=$fs_type
fi

if [ "${src_mounted_dir[p]}" == "/boot" ] && ((p == 1))
# Check for both /boot and /boot/firmware mount points for compatibility
if ([ "${src_mounted_dir[p]}" == "/boot" ] || [ "${src_mounted_dir[p]}" == "/boot/firmware" ]) && ((p == 1))
then
ext_label $p "$fs_type" "-L" label
printf " => mkfs -t $mkfs_type $label $dst_dev ..."
Expand Down Expand Up @@ -1730,15 +1743,28 @@ qecho ""
# Fix PARTUUID or device name references in cmdline.txt and fstab
#
fstab=${clone}/etc/fstab
cmdline_txt=${clone}/boot/cmdline.txt
# Check for cmdline.txt in both /boot/firmware (modern) and /boot (legacy)
if [ -f ${clone}/boot/firmware/cmdline.txt ]
then
cmdline_txt=${clone}/boot/firmware/cmdline.txt
else
cmdline_txt=${clone}/boot/cmdline.txt
fi

if [ -f $cmdline_txt ]
then
if ((leave_sd_usb_boot && SD_slot_dst))
then
qecho "Leaving SD to USB boot alone."
cp $cmdline_txt ${clone}/boot/cmdline.boot
cmdline_txt=${clone}/boot/cmdline.boot
# Use the same directory structure as the source for cmdline.boot
if [ -f ${clone}/boot/firmware/cmdline.txt ]
then
cp $cmdline_txt ${clone}/boot/firmware/cmdline.boot
cmdline_txt=${clone}/boot/firmware/cmdline.boot
else
cp $cmdline_txt ${clone}/boot/cmdline.boot
cmdline_txt=${clone}/boot/cmdline.boot
fi
fi
if grep -q $src_disk_ID $cmdline_txt
then
Expand All @@ -1752,8 +1778,15 @@ then
if ((leave_sd_usb_boot && SD_slot_boot))
then
qecho "Copying USB cmdline.txt to SD card to set up USB boot."
cp /boot/cmdline.txt /boot/cmdline.boot
cp $cmdline_txt /boot/cmdline.txt
# Determine the boot directory path
if [ -f /boot/firmware/cmdline.txt ]
then
boot_dir="/boot/firmware"
else
boot_dir="/boot"
fi
cp ${boot_dir}/cmdline.txt ${boot_dir}/cmdline.boot
cp $cmdline_txt ${boot_dir}/cmdline.txt
fi
fi

Expand Down