ldmo
Posts: 1
Joined: Thu Jul 20, 2017 12:23 pm

Create OS image NOT clone of SD

Thu Jul 20, 2017 12:30 pm

Hi,

I have around 50 raspberry pi 2s in the field.
They are using a raspian image that i have then edited to suit the application they are used for, for instance create an access point, a front end for user to interact with the system, backend code to communicate with the host system etc.

I have replicated the SD cards using ApplePi Baker (MAC), i'm sure it would work the same using Win32DiskImager.

My question is that; the disk imager simply uses dd (I assume), to image the whole disk regardless of whether the whole disk is used. If i download a fresh copy of raspbian lite for instance, that image is only around 1.3GB. How can I image my "now custom" OS in such a way that I dont have to burn 8GB/16GB cards everytime, with the risk they will not fit, if the card is slightly smaller?

Thanks in advance.

User avatar
elkberry
Posts: 167
Joined: Wed Dec 28, 2016 9:21 pm

Re: Create OS image NOT clone of SD

Thu Jul 20, 2017 8:10 pm

Maybe you want to have a look into https://github.com/billw2/rpi-clone, which is a script for creating the necessary partitions and then rsyncing the mSD to another mSD. To be used on a Pi to copy its running system.

I haven't tried to use it on another Linux yet, such as Ubuntu or desktop Debian. Could work too for offline cloning, might need slight adaption at least for the source device.
From ZX81 to Raspberry Pi, but wait ... where's the 7805 gone?

User avatar
B.Goode
Posts: 8894
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Create OS image NOT clone of SD

Thu Jul 20, 2017 8:34 pm

How can I image my "now custom" OS in such a way that I dont have to burn 8GB/16GB cards everytime
The SD Card Copier, a standard part of current versions of Raspbian?

Introduced in this blog post: https://www.raspberrypi.org/blog/anothe ... -raspbian/

gkaiseril
Posts: 654
Joined: Mon Aug 08, 2016 9:27 pm
Location: Chicago, IL

Re: Create OS image NOT clone of SD

Thu Jul 20, 2017 8:58 pm

Yes it is. It does a full copy of the SD in Pi's SD slot to another SD, any size, in card reader. Note that the computer name is not changed, so if you want to uniquely name your computer you will need to edit the configuration file.
f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng.

User avatar
procount
Posts: 1782
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: Create OS image NOT clone of SD

Thu Jul 20, 2017 11:47 pm

You can simply create a tar file of the whole of each partition (e.g. boot and root) and then compress them with xz. That's how NOOBS stores its OS install files. To restore you just do the reverse after you have te-created the partitions.
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

peterlite
Posts: 720
Joined: Sun Apr 17, 2016 4:00 am

Re: Create OS image NOT clone of SD

Fri Jul 21, 2017 1:55 am

You can also truncate the unused portion of a disk image. You use gparted to shrink the last partition, which leaves part of the card unused. you can then chop off the unused part of the image. I used it to move 5 GB from a 16 GB card to an 8 GB card. It is messy. I am adding it to complete the list of alternatives mentioned in this thread.

gbl
Posts: 1
Joined: Mon Jan 07, 2019 7:09 pm

Re: Create OS image NOT clone of SD

Mon Jan 07, 2019 7:28 pm

i'm a newbie... so please forgive if i mis-post. this topic sound almost exactly like what i'm hoping to accomplish... except...

i have about 12 rPis in the field... model 1Bs, 2Bs, and 3Bs... all running Raspbian. but... many are in harsh environments (but weathertight). any in direct sunlight (again... in watertight enclosures), have fans, and temperatures don't normally present a problem (i have a shell script running on the Pis that alert me if CPU temperatures get too high).

but... given that rPis aren't really considered mission critical (although i treat them like they are ... YAY Go PI), i'd like to be able to log into them periodically, and either retrieve the necessary files to be able to generate OR generate on the PI, the image file (.img) to burn a clone of the running PIs SD card, and then move that .img file offsite so that it can be used to create a recovery SD.

so... to recap... i'd like to create an OS image (.img file) from a running raspberry pi system, but not burn the image right then, but to just create the .img file, and move/copy it off the PI to an offsite server, for backup/quick recovery of a possible.

this sounds like i'm understanding about 95% of what's needed, to do what i want, but i'm not smart enough to make the smarts-leap to doing everything here, but stop before writing to another SD card on the PI, and just retrieve the .img file to burn a new SD offsite.

thanks for the patience required to dumb it down for me.

Gerard.

Return to “Advanced users”