Can’t setup SD Backup

  • Platform information:
    • Raspberry Pi 4B 4GB
    • OH 3.1

Hi all,
I am trying to set up the SD Backup via the config tool #53.
Unfortunately i get this error:

2021-09-14_18:12:48_CEST [openHABian] Setting up automated SD mirroring and backup... OK
Checking that no-one is using this disk right now ... OK

Disk /dev/sda: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Disk model: STORAGE DEVICE  
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: 0x6161c94d

Old situation:

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sda1         8192   532479   524288  256M  c W95 FAT32 (LBA)
/dev/sda2       532480 31116287 30583808 14.6G 83 Linux

>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0x4334c763.
/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 14.6 GiB.
Partition #2 contains a ext4 signature.
/dev/sda3: Start sector 31116288 out of range.
Failed to add #3 partition: Numerical result out of range
Leaving.

It looks like creating a raw backup via #54 works.

Any idea how to fix this?

Thanks

Best regards Dirk

Set debugmode=maximum in openhabian.conf and redo.

How large are your SDs ? ("lsblk" in shell)

Output with debugmode mode set to maximum:

+ choice2='53 | Setup SD mirroring'
+ '[' 0 -eq 1 ']'
+ '[' 1 -eq 255 ']'
+ case "$choice2" in
+ setup_mirror_SD install
+ [[ -n '' ]]
+ local src=/dev/mmcblk0
+ local srcSize
+ local dest
+ local destSize
+ local 'infoText1=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'
+ local 'infoText2=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?'
+ local minStorageSize=4000000000
+ local sdIncludesDir=/opt/openhabian/includes/SD
+ local serviceTargetDir=/etc/systemd/system
+ local 'sizeError=your destination SD card device does not have enough space, it needs to have at least twice as much as the source'
+ local storageDir=/storage
++ timestamp
++ date +%F_%T_%Z
+ echo -n '2021-09-15_10:03:32_CEST [openHABian] Setting up automated SD mirroring and backup... '
2021-09-15_10:03:32_CEST [openHABian] Setting up automated SD mirroring and backup... + [[ install == \r\e\m\o\v\e ]]
+ [[ install != \i\n\s\t\a\l\l ]]
+ is_pi
+ is_pifour
+ [[ '' == \p\i\4 ]]
+ grep -q '^Revision\s*:\s*[ 123][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]11[0-9a-fA-F]$' /proc/cpuinfo
+ return 0
+ return 0
+ mkdir -p /storage
+ cond_redirect apt-get install --yes gdisk
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ apt-get install --yes gdisk \033[39;49;00m'

$ apt-get install --yes gdisk 
+ apt-get install --yes gdisk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gdisk is already the newest version (1.0.3-1.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
+ return 0
+ echo OK
OK
+ cond_redirect install -m 755 /opt/openhabian/includes/SD/set-partuuid /usr/local/sbin
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ install -m 755 /opt/openhabian/includes/SD/set-partuuid /usr/local/sbin \033[39;49;00m'

$ install -m 755 /opt/openhabian/includes/SD/set-partuuid /usr/local/sbin 
+ install -m 755 /opt/openhabian/includes/SD/set-partuuid /usr/local/sbin
+ return 0
+ [[ -n 1 ]]
+ 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 14.9G
+ retval=sda
+ [[ -z sda ]]
+ dest=/dev/sda
++ blockdev --getsize64 /dev/sda
+ [[ -n 15931539456 ]]
+ 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=15931539456
+ minStorageSize=9965769728
++ blockdev --getsize64 /dev/sda
+ destSize=15931539456
+ [[ 15931539456 -lt 15931539456 ]]
+ [[ -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'
+ [[ 15931539456 -ge 9965769728 ]]
++ fdisk -l /dev/mmcblk0
++ head -1
++ cut '-d ' -f7
+ start=31116288
+ (( destSize-=start ))
+ sfdisk -d /dev/mmcblk0
+ sfdisk --force /dev/sda
+ echo '/dev/mmcblk0p3 : start=31116288,size=15900423168, type=83'
Checking that no-one is using this disk right now ... OK

Disk /dev/sda: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Disk model: STORAGE DEVICE  
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: 0x6161c94d

Old situation:

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sda1         8192   532479   524288  256M  c W95 FAT32 (LBA)
/dev/sda2       532480 31116287 30583808 14.6G 83 Linux

>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0x368b6a78.
/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 14.6 GiB.
Partition #2 contains a ext4 signature.
/dev/sda3: Start sector 31116288 out of range.
Failed to add #3 partition: Numerical result out of range
Leaving.

+ 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)
The file /dev/sda3 does not exist and no size was specified.
+ return 1
+ 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
+ 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
A dependency job for storage.mount failed. See 'journalctl -xe' for details.
+ return 1
+ echo 'FAILED (enable storage mount)'
FAILED (enable storage mount)
+ return 1
+ '[' 1 -ne 0 ']'
+ whiptail --msgbox 'There was an error or interruption during the execution of:\n  "50 | Backup/Restore"\n\nPlease try again. If the error persists, please read /opt/openhabian/docs/openhabian-DEBUG.md or https://github.com/openhab/openhabian/blob/main/docs/openhabian-DEBUG.md how to proceed.' 14 80
+ return 0

Output from lsblk:


openhabian@openhabian:~ $ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    1 14.9G  0 disk 
├─sda1        8:1    1  256M  0 part 
└─sda2        8:2    1 14.6G  0 part 
mmcblk0     179:0    0 14.9G  0 disk 
├─mmcblk0p1 179:1    0  256M  0 part /boot
└─mmcblk0p2 179:2    0 14.6G  0 part /
zram0       254:0    0  600M  0 disk [SWAP]
zram1       254:1    0  900M  0 disk /opt/zram/zram1
zram2       254:2    0  600M  0 disk /opt/zram/zram2

Must be the backup card the double size of the main card or must it only got the double free space of the used main card?
If it needs to be double the size maybe this is the problem, but why it doesn’t say that as an error?

Update openHABian (main branch) and try again.

This fixed it!


2021-09-15_11:08:42_CEST [openHABian] Checking for root privileges... OK
2021-09-15_11:08:43_CEST [openHABian] Loading configuration file '/etc/openhabian.conf'... OK
2021-09-15_11:08:43_CEST [openHABian] openHABian configuration tool version: [main]{2021-09-15T11:01:04+02:00}(3d7864f)
2021-09-15_11:08:43_CEST [openHABian] Checking for changes in origin branch main... OK
2021-09-15_11:08:43_CEST [openHABian] Switching to branch main... OK
2021-09-15_11:08:57_CEST [openHABian] Setting up automated SD mirroring and backup... OK
Taking a raw partition copy, be prepared this may take long such as 20-30 minutes for a 16 GB SD card
OK
OK
OK

Also the timers are now visible. Looks good now to me even there is for now a n/a


openhabian@openhabian:~ $ systemctl list-timers
NEXT                          LEFT                  LAST                          PASSED       UNIT                         ACTIVATES
Wed 2021-09-15 15:47:37 CEST  3h 54min left         Tue 2021-09-14 15:47:37 CEST  20h ago      systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Thu 2021-09-16 00:00:00 CEST  12h left              Wed 2021-09-15 00:00:54 CEST  11h ago      logrotate.timer              logrotate.service
Thu 2021-09-16 00:00:00 CEST  12h left              Wed 2021-09-15 00:00:54 CEST  11h ago      man-db.timer                 man-db.service
Thu 2021-09-16 02:02:43 CEST  14h left              n/a                           n/a          sdrsync.timer                sdrsync.service
Thu 2021-09-16 03:35:57 CEST  15h left              Wed 2021-09-15 00:11:32 CEST  11h ago      firemotd.timer               firemotd.service
Thu 2021-09-16 05:39:25 CEST  17h left              Wed 2021-09-15 10:00:07 CEST  1h 53min ago apt-daily.timer              apt-daily.service
Thu 2021-09-16 06:29:37 CEST  18h left              Wed 2021-09-15 06:59:54 CEST  4h 53min ago apt-daily-upgrade.timer      apt-daily-upgrade.service
Sat 2022-01-01 01:15:00 CET   3 months 16 days left n/a                           n/a          sdrawcopy.timer              sdrawcopy.service

Thank you!