Restoring backup to another SDCard

Hello,

I created a backup and moved it over to a fresh installation of DietPi on a new faster SDCard. It restored and then when I reboot I get the following…

It will hang like this forever.

May be easier to to create an image of the old SD card with Win32 disk imager (or similar program) and write the image on to the new card. The new card will have to be the same size or bigger for this to work…

John

John beat me too it lol :slight_smile:

Looks like filesystem corruption.

A simple solution would be to clone the SD card.

Try using Win32diskimager image to:

  • Read the SD card (old) image to a file
  • Write the image to the SD card (new).

eg: https://computers.tutsplus.com/articles/how-to-clone-your-raspberry-pi-sd-cards-with-windows--mac-59294

Ahhhh that was my next option :slight_smile: I will write to new card and expand filesystem.

Thanks for the heads up guys.

Copy and paste all option, if needed:

cat << _EOF_ > /etc/systemd/system/dietpi-fs_partition_resize.service
[Unit]
Description=dietpi-fs_partition_resize
Before=dietpi-ramdisk.service

[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/bin/bash -c '/var/lib/dietpi/fs_partition_resize.sh | tee /var/tmp/dietpi/logs/fs_partition_resize.log'
StandardOutput=tty

[Install]
WantedBy=local-fs.target
_EOF_
systemctl daemon-reload
G_RUN_CMD systemctl enable dietpi-fs_partition_resize.service

cat << _EOF_ > /var/lib/dietpi/fs_partition_resize.sh
#!/bin/bash

systemctl disable dietpi-fs_partition_resize.service
systemctl enable dietpi-fs_expand.service
systemctl daemon-reload

sync

TARGET_PARTITION=0
TARGET_DEV=\$(findmnt / -o source -n)

# - MMCBLK[0-9]p[0-9] scrape
if [[ "\$TARGET_DEV" = *"mmcblk"* ]]; then

TARGET_DEV=\$(findmnt / -o source -n | sed 's/p[0-9]\$//')
TARGET_PARTITION=\$(findmnt / -o source -n | sed 's/.*p//')

# - Everything else scrape (eg: /dev/sdX[0-9])
else

TARGET_DEV=\$(findmnt / -o source -n | sed 's/[0-9]\$//')
TARGET_PARTITION=\$(findmnt / -o source -n | sed 's|/dev/sd.||')

fi

cat << _EOF_1 | fdisk \$TARGET_DEV
p
d
\$TARGET_PARTITION
n
p
\$TARGET_PARTITION
\$(parted \$TARGET_DEV -ms unit s p | grep ':ext4::;' | sed 's/:/ /g' | sed 's/s//g' | awk '{ print \$2 }')

p
w

_EOF_1

reboot

_EOF_
G_RUN_CMD chmod +x /var/lib/dietpi/fs_partition_resize.sh

G_DIETPI-NOTIFY 2 'Generating dietpi-fs_partition_expand for subsequent boot'

cat << _EOF_ > /etc/systemd/system/dietpi-fs_expand.service
[Unit]
Description=dietpi-fs_expand
Before=dietpi-ramdisk.service

[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/bin/bash -c "resize2fs \$(findmnt / -o source -n) &> /var/tmp/dietpi/logs/fs_expand.log; systemctl disable dietpi-fs_expand.service; systemctl daemon-reload"
StandardOutput=tty

[Install]
WantedBy=local-fs.target
_EOF_
systemctl daemon-reload
reboot