Restoring backup to another SDCard

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
schmeckles22
Posts: 5
Joined: Wed Jan 31, 2018 4:22 pm

Restoring backup to another SDCard

Post by schmeckles22 »

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...

Image

It will hang like this forever.
User avatar
johnvick
Legend
Posts: 693
Joined: Wed Jun 08, 2016 11:53 am
Location: New Zealand

Re: Restoring backup to another SDCard

Post by johnvick »

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
User avatar
Fourdee
Site Admin
Posts: 2782
Joined: Tue Feb 06, 2007 1:36 pm

Re: Restoring backup to another SDCard

Post by Fourdee »

John beat me too it lol :)

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 ... -mac-59294
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
schmeckles22
Posts: 5
Joined: Wed Jan 31, 2018 4:22 pm

Re: Restoring backup to another SDCard

Post by schmeckles22 »

Fourdee wrote:John beat me too it lol :)

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 ... -mac-59294


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

Thanks for the heads up guys.
User avatar
Fourdee
Site Admin
Posts: 2782
Joined: Tue Feb 06, 2007 1:36 pm

Re: Restoring backup to another SDCard

Post by Fourdee »

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

Thanks for the heads up guys.
Copy and paste all option, if needed:

Code: Select all

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
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
Post Reply