Can’t setup SD mirroring

  • 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!

I’m having a similar problem, using the main branch: When I try to Setup SD Mirroring (option 53), I get the following (full debug) output:

+ 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'
+ [[ 64021856256 -ge 36010928128 ]]
++ fdisk -l /dev/mmcblk0
++ head -1
++ cut '-d ' -f7
+ start=62521344
+ (( destSize-=start ))
+ sfdisk -d /dev/mmcblk0
+ sfdisk --force /dev/sda
+ echo '/dev/mmcblk0p3 : start=62521344,size=63959334912, type=83'
Checking that no-one is using this disk right now ... OK

Disk /dev/sda: 59.63 GiB, 64021856256 bytes, 125042688 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: 0x00000000

Old situation:

Device     Boot Start       End   Sectors  Size Id Type
/dev/sda1       32768 125042687 125009920 59.6G  7 HPFS/NTFS/exFAT

>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0x91676c6f.
/dev/sda1: Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 256 MiB.
/dev/sda2: Created a new partition 2 of type 'Linux' and of size 29.6 GiB.
/dev/sda3: No free sectors available.
Failed to add #3 partition: No space left on device
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.46.2 (28-Feb-2021)
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
+ [[ -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
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
+ true

lsblk shows the following:

NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    1 59.6G  0 disk
└─sda1        8:1    1 59.6G  0 part
mmcblk0     179:0    0 29.8G  0 disk
├─mmcblk0p1 179:1    0  256M  0 part /boot
└─mmcblk0p2 179:2    0 29.6G  0 part /
zram0       254:0    0  450M  0 disk [SWAP]
zram1       254:1    0  350M  0 disk /opt/zram/zram1
zram2       254:2    0  450M  0 disk /opt/zram/zram2

If you want help you should be comprehensively specifiying your issue else I (and anybody else) is forced to guess.
Looks like your external SD card is smaller than the internal yet you’re trying to setup a 3rd partition for the (negative) amount of space left.

I appreciate the response. Sorry if I wasn’t more clear.

I’m booted from a 32gb SD card in the pi’s sd slot (‘mmcblk0’ in the lsblk above).

I’m trying to backup to a 64gb card in a usb card reader (sda1 in the lsblk above). When Setup SD mirroring asks me to Select USB device to copy the internal SD card data to, there’s only one option, sda 59.6G, which presumably is the 64gb SD in the USB reader.

When I attempt this, I get the Failed to add #3 partition: No space left on device error in the output. I turned on full debug logging and copied the output above.

This is a new openhabian setup on a new rpi4. I’m not explicitly trying to create a partition; AFAIK the Setup SD Mirroring utility is. The SD card does already have an OOB 59.5gb partition on it.

What am I missing to “comprehensively” specify my issue?

I don’t know why that happens.
Can you manually delete the partition on the 64G SD then retry ?

Tried that. Same result (error). There is no partition visible on the drive afterward.

I’ve tried everything I can think of; still no soap. The target SD is a brand new Samsung PRO Endurance 64GB (MB-MJ64GA/AM). EaseUS’s surface test finds no errors. Windows 10 can add and remove a partition.

Should I report this as a bug? How?

That would not be of use when noone can reproduce it, noone can fix it.
Try to manually issue the commands up to the sfdisk command that fails to create the partition #3 out of the remaining space, see /opt/openhabian/openhabian/functions/backup.bash line 543ff.
Eventually play with values to find out why it fails (some size miscalculation? wrong start= ? Maybe because of secondary superblock being used?)

Forgive my inexperience on linux … I don’t see a /home/openhabian directory. Is it hidden from me because of permissions? Or is it elsewhere on an openhabian 3.2.0 install?

There is no openHABian 3.2.0
Please don‘t mix up openHAB and openHABian version numbers.

check for /opt/openhabian/functions/backup.bash

Created a new DOS disklabel with disk identifier 0x154a1120.
/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.
/dev/sda3: No free sectors available.
Failed to add #3 partition: No space left on device

same problem here. third partition failed to create, “No free space avaiable” 16G SD card in raspberry, 32G SD in USB slot. system create 256MiB partition1 , 14.6GiB partition2 .

SD card is recognized as a 29.7G size, maybe system want to create 2x 14.6 GB? and it does not fit ?

in script - i found

minStorageSize="$((minStorageSize + srcSize))" # to ensure we have at least 4GB for storage partition plus space for the main partitions
destSize="$(blockdev --getsize64 “$dest”)"

and

if [[ “$destSize” -ge “$minStorageSize” ]]; then …

Folks, open an issue on Github please.
Set debugmode=maximum to get to see the calculations and commands, and upload the full log. Identify the command that results in Failed to add #3 partition: No space left on device.

Include the info on both of your SD cards like below.

[13:23:59] root@openhab:/home/openhabian# fdisk -l /dev/mmcblk0 /dev/sda
Disk /dev/mmcblk0: 14,9 GiB, 15931539456 bytes, 31116288 sectors
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: 0xea1ce01e

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1        8192   532479   524288  256M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      532480 31116287 30583808 14,6G 83 Linux


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: 0x867b68df

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

I have exactly the same problem.

Have opened an issue:

All,
either update from main or edit /opt/openhabian/functions/backup.bash line 540 replace the f7 by f5 and DO NOT update openHABian when asked on start. Keep debugmode=maximum to get the log output. Then retry menu option 53.

Unfortunately, this does not fix the error.

++ whiptail --title 'openHABian Configuration Tool — [openHAB3]{2021-12-02T09:19:37-07:00}(bb960d8)' --menu Backup/Restore 15 116 8 --cancel-button Back --ok-button Execute '50 | Backup openHAB config' 'Backup the current active openHAB configuration' '51 | Restore an openHAB config' 'Restore an openHAB configuration from backup zipfile' '   | Restore text only config' 'Restore text only configuration without restarting' '52 | Amanda System Backup' 'Set up Amanda to comprehensively backup your complete openHABian box' '53 | Setup SD mirroring' 'Setup mirroring of internal to external SD card' '   | Remove SD mirroring' 'Disable mirroring of SD cards' '54 | Raw copy SD' 'Raw copy internal SD to external disk / SD card' '55 | Sync SD' 'Rsync internal SD to external disk / SD card'
+ choice2='53 | Setup SD mirroring'
+ '[' 0 -eq 1 ']'
+ '[' 1 -eq 255 ']'
+ case "$choice2" in
+ setup_mirror_SD install
+ 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'
+ local storageDir=/storage
+ 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
++ timestamp
++ date +%F_%T_%Z
+ echo -n '2021-12-06_20:08:42_CET [openHABian] Setting up automated SD mirroring and backup... '
2021-12-06_20:08:42_CET [openHABian] Setting up automated SD mirroring and backup... + [[ -n '' ]]
+ [[ 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
Paketlisten werden gelesen… Fertig
Abhängigkeitsbaum wird aufgebaut… Fertig
Statusinformationen werden eingelesen… Fertig
gdisk ist schon die neueste Version (1.0.6-1.1).
0 aktualisiert, 0 neu installiert, 0 zu entfernen und 5 nicht aktualisiert.
+ 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 29,7G
+ retval=sda
+ [[ -z sda ]]
+ dest=/dev/sda
++ blockdev --getsize64 /dev/sda
+ [[ -n 31914983424 ]]
+ 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=19931539456
++ blockdev --getsize64 /dev/sda
+ destSize=31914983424
+ [[ 31914983424 -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'
+ [[ 31914983424 -ge 19931539456 ]]
++ fdisk -l /dev/mmcblk0
++ head -1
++ cut '-d ' -f5
+ start=15931539456
+ (( destSize-=start ))
+ sfdisk -d /dev/mmcblk0
+ sfdisk --force /dev/sda
+ echo '/dev/mmcblk0p3 : start=15931539456,size=15983443968, type=83'
Checking that no-one is using this disk right now ... OK

Disk /dev/sda: 29,72 GiB, 31914983424 bytes, 62333952 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: 0xb8d3a6a1

Old situation:

Device     Boot Start      End  Sectors  Size Id Type
/dev/sda1        2048 62332927 62330880 29,7G  c W95 FAT32 (LBA)

>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0x80735363.
/dev/sda1: Created a new partition 1 of type 'W95 FAT32 (LBA)' and of size 256 MiB.
/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 15931539456 out of range.
Failed to add #3 partition: Das numerische Ergebnis ist außerhalb des gültigen Bereiches
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.46.2 (28-Feb-2021)
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
+ [[ -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
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
+ true
+ show_main_menu
+ local choice
+ local version
+++ get_git_revision
+++ local branch
+++ local commitDate
+++ local shorthash
++++ git -C /opt/openhabian rev-parse --abbrev-ref HEAD
+++ branch=openHAB3
++++ git -C /opt/openhabian log --pretty=format:%aI -n 1
+++ commitDate=2021-12-02T09:19:37-07:00
++++ git -C /opt/openhabian log --pretty=format:%h -n 1
+++ shorthash=bb960d8
+++ echo '[openHAB3]{2021-12-02T09:19:37-07:00}(bb960d8)'
++ whiptail --title 'openHABian Configuration Tool — [openHAB3]{2021-12-02T09:19:37-07:00}(bb960d8)' --menu 'Setup Options' 19 116 12 --cancel-button Exit --ok-button Execute '00 | About openHABian' 'Information about the openHABian project and this tool' '' '' '01 | Select Branch' 'Select the openHABian config tool version ("branch") to run' '02 | Upgrade System' 'Update all installed software packages (incl. openHAB) to their latest version' '03 | Install openHAB' 'Install or upgrade to openHAB 3' '04 | Import config' 'Import an openHAB 3 configuration from file or URL' '' '' '10 | Apply Improvements' 'Apply the latest improvements to the basic openHABian setup ►' '20 | Optional Components' 'Choose from a set of optional software components ►' '30 | System Settings' 'A range of system and hardware related configuration steps ►' '40 | openHAB Related' 'Switch the installed openHAB version or apply tweaks ►' '50 | Backup/Restore' 'Manage backups and restore your system ►'