01342
Posts: 8
Joined: Sun May 12, 2013 3:59 pm

Backing up SD card

Mon May 04, 2015 8:28 am

Hello,

Can anyone point me at an idiot's guide to backing up an SD card so that I can just reinstall rather than have to go through the whole set up process the next time my pi corrupts?
I've tried Win32diskmanager as suggested all over Google but keep getting an image that is WAY too large.

Cheers,

Keith.

ShorTie
Posts: 92
Joined: Sun May 12, 2013 3:54 pm

Re: Backing up SD card

Mon May 04, 2015 8:50 am

May I suggest using mini_image.sh ??

viewtopic.php?p=737900#p737900

It will make a image that is just slightly bigger then is used

Have A Great Day
ShorTie ;)

OttovanZanten
Posts: 61
Joined: Fri Apr 17, 2015 8:45 am
Location: Groningen, the Netherlands

Re: Backing up SD card

Mon May 04, 2015 11:46 am

How large does your image get?
I think raspbian img is about 900 megs, but after installing it I had 300 megs left on my 4 GB SD card.
So if your image ends up being well over 4 GB that seems about right. It's just not as well compressed as the 900mb raspbian image.

My solution... I just have a short list of instructions in a txt file somewhere in my pc to remind me of some stuff I like in a fresh install.

Like expand file system, enable SSH, set correct time zone, set background color to darkgrey, do sudo update, do sudo upgrade, install libre office, install tightvncserver, start vnc with command 'vncserver :0 -geometry 800x600 -depth 24'
After that I can move files to and from the SD card over the network using WinSCP. (You need to have SSH enabled)
(Oh yeah and open the terminal, type lxsession-edit and uncheck LXPolKit so you get rid of the annoying error on boot)

This works well for me as my OS is usually set up as I like it in only 10 minutes and I don't have to transfer too many files. Mainly some python scripts. If you have a server running for instance and you got lots of settings to do before it works then this isn't the way to go though.

ShorTie
Posts: 92
Joined: Sun May 12, 2013 3:54 pm

Re: Backing up SD card

Mon May 04, 2015 9:46 pm

It will end up 420mb bigger then the used space on the sdcard + 40mb for /boot.
You can not wipe out all the free space or the system will not boot.

Have A Great Day
ShorTie ;)

01342
Posts: 8
Joined: Sun May 12, 2013 3:59 pm

Re: Backing up SD card

Tue May 05, 2015 3:27 pm

OttovanZanten wrote:How large does your image get?
I think raspbian img is about 900 megs, but after installing it I had 300 megs left on my 4 GB SD card.
So if your image ends up being well over 4 GB that seems about right. It's just not as well compressed as the 900mb raspbian image.

My solution... I just have a short list of instructions in a txt file somewhere in my pc to remind me of some stuff I like in a fresh install.

Like expand file system, enable SSH, set correct time zone, set background color to darkgrey, do sudo update, do sudo upgrade, install libre office, install tightvncserver, start vnc with command 'vncserver :0 -geometry 800x600 -depth 24'
After that I can move files to and from the SD card over the network using WinSCP. (You need to have SSH enabled)
(Oh yeah and open the terminal, type lxsession-edit and uncheck LXPolKit so you get rid of the annoying error on boot)

This works well for me as my OS is usually set up as I like it in only 10 minutes and I don't have to transfer too many files. Mainly some python scripts. If you have a server running for instance and you got lots of settings to do before it works then this isn't the way to go though.
Thanks, I pretty much do as you do but setting up a couple of the programms is a pain so better to get the Pi just right then copy the SD card. It doesn't matter if I expand the file system during the initial or not when taking a copy using Win32diskmanager the new image is always just bigger than it was on the SD card so than an image taken from an 8GB card won't fit back onto that very same SD card :!:

Cheers,

Keith.

01342
Posts: 8
Joined: Sun May 12, 2013 3:59 pm

