SD Mirroring - FAILED (e2fsck) invalid option -- 'U'

  • Platform information:
    • Hardware: Raspberry Pi 4B 4GB
    • OS: Raspbian GNU/Linux 10 (buster), Linux 5.10.103-v7l+, arm
    • Java Runtime Environment: OpenJDK Runtime Environment Zulu11.50+19-CA (build 11.0.12+7-LTS)
    • openHAB version: openHAB 3.4.2 - Release Build
  • Issue of the topic: Unable to Sync or Setup SD Mirroring

I am setting up the SD Backup via the config tool #53.
Unfortunately, I get this error:

e2fsck -y /dev/sda2 -U random
e2fsck: invalid option – ‘U’
FAILED (e2fsck)

+ select_blkdev '^sd' 'Setup SD mirroring' 'Select USB device to copy the internal SD card data to'
+ [[ -z 1 ]]
+ array=()
+ declare -a array
+ read -r id foo foo size foo foo foo
++ lsblk -i
++ tr -d '`\\|'
++ grep -E '^sd'
++ tr -d '\\-'
+ array+=("$id" "$size")
+ read -r id foo foo size foo foo foo
+ [[ 2 -eq 0 ]]
+ (( count=2 + 8 ))
++ whiptail --title 'Setup SD mirroring' --cancel-button Cancel --ok-button Select --menu '\nSelect USB device to copy the internal SD card data to' 10 76 0 sda 59.5G
+ retval=sda
+ [[ -z sda ]]
+ dest=/dev/sda
++ blockdev --getsize64 /dev/sda
+ [[ -n 63864569856 ]]
+ mount
+ grep -Eq '$dest[12]'
+ infoText='DANGEROUS OPERATION, USE WITH PRECAUTION!\n\nThis will *copy* your system root from your SD card to a USB attached card writer device. Are you sure /dev/sda is an SD card writer device equipped with a dispensible SD card? Are you sure, this will destroy all data on that card and you want to proceed writing to this device?'
++ blockdev --getsize64 /dev/mmcblk0
+ srcSize=31046238208
+ minStorageSize=35046238208
++ blockdev --getsize64 /dev/sda
+ destSize=63864569856
+ [[ 63864569856 -lt 31046238208 ]]
+ [[ -n 1 ]]
+ whiptail --title 'Copy internal SD to /dev/sda' --yes-button Continue --no-button Back --yesno 'DANGEROUS OPERATION, USE WITH PRECAUTION!\n\nThis will *copy* your system root from your SD card to a USB attached card writer device. Are you sure /dev/sda is an SD card writer device equipped with a dispensible SD card? Are you sure, this will destroy all data on that card and you want to proceed writing to this device?' 12 116
++ basename /storage
+ mountUnit=storage.mount
+ systemctl stop storage.mount
+ sfdisk -d /dev/mmcblk0
+ grep -q '^/dev/mmcblk0p3'
+ [[ 63864569856 -ge 35046238208 ]]
++ fdisk -l /dev/mmcblk0
++ head -1
++ cut '-d ' -f5
+ start=31046238208
+ (( destSize-=start ))
+ (( start/=512 ))
+ destSizeSector=32818331648
+ (( destSizeSector/=512 ))
+ sfdisk -d /dev/mmcblk0
+ sfdisk --force /dev/sda
+ echo '/dev/mmcblk0p3 : start=60637184,size=64098304, type=83'
Checking that no-one is using this disk right now ... OK

Disk /dev/sda: 59.5 GiB, 63864569856 bytes, 124735488 sectors
Disk model: SDDR-B531
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf98e7c52

Old situation:

Device     Boot    Start       End  Sectors  Size Id Type
/dev/sda1           8192    532479   524288  256M  c W95 FAT32 (LBA)
/dev/sda2         532480  60637183 60104704 28.7G 83 Linux
/dev/sda3       60637184 124735487 64098304 30.6G 83 Linux

>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0x36d2ff49.
/dev/sda1: Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 256 MiB.
Partition #1 contains a vfat signature.
/dev/sda2: Created a new partition 2 of type 'Linux' and of size 28.7 GiB.
Partition #2 contains a ext4 signature.
/dev/sda3: Created a new partition 3 of type 'Linux' and of size 30.6 GiB.
Partition #3 contains a ext4 signature.
/dev/sda4: Done.

New situation:
Disklabel type: dos
Disk identifier: 0x36d2ff49

