rpi-clone
rpi-clone copied to clipboard
official rpios bookworm issue
The official rpios bookworm release has changed the mount point /boot to /boot/firmware. The current rpi-clone can back up, but the backup media is not bootable because the cmdline.txt file is not updated with the new PARTUUID.
/boot/cmdline.txt -> /boot/firmware/cmdline.txt
Consider adding lines like this after these variable assignments "cmdline_txt=${clone}/boot/cmdline.txt"
if [ -h $cmdline_txt ] ; then cmdline_txt=${clone}/boot/firmware/cmdline.txt fi
This tests if the /boot/cmdline.txt is a link and changes it to the actual file.
Since I've updated to bookworm as well, looking at potential necessary fixes. I am looking at where to put this test. Would this be right after line 1733?
Looking at my pi that I updated to bookworm by changing the source.list and apt update / apt upgrade, I found no folder /boot/firmware, my cmdline.txt is in (old) location /boot
Did you do a fresh install?
I did a fresh install of bookworm 64bit. It seems likely that you will not be affected by the backup media boot issue, but I would test booting a backup to be sure. I would add the new lines after each occurance of this line: cmdline_txt=${clone}/boot/cmdline.boot
Lines 1733 1741
With these changes in place, backups of older versions of rpios will not be affected.
Some attention should be given to the area around ((convert_to_partuuid)). I have not tested this but the same three lines could be added after 974. cmdline_txt=/boot/cmdline.txt
Thanks, I'll look into this in my setup. For now it does not seem to be needed in my install. But it may be worthwhile for a future fresh install... A pity that rpi-clone does not seem to be maintained for quite some time anymore, and we have to rely on individual changes and updates such as the one pointed out by you.
I'll create a fix in my fork when I'm back home next week.
Rebuilt a Raspberry 4-System from scratch yesterday. After work I was surprised to find out that the backups I used to do with rpi-clone would not boot.
So I found your issues-discussion here and changed rpi-clone by only adding:
if [ -h $cmdline_txt ] ; then cmdline_txt=${clone}/boot/firmware/cmdline.txt fi
after line 1733.
To use it again in line 1741 will probably not work because you just changed cmdline_txt to point to a file (rather than a link) after line 1733 and check again whether it points to a link (which will always fail?). Line 1741 deals with cmdline.boot and not cmdline.txt? And from my poor understanding of what the code is doing here I think further changes are not needed here. Don't know about other parts of the code where /boot/cmdline.txt is used.
Bottom line: I cloned with just three lines added, it booted fine.
Hope that helps.
~I just created a fix in my fork so rpi-clone creates a bootable clone for bookworm. I tested the fix with a lite 32 bit image only. Would be great if if somebody tests the fix for other images and reports any issues.~
EDIT: @zwolfpack s fix below is much better than mine. But realpath is not required for fstab. I created a PR and added the fix in my fork.
The changes around line 1733 are sufficient to make a normal backup bootable. One of the other two changes are in an area to change fstab and cmdline.txt from device names to PARTUUID: line 974. The other change seems to be when someone has a boot (or now firmware) partition on the SD card while the root partition is on a USB drive.: line 1741.
The issue arises when cmdline.txt is edited via 'sed -i'. That command ends up replacing the symlink /boot/cmdline.txt with the edited content, but the link target in /boot/firmware/cmdline.txt, which is the place that needs changing, isn't changed.
To fix, realpath(1) can be used to resolve the filename to the actual target. Following patch applies this for all instances where 'sed -i' is used.
--- rpi-clone/rpi-clone 2023-10-22 20:01:42.068868892 -0700
+++ rpi-clone-bookworm/rpi-clone 2023-10-22 13:37:47.691962245 -0700
@@ -971,7 +971,7 @@
cp $fstab_tmp $fstab
printf "Your original fstab is backed up to $fstab_save\n"
- cmdline_txt=/boot/cmdline.txt
+ cmdline_txt=`realpath /boot/cmdline.txt`
cmdline_save=$cmdline_txt.${PGM}-save
if [ -f $cmdline_txt ] && grep -q "$src_root_dev" $cmdline_txt
then
@@ -1729,8 +1729,8 @@
# Fix PARTUUID or device name references in cmdline.txt and fstab
#
-fstab=${clone}/etc/fstab
-cmdline_txt=${clone}/boot/cmdline.txt
+fstab=`realpath ${clone}/etc/fstab`
+cmdline_txt=`realpath ${clone}/boot/cmdline.txt`
if [ -f $cmdline_txt ]
then
@@ -1738,7 +1738,7 @@
then
qecho "Leaving SD to USB boot alone."
cp $cmdline_txt ${clone}/boot/cmdline.boot
- cmdline_txt=${clone}/boot/cmdline.boot
+ cmdline_txt=`dirname $cmdline_txt`/cmdline.boot
fi
if grep -q $src_disk_ID $cmdline_txt
then
I realize that realpath is not required for fstab ... currently. However, a similar problem would arise if /etc/fstab was symlinked. So I though it prudent to fix that as well.
However, a similar problem would arise if /etc/fstab was symlinked.
I see your point. But I don't expect /etc/fstab to become symlinked. It's a file as long as Linux exists. That's why I decided to remove realpath for /etc/fstab in my PR.
I fixed this by adding --follow-symlinks to the sed command
~I just created a fix in my fork so rpi-clone creates a bootable clone for bookworm. I tested the fix with a lite 32 bit image only. Would be great if if somebody tests the fix for other images and reports any issues.~
EDIT: @zwolfpack s fix below is much better than mine. But realpath is not required for fstab. I created a PR and added the fix in my fork.
FWIW it doesn't look like the fork works either with official clean install Bookworm on the Pi 3B+. I tried it just now and the Pi wouldn't get past power on.
:cry: Unfortunately rpi-clone misses an important feature to help if there are any issues - a debug log :cry:
Would be great to have a debug log of your restore in order to help you. Maybe somebody adds the missing debug feature in rpi-clone :wink:
😢 Unfortunately rpi-clone misses an important feature to help if there are any issues - a debug log 😢
Would be great to have a debug log of your restore in order to help you. Maybe somebody adds the missing debug feature in rpi-clone 😉
No worries. I have an Pi 4B on hand so I'm using the SD card copier utility instead. Still not as handy for backups, but it'll work well enough to migrate from one microSD card to another. Here's hoping that doesn't fail.
I use raspiBackup to backup my Raspberries. Just give it a try :wink:
I'll look into that, thanks!
raspiBackup has a debug log :smile: - just in case you have any issues
Hi, I tried everything in this post but my cloned card doesn't boot. I run rpi-clone on a pi4 (waiting for pi5 arrival) with Pi OS "bookworm" 64 bit. Nothing to do, I have to give-up. The clone with GUI official script works, as usual.
Syncing file systems (can take a long time)
Syncing mounted partitions:
Mounting /dev/sda2 on /mnt/clone
=> rsync // /mnt/clone with-root-excludes ...
Mounting /dev/sda1 on /mnt/clone/boot/firmware
=> rsync /boot/firmware/ /mnt/clone/boot/firmware ...
Editing /mnt/clone/boot/cmdline.txt PARTUUID to use 59dc1bbf
Editing /mnt/clone/etc/fstab PARTUUID to use 59dc1bbf
as others pointed out it did do the correct edit but just didn't store it at the right target folder. It stored it in /mnt/clone/boot/cmdline.txt instead of /mnt/clone/boot/firmware/cmdline.txt . I was able to manually put in the USB drive and set the right partition value in the firmware folder and it works.
@framps thanks, your version works without issue!
In verband met de feestdagen ben ik tot en met vrijdag 29 december 2023 afwezig en zal mijn email beperkt kunnen lezen en beantwoorden.
Ik wens u het allerbeste voor 2024 en fijne feestdagen!
Met vriendelijke groet, FSE Turnstiles b.v. Jos de Vries
PS: Neem voor urgente storingen contact met ons op door een email te sturen naar @.***
@framps thanks, your version works without issue!
On which Raspberry Pi OS version?
@framps thanks, your version works without issue!
On which Raspberry Pi OS version?
Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 with Kernel: pi5 6.1.0-rpi7-rpi-2712
which is the final patch to apply to rpi-clone on a Rasp 3B+ (32bit) bookworm? I am getting confused...
- Fix the current code according https://github.com/billw2/rpi-clone/issues/168#issuecomment-1784275165
- Apply the patch listed in https://github.com/billw2/rpi-clone/issues/168#issuecomment-1774370841 or use rpi-clone from my fork
I have used @framps fork on my bookworm, and this is the results I am getting on boot partition:
ll /media/BOOT/
ls: cannot access '/media/BOOT/'$'\001''░m░╝╕'$'\035''≡.\≡ ': Input/output error
ls: cannot access '/media/BOOT/T± s4≡G:.ä± ': Input/output error
ls: cannot access '/media/BOOT/'$'\001''αy░▄Φ'$'\035''≡.|± ': Input/output error
ls: cannot access '/media/BOOT/╨± r.'$'\001''░m': Input/output error
ls: cannot access '/media/BOOT/▓"'$'\003''∩'$'\002''>'$'\002''.üá'$'\003': Input/output error
total 17124409
-rwxr-xr-x 1 pab pab 218099713 Jan 4 1980 ''$'\001''.░'
drwxr-xr-x 8 pab pab 4608 Jan 1 1970 .
drwxr-xr-x 5 root root 4096 Dec 27 12:58 ..
-rwxr-xr-x 1 pab pab 29243 Dec 23 10:54 bcm2708-rpi-b.dtb
-rwxr-xr-x 1 pab pab 29562 Dec 23 10:54 bcm2708-rpi-b-plus.dtb
-rwxr-xr-x 1 pab pab 28986 Dec 23 10:54 bcm2708-rpi-cm.dtb
-rwxr-xr-x 1 pab pab 28868 Dec 23 10:54 bcm2708-rpi-zero.dtb
-rwxr-xr-x 1 pab pab 30739 Dec 23 10:54 bcm2708-rpi-zero-w.dtb
-rwxr-xr-x 1 pab pab 31210 Dec 23 10:54 bcm2709-rpi-2-b.dtb
-rwxr-xr-x 1 pab pab 31359 Dec 23 10:54 bcm2710-rpi-2-b.dtb
-rwxr-xr-x 1 pab pab 33555 Dec 23 10:54 bcm2710-rpi-3-b.dtb
-rwxr-xr-x 1 pab pab 31254 Dec 23 10:54 bcm2710-rpi-cm3.dtb
-rwxr-xr-x 1 pab pab 32524 Dec 23 10:54 bcm2710-rpi-zero-2-w.dtb
-rwxr-xr-x 1 pab pab 54707 Dec 23 10:54 bcm2711-rpi-4-b.dtb
-rwxr-xr-x 1 pab pab 52476 Dec 23 10:49 bootcode.bin
-rwxr-xr-x 1 pab pab 52476 Dec 23 10:49 bootcode.bin
-rwxr-xr-x 1 pab pab 1611801893 Jan 5 2010 '°='$'\002''.'$'\a''Ç'$'\005'
-rwxr-xr-x 1 pab pab 4096 Feb 12 2019 ._cmdline.txt
-rwxr-xr-x 1 pab pab 142 Nov 19 2019 cmdline.txt
-rwxr-xr-x 1 pab pab 4096 Feb 12 2019 ._config.txt
-rwxr-xr-x 1 pab pab 1756 Dec 23 10:56 config.txt
-rwxr-xr-x 1 pab pab 1739 Jul 10 10:56 config.txt.bak
-r-xr-xr-x 1 pab pab 4294961157 Aug 1 1980 ''$'\001''░d.'$'\002''└#'
-rwxr-xr-x 1 pab pab 520388128 Jan 4 2096 'e.'$'\004''└ '
-rwxr-xr-x 1 pab pab 3180 Dec 23 10:49 fixup4cd.dat
-rwxr-xr-x 1 pab pab 3180 Dec 23 10:49 fixup4cd.dat
-rwxr-xr-x 1 pab pab 5412 Dec 23 10:49 fixup4.dat
-rwxr-xr-x 1 pab pab 5412 Dec 23 10:49 fixup4.dat
-rwxr-xr-x 1 pab pab 8397 Dec 23 10:49 fixup4db.dat
-rwxr-xr-x 1 pab pab 8397 Dec 23 10:49 fixup4db.dat
-rwxr-xr-x 1 pab pab 8399 Dec 23 10:49 fixup4x.dat
-rwxr-xr-x 1 pab pab 8399 Dec 23 10:49 fixup4x.dat
-rwxr-xr-x 1 pab pab 3180 Dec 23 10:49 fixup_cd.dat
-rwxr-xr-x 1 pab pab 7269 Dec 23 10:49 fixup.dat
-rwxr-xr-x 1 pab pab 7269 Dec 23 10:49 fixup.dat
-rwxr-xr-x 1 pab pab 10242 Dec 23 10:49 fixup_db.dat
-rwxr-xr-x 1 pab pab 10244 Dec 23 10:49 fixup_x.dat
-rwxr-xr-x 1 pab pab 11317382 Feb 8 2076 ''$'\031''@*@'$'\a''`.'$'\006''î'$'\004'
-rwxr-xr-x 1 pab pab 145 Nov 13 2018 issue.txt
-rwxr-xr-x 1 pab pab 1594 Dec 23 10:49 LICENCE.broadcom
-rwxr-xr-x 1 pab pab 1594 Dec 23 10:49 LICENCE.broadcom
-rwxr-xr-x 1 pab pab 18974 Nov 13 2018 LICENSE.oracle
d????????? ? ? ? ? ? ''$'\001''░m░╝╕'$'\035''≡.\≡ '
d????????? ? ? ? ? ? '╨± r.'$'\001''░m'
drwxr-xr-x 4 pab pab 512 Sep 21 2019 .Spotlight-V100
-rwxr-xr-x 1 pab pab 808060 Dec 23 10:49 start4cd.elf
-rwxr-xr-x 1 pab pab 3751752 Dec 23 10:49 start4db.elf
-rwxr-xr-x 1 pab pab 2254944 Dec 23 10:49 start4.elf
-rwxr-xr-x 1 pab pab 3002536 Dec 23 10:49 start4x.elf
-rwxr-xr-x 1 pab pab 808060 Dec 23 10:49 start_cd.elf
-rwxr-xr-x 1 pab pab 4823624 Dec 23 10:49 start_db.elf
-rwxr-xr-x 1 pab pab 2979264 Dec 23 10:49 start.elf
-rwxr-xr-x 1 pab pab 3726216 Dec 23 10:49 start_x.elf
d????????? ? ? ? ? ? T± s4≡G:.ä±
-rwxr-xr-x 1 pab pab 3221651719 Mar 16 2043 ''$'\002''.'$'\a''ü'$'\006'
d????????? ? ? ? ? ? '▓"'$'\003''∩'$'\002''>'$'\002''.üá'$'\003'
-rwxr-xr-x 1 pab pab 164 Mar 17 2019 wpa_supplicant.conf_Salty
d????????? ? ? ? ? ? ''$'\001''αy░▄Φ'$'\035''≡.|± '
-rwxr-xr-x 1 pab pab 172 Jan 1 2067 'σ▒≥'$'\016''╚.'$'\004'
-rwxr-xr-x 1 pab pab 3892428806 Feb 1 2043 ''$'\003''Φ8.'$'\a''ü'$'\006'
-rwxr-xr-x 1 pab pab 520388128 Jan 4 2096 ''$'\004''Φ'$'\b''É ~'$'\004\037''.'$'\004''φ'$'\b'
-rwxr-xr-x 1 pab pab 3221586184 Mar 16 2043 ''$'\004\037\003''Φ '$'\177''.'$'\b''ü'$'\006'
pab@pab:~ $
Looks like your SD card is broken.
Looks like your SD card is broken.
It seems very unlikely, as it worked every day before the upgrade... I will check and maybe reformat it.
during rsync I am getting these errors:
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.bcm2712-rpi-5-b.dtb.SlzdW6" failed: Read-only file system (30)
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.cmdline.txt.g9a4Sq" failed: Read-only file system (30)
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.config.txt.QA8F5F" failed: Read-only file system (30)
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.config.txt.bak.fK9cPg" failed: Read-only file system (30)
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.fixup_cd.dat.DoHYL7" failed: Read-only file system (30)
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.fixup_db.dat.IfOnvM" failed: Read-only file system (30)
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.initramfs7.btIE0Q" failed: Read-only file system (30)
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.issue.txt.Q6vgxm" failed: Read-only file system (30)
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.kernel7.img.hWtAb9" failed: Read-only file system (30)
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.start.elf.i72DIe" failed: Read-only file system (30)
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.start_cd.elf.nY5NIh" failed: Read-only file system (30)
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.start_db.elf.WnMyIt" failed: Read-only file system (30)
rsync: [receiver] mkstemp "/mnt/clone/boot/firmware/.start_x.elf.WR0DqO" failed: Read-only file system (30)
Your SD card is broken. I suggest to use a brand new SD card.