Re: Backing up SD card

Tue May 05, 2015 3:30 pm

ShorTie wrote:It will end up 420mb bigger then the used space on the sdcard + 40mb for /boot.
You can not wipe out all the free space or the system will not boot.

Have A Great Day
ShorTie ;)
Thanks but I'm afraid my computer/pi/linux/keyboard skills do not extend to understanding how to do what you've suggested.
It's not that I'm not grateful or believe that your suggstion won't work it's just that I'm too thick to use it. I couldn't even open the file that I downloaded from dropbox!!

Cheers,

Keith.

User avatar
RaTTuS
Posts: 10304
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Backing up SD card

Tue May 05, 2015 3:35 pm

have you got a spare usb sdcard adapter
then plug it into the rpi with a sdcard in it
then, assuming your not using noobs
open a terminal and :-
sudo sh

then assuming your sdcard is found as /dev/sda
fdisk /dev/sda
create 2 partitions
one of type c [fast32 lba] - size approx 100M
one of type 83 [linux] - the rest of the SDcard
write the changes
then make the file systems
mkfs.vfat /dev/sda1
mkfs.ext4 /dev/sda2 #this can be ext2


#then

mount /dev/sda1 /mnt
cp -ax /boot /mnt
sync
umount /mnt
mount /dev/sda2 /mnt
cp -ax / /mnt
sync
umount /mnt

exit



now if you are happy with the image as a backup then great what you can do in the future is to update the backup to a new image by

sudo sh
mount /dev/sda2 /mnt
mount /dev/sda1 /mnt/boot
rsync -ax /boot/ /mnt/boot
rsync -ax / /mnt
sync
umount /mnt/boot /mnt
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

ShorTie
Posts: 92
Joined: Sun May 12, 2013 3:54 pm

Re: Backing up SD card

Tue May 05, 2015 6:11 pm

Get the file on your pi with

Code: Select all

wget https://www.dropbox.com/s/p51aqnxemu3zp4h/mini_image.sh --no-check-certificate
make it executable with

Code: Select all

chmod +x mini_image.sh
then execute/run it with

Code: Select all

./mini_image.sh backup.img sda
assuming you have a storage device hooked up to /dev/sda.


Have A Great Day
ShorTie ;)

User avatar
electronicsguy
Posts: 156
Joined: Wed Jan 21, 2015 11:20 pm
Contact: Website

Re: Backing up SD card

Tue May 05, 2015 6:17 pm

01342 wrote:Hello,

Can anyone point me at an idiot's guide to backing up an SD card so that I can just reinstall rather than have to go through the whole set up process the next time my pi corrupts?
I've tried Win32diskmanager as suggested all over Google but keep getting an image that is WAY too large.

Cheers,

Keith.
It'd be better if you solve the problem of frequent corruption by transferring the root file system into a usb drive.
blog: https://electronicsguy.wordpress.com
github: https://github.com/electronicsguy

User avatar
kusti8
Posts: 3439
Joined: Sat Dec 21, 2013 5:29 pm
Location: USA

Re: Backing up SD card

Tue May 05, 2015 7:31 pm

electronicsguy wrote:
01342 wrote:Hello,

Can anyone point me at an idiot's guide to backing up an SD card so that I can just reinstall rather than have to go through the whole set up process the next time my pi corrupts?
I've tried Win32diskmanager as suggested all over Google but keep getting an image that is WAY too large.

Cheers,

Keith.
It'd be better if you solve the problem of frequent corruption by transferring the root file system into a usb drive.

Even if you put it onto a USB drive, it may be more safe but that doesn't guarantee no corruption or human mistakes, which is what usually happens.
There are 10 types of people: those who understand binary and those who don't.

01342
Posts: 8
Joined: Sun May 12, 2013 3:59 pm

Re: Backing up SD card

Wed May 06, 2015 10:27 am

Thanks everyone.

Keith.

Return to “Beginners”