Device     Boot    Start       End  Sectors  Size Id Type
/dev/sda1           8192    532479   524288  256M  c W95 FAT32 (LBA)
/dev/sda2         532480  60637183 60104704 28.7G 83 Linux
/dev/sda3       60637184 124735487 64098304 30.6G 83 Linux

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
+ partprobe
+ cond_redirect mke2fs -F -t ext4 /dev/sda3
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ mke2fs -F -t ext4 /dev/sda3 \033[39;49;00m'

$ mke2fs -F -t ext4 /dev/sda3
+ mke2fs -F -t ext4 /dev/sda3
mke2fs 1.44.5 (15-Dec-2018)
/dev/sda3 contains a ext4 file system
        last mounted on Sat Apr  8 18:42:12 2023
Creating filesystem with 8012288 4k blocks and 2003120 inodes
Filesystem UUID: 5f3823a6-78a9-4154-b135-c4c7ca82ab7c
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

+ return 0
+ sed -e 's|%DEVICE|/dev/sda3|g' -e 's|%STORAGE|/storage|g' /opt/openhabian/includes/SD/storage.mount-template
+ cond_redirect chmod 644 /etc/systemd/system/storage.mount
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ chmod 644 /etc/systemd/system/storage.mount \033[39;49;00m'

$ chmod 644 /etc/systemd/system/storage.mount
+ chmod 644 /etc/systemd/system/storage.mount
+ return 0
+ cond_redirect systemctl -q daemon-reload
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ systemctl -q daemon-reload \033[39;49;00m'

$ systemctl -q daemon-reload
+ systemctl -q daemon-reload
+ return 0
+ cond_redirect systemctl enable --now storage.mount
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ systemctl enable --now storage.mount \033[39;49;00m'

$ systemctl enable --now storage.mount
+ systemctl enable --now storage.mount
+ return 0
+ mirror_SD raw /dev/sda
+ local src=/dev/mmcblk0
+ local dest=/dev/sda
+ local start
+ local destPartsLargeEnough=true
+ local storageDir=/storage
+ local syncMount=/storage/syncmount
+ local dirty=no
+ local repartitionText
+ local 'dumpInfoText=For your information as the operator of this openHABian system:\nA timed background job to run semiannually has just created a full raw device copy of your RPI'\''s internal SD card.\nOnly partitions to contain openHABian (/boot and / partitions 1 & 2) were copied.'
+ local partUUID
+ [[ 2 -eq 1 ]]
+ [[ /dev/mmcblk0 == \/\d\e\v\/\s\d\a ]]
++ blockdev --getsize64 /dev/sda
+ [[ -n 63864569856 ]]
+ mount
+ grep -Eq '$dest[12]'
+ [[ -d /storage/syncmount ]]
+ mkdir -p /storage/syncmount
+ [[ raw == \r\a\w ]]
+ for i in 1 2 3
+ sfdisk -d /dev/mmcblk0
+ grep -q '^/dev/mmcblk0p1'
++ blockdev --getsize64 /dev/mmcblk0p1
+ srcSize=268435456
++ blockdev --getsize64 /dev/sda1
+ destSize=268435456
+ [[ 268435456 -lt 268435456 ]]
+ for i in 1 2 3
+ sfdisk -d /dev/mmcblk0
+ grep -q '^/dev/mmcblk0p2'
++ blockdev --getsize64 /dev/mmcblk0p2
+ srcSize=30773608448
++ blockdev --getsize64 /dev/sda2
+ destSize=30773608448
+ [[ 30773608448 -lt 30773608448 ]]
+ for i in 1 2 3
+ sfdisk -d /dev/mmcblk0
+ grep -q '^/dev/mmcblk0p3'
+ continue
+ [[ true == \t\r\u\e ]]
+ echo 'Taking a raw partition copy, be prepared this may take long such as 20-30 minutes for a 16 GB SD card'
Taking a raw partition copy, be prepared this may take long such as 20-30 minutes for a 16 GB SD card
+ cond_redirect dd if=/dev/mmcblk0p1 bs=1M of=/dev/sda1 status=progress
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ dd if=/dev/mmcblk0p1 bs=1M of=/dev/sda1 status=progress \033[39;49;00m'

$ dd if=/dev/mmcblk0p1 bs=1M of=/dev/sda1 status=progress
+ dd if=/dev/mmcblk0p1 bs=1M of=/dev/sda1 status=progress
253755392 bytes (254 MB, 242 MiB) copied, 9 s, 28.2 MB/s
256+0 records in
256+0 records out
268435456 bytes (268 MB, 256 MiB) copied, 13.0826 s, 20.5 MB/s
+ return 0
+ cond_redirect dd if=/dev/mmcblk0p2 bs=1M of=/dev/sda2 status=progress
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ dd if=/dev/mmcblk0p2 bs=1M of=/dev/sda2 status=progress \033[39;49;00m'

$ dd if=/dev/mmcblk0p2 bs=1M of=/dev/sda2 status=progress
+ dd if=/dev/mmcblk0p2 bs=1M of=/dev/sda2 status=progress
30768365568 bytes (31 GB, 29 GiB) copied, 1154 s, 26.7 MB/s
29348+0 records in
29348+0 records out
30773608448 bytes (31 GB, 29 GiB) copied, 1159.71 s, 26.5 MB/s
+ return 0
+ sfdisk -d /dev/mmcblk0
+ grep -q '^/dev/mmcblk0p3'
++ blkid /dev/mmcblk0p2
++ sed -n 's|^.*PARTUUID="\(\S\+\)".*|\1|p'
++ sed -e s/-02//g
+ origPartUUID=36d2ff49
++ yes
++ set-partuuid /dev/sda2 random
++ awk '/^PARTUUID/ { print substr($7,1,length($7) - 3) }'
+ partUUID=ae8a6b69
+ cond_redirect e2fsck -y /dev/sda2 -U random
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ e2fsck -y /dev/sda2 -U random \033[39;49;00m'

$ e2fsck -y /dev/sda2 -U random
+ e2fsck -y /dev/sda2 -U random
e2fsck: invalid option -- 'U'
Usage: e2fsck [-panyrcdfktvDFV] [-b superblock] [-B blocksize]
                [-l|-L bad_blocks_file] [-C fd] [-j external_journal]
                [-E extended-options] [-z undo_file] device

Emergency help:
 -p                   Automatic repair (no questions)
 -n                   Make no changes to the filesystem
 -y                   Assume "yes" to all questions
 -c                   Check for bad blocks and add them to the badblock list
 -f                   Force checking even if filesystem is marked clean
 -v                   Be verbose
 -b superblock        Use alternative superblock
 -B blocksize         Force blocksize when looking for superblock
 -j external_journal  Set location of the external journal
 -l bad_blocks_file   Add to badblocks list
 -L bad_blocks_file   Set badblocks list
 -z undo_file         Create an undo file
+ return 16
+ echo 'FAILED (e2fsck)'
FAILED (e2fsck)
+ dirty=yes
+ cond_redirect tune2fs /dev/sda2 -U random
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ tune2fs /dev/sda2 -U random \033[39;49;00m'

$ tune2fs /dev/sda2 -U random
+ tune2fs /dev/sda2 -U random
tune2fs 1.44.5 (15-Dec-2018)
+ return 0
+ umount -q /dev/sda1
+ mount /dev/sda1 /storage/syncmount
+ sed -i 's|36d2ff49|ae8a6b69|g' /storage/syncmount/cmdline.txt
+ umount /storage/syncmount
+ umount -q /dev/sda2
+ mount /dev/sda2 /storage/syncmount
+ sed -i 's|36d2ff49|ae8a6b69|g' /storage/syncmount/etc/fstab
+ [[ -f /storage/syncmount/etc/systemd/system//storage.mount ]]
+ sed -i 's|^What=.*|What=/dev/mmcblk0p3|g' /storage/syncmount/etc/systemd/system//storage.mount
+ umount /storage/syncmount
+ cond_redirect fsck -y -t ext4 /dev/sda2
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ fsck -y -t ext4 /dev/sda2 \033[39;49;00m'

$ fsck -y -t ext4 /dev/sda2
+ fsck -y -t ext4 /dev/sda2
fsck from util-linux 2.33.1
e2fsck 1.44.5 (15-Dec-2018)
rootfs: clean, 144736/1862080 files, 3416076/7513088 blocks
+ return 0
+ [[ yes == \n\o ]]
+ [[ -n '' ]]
+ return 0
+ sed -e 's|%DEST|/dev/sda|g' /opt/openhabian/includes/SD/sdrawcopy.service-template
+ sed -e 's|%DEST|/dev/sda|g' /opt/openhabian/includes/SD/sdrsync.service-template
+ cond_redirect install -m 644 -t /etc/systemd/system /opt/openhabian/includes/SD/sdrawcopy.timer /opt/openhabian/includes/SD/sdrsync.timer
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ install -m 644 -t /etc/systemd/system /opt/openhabian/includes/SD/sdrawcopy.timer /opt/openhabian/includes/SD/sdrsync.timer \033[39;49;00m'

$ install -m 644 -t /etc/systemd/system /opt/openhabian/includes/SD/sdrawcopy.timer /opt/openhabian/includes/SD/sdrsync.timer
+ install -m 644 -t /etc/systemd/system /opt/openhabian/includes/SD/sdrawcopy.timer /opt/openhabian/includes/SD/sdrsync.timer
+ return 0
+ cond_redirect install -m 755 /opt/openhabian/includes/SD/mirror_SD /usr/local/sbin
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ install -m 755 /opt/openhabian/includes/SD/mirror_SD /usr/local/sbin \033[39;49;00m'

$ install -m 755 /opt/openhabian/includes/SD/mirror_SD /usr/local/sbin
+ install -m 755 /opt/openhabian/includes/SD/mirror_SD /usr/local/sbin
+ return 0
+ cond_redirect systemctl -q daemon-reload
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ systemctl -q daemon-reload \033[39;49;00m'

$ systemctl -q daemon-reload
+ systemctl -q daemon-reload
+ return 0
+ cond_redirect systemctl enable --now sdrawcopy.timer sdrsync.timer
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ systemctl enable --now sdrawcopy.timer sdrsync.timer \033[39;49;00m'

$ systemctl enable --now sdrawcopy.timer sdrsync.timer
+ systemctl enable --now sdrawcopy.timer sdrsync.timer
+ return 0
+ echo OK

Any idea how to fix this?
Thanks,
Pedro