Best Procedure for Cloning the OS SD Card?

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
CaptainSunset
 
Posts: 62
Joined: Thu Mar 19, 2015 2:27 pm

Best Procedure for Cloning the OS SD Card?

Post by CaptainSunset »

At this point, I've done a moderate amount of modification with the Raspian OS on my Pi; mostly apt-get-ting familiar software, adding corefonts, config'ing wi-fi, and changing the password.
So far so good; in fact, easy as pie...

Once I started thinking about adding users, or the many purposes Pis could be put to, I realized I'd like to have a 'known good default' OS card, a 'try anything once' experimenting card, and even dedicated purpose cards for specific projects.

Looking online, I found various methods of copying the SD card, some involving an additional computer, or adding a card reader to the Pi, with scripts or not (involving command understanding I don't have yet)...

The two most likely posts I found were:

How do I backup my Raspberry Pi?
http://raspberrypi.stackexchange.com/qu ... spberry-pi

and

Backup, Restore, Customize and Clone your Raspberry Pi SD Cards (tutorial) [Updated 8/30 for NOOBs SD]
http://sysmatt.blogspot.com/2014/08/bac ... -your.html

Neither is recent enough to be based on the Pi 2B, and addressed to a higher level of understanding than mine (Matt just jumps in and starts using root).

Can someone more experienced recommend any other particular method as better than these? Thanks!

User avatar
ADearUser
 
Posts: 98
Joined: Thu Mar 12, 2015 11:07 am

Re: Best Procedure for Cloning the OS SD Card?

Post by ADearUser »

That stack exchange solution is good, especially if you're in a rush. I'd use the dd command from within a linux laptop or desktop PC. There's a slight problem with that approach though because what if you clone a 32gb SD card, but you want to place it on a 16GB SD card. It should be possible if youre RPi files sum to less than 16GB, but it requires shrinking the image you create afterwards.

You might want to look into puppet too... That's what Dev Ops ppl in the industry have concluded is better than w/e the * we've been doing up till now ;) I haven't tested it yet, but will when I get freetime. Basically with puppet, you don't backup files or create images, rather you create perscriptions for fresh installs of software with proper configurations that you think are best for said software. That's ultimately what you want is to have is fresh installs with your configurations, not a bunch of .img files where 'you got lucky' and subtle pieces of software got installed and luckily aren't interfering (too noticably) with the software you actually want installed.

Shrink the .img file down: http://softwarebakery.com/shrinking-images-on-linux
Puppet: http://nofail.de/2013/01/pulling-string ... pberry-pi/

User avatar
ADearUser
 
Posts: 98
Joined: Thu Mar 12, 2015 11:07 am

Re: Best Procedure for Cloning the OS SD Card?

Post by ADearUser »

Just a quick heads up, be very careful with the backups. Don't overwrite your existing SD, to test, use a second SD card. I've been playing around with shrinking the img of a 32gb installed into a 16gb card in the background and got a kernel panic while booting that I'll need to sort out later =/ But doing a plain DD command should work fine (not tested yet though...). Just wanted to give you that warning up front.

User avatar
CaptainSunset
 
Posts: 62
Joined: Thu Mar 19, 2015 2:27 pm

Re: Best Procedure for Cloning the OS SD Card?

Post by CaptainSunset »

Thanks for the info, Dear!

WIll check puppet out; will proceed carefully- much of this is very new to me.

I've decided not to go bigger than 16 gig SD cards for now; Sandisk Class 10s are going for $15 bucks on sale now, a buck a gig (used to be a good price on a mechanical HD). If I ever need significantly more, say for video/music archives, I'll prob'ly use USB flash drives.

& yeah, a dd command is whiteknuckle territory for me...

User avatar
ADearUser
 
Posts: 98
Joined: Thu Mar 12, 2015 11:07 am

Re: Best Procedure for Cloning the OS SD Card?

Post by ADearUser »

First, I don't know how or why, but this store near me called MicroCenter sells class 10 SD cards for $7 a pop, 16gb. I tested one once and they meet the class 10 standards.

I've got a lot of RPi units at this point, so I'm looking into better ways of organizing deployments. Turns out using chef might actually be a better method than puppet, but I still don't have a routine for myself yet. If you're new to the pi and just have one or two raspberries around, just using the simple dd command might be your best bet, but I recommend you try and keep a log of what commands you run against your pi. Specifically `apt-get install` commands you run, and anything related to `./build` commands. I have a web application scratch pad/blog where I paste in "noteable" installations which ensures I have some level of repeatability across raspberrys. Run history >> ~/hist.txt to dump out all the commands you've run on your pi to-date, you might find that pretty handy to know if you're just starting out.

Anyway, one last note about the dd command, 'if' stands for input file, and 'of' stands for output file. The command might feel a lot simpler after knowing that. Still a white knuckle thing, but not too overly complicated.

User avatar
CaptainSunset
 
Posts: 62
Joined: Thu Mar 19, 2015 2:27 pm

Re: Best Procedure for Cloning the OS SD Card?

Post by CaptainSunset »

"Run history >> ~/hist.txt to dump out all the commands you've run on your pi to-date, you might find that pretty handy to know if you're just starting out. "

Wow... thanks, that's really worth knowing! I've been keeping track manually in a .txt file on the card, but know I missed at least one, and even the order can be important.

btw, there's a guy posting over at the Pi foundation who's been getting AC shocks, sounds like he is bringing in some serious voltage over the monitor cable. Seems like something that could pop SD cards too.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”