Page 1 of 1

Saving SD-image to mac?

Posted: Fri Aug 31, 2012 11:15 am
by Pieter-Jan5000
Hello,

I recently had a few crashes with my SD card so I would like to start saving the image on my computer. I have done a lot of uninstalls / installs on the image, and I don't want to redo the process every time.

When I execute:

sudo dd bs=1m if=/dev/rdisk1 of=RPi.img

I get an image RPi.img which looks pretty good, but it has a size of 8Gig, which is the size of my SD card. I only want to copy the used data, what can I do?

Thanks!

Re: Saving SD-image to mac?

Posted: Fri Aug 31, 2012 2:31 pm
by ghans
Any good compression program will see the free space , making
the resulting file ~ 700 megs big.

ghans

Re: Saving SD-image to mac?

Posted: Fri Aug 31, 2012 2:56 pm
by Joe Schmoe
As the previous poster noted, one way to do it is to just compress the resulting file. But this only solves one side of the problem (file size), but not the one that is really more likely to matter (the fact that it takes too long - because you're copying mostly unused space).

Another way to do it is to do a file copy, rather than an image copy. That is, do something like:

mkdir $HOME/PiBackup
cd $HOME/PiBackup
cp -a /mnt/SDcard .

Re: Saving SD-image to mac?

Posted: Fri Aug 31, 2012 3:13 pm
by RaTTuS
if you use rsync you don't have to switch the Pi off....
rsync -a / remotemachineip:/backupdirectory

Re: Saving SD-image to mac?

Posted: Fri Aug 31, 2012 3:19 pm
by Joe Schmoe
RaTTuS wrote:if you use rsync you don't have to switch the Pi off....
rsync -a / remotemachineip:/backupdirectory
Yes. rsync is a nice tool. Certainly the right approach once you've made a backup and want to keep it up-to-date.

Re: Saving SD-image to mac?

Posted: Fri Aug 31, 2012 3:31 pm
by Mortimer
That's quite interesting. Can RSync be used to create a sort of incremental backup to a network fileshare? Or is it a single snapshot only?

Re: Saving SD-image to mac?

Posted: Fri Aug 31, 2012 3:58 pm
by Pieter-Jan5000
Will the previous solutions result in an image? I really want an image that I can put on any SD card without having to install anything else first ...

Re: Saving SD-image to mac?

Posted: Fri Aug 31, 2012 4:02 pm
by PIstolero
No, with rsync you don´t get an bootable image from your SD card, only the files.
I don´t know OSX but with Linux you can use a pipe to zip the image on the fly, for example:
sudo dd bs=1m if=/dev/rdisk1 | gzip -c > /tmp/rpi.img
Does this work with OSX? (maybe something else then gzip)

Re: Saving SD-image to mac?

Posted: Fri Aug 31, 2012 4:04 pm
by Mortimer
Mac OS X has gzip.

Re: Saving SD-image to mac?

Posted: Sat Sep 01, 2012 6:27 pm
by wpns
My Mac Mini (10.7) won't mount the file system, so I've been using:

sudo diskutil unmount /dev/disk5s1
sudo dd bs=100m if=/dev/rdisk5 of=WPNSbackup.img
sudo diskutil eject /dev/rdisk5

And yeah, it's ugly, but makes an image that will be restorable using dd on the mac. 8G of 'wasted' space on my Mac isn't noticable. 8*)

Re: Saving SD-image to mac?

Posted: Sat Sep 01, 2012 6:45 pm
by Joe Schmoe
wpns wrote:My Mac Mini (10.7) won't mount the file system, so I've been using:

sudo diskutil unmount /dev/disk5s1
sudo dd bs=100m if=/dev/rdisk5 of=WPNSbackup.img
sudo diskutil eject /dev/rdisk5

And yeah, it's ugly, but makes an image that will be restorable using dd on the mac. 8G of 'wasted' space on my Mac isn't noticable. 8*)
As I said, it's not the space that's the issue (in these modern, enlightened times), but the *time*.

To my mind, the problem is that it is going to take a long time [*] to make an 8G image, and most of that time is wasted (i.e., copying empty space).

[*] Or, as Harrison Ford says in "6 Days, 7 Nights", "A long, long, long, long, *long* time" (one of my favorite movie lines)

P.S. Yes, you don't get a "ready to go" image, but you're a smart guy. You'll figure out how to restore it - it is quite easy.

P.P.S. If I were going this, I'd make a ZIP file of the FAT partition - just do it once and be done with that end of it. Then I'd use rsync to make and maintain an incremental, file-by-file, image of the Linux partition.

Re: Saving SD-image to mac?

Posted: Fri Sep 21, 2012 10:55 pm
by James80A
Hi. I've just tried this dd command: sudo dd bs=1m if=/dev/disk1 of=RPi.img.

With this result:
3781+1 records in
3781+1 records out
3965190144 bytes transferred in 686.081772 secs (5779472 bytes/sec)

My question is where is the output file located?

Thanks.

Re: Saving SD-image to mac?

Posted: Sat Sep 22, 2012 7:46 am
by RaTTuS
James80A wrote:Hi. I've just tried this dd command: sudo dd bs=1m if=/dev/disk1 of=RPi.img.

With this result:
3781+1 records in
3781+1 records out
3965190144 bytes transferred in 686.081772 secs (5779472 bytes/sec)

My question is where is the output file located?

Thanks.
in the directory that your ran the commandfrom

Re: Saving SD-image to mac?

Posted: Sat Mar 09, 2013 9:59 pm
by jtillinghast
I'm trying to figure out what to grab for the image... When I run "mount," I have two choices to choose from:

Code: Select all

/dev/mmcblk0p2 on / type ext4 (rw,noatime)
proc on /proc type proc (rw)
devpts on /dev/pts type devpts (rw,noexec,nosuid,relatime,gid=5,mode=620)
/dev/mmcblk0p1 on /boot type vfat (rw,noatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
Silly question, but I'm only going to grab if=/dev/mmbcblk0p1 , right (since it's the one with /boot)?
Thanks!

Edit: Also, I tried to run "bs=1m," but got 'invalid number '1m.' I tried 1M, and it seemed to work, but I probably just massively changed the intent of the instruction, right?

Re: Saving SD-image to mac?

Posted: Sat Mar 09, 2013 11:03 pm
by ghans
I don't think it makes much sense to use dd on a running system.
Plug the SD Card into a Linux or Mac box , then you can use
the instructions.

ghans

Re: Saving SD-image to mac?

Posted: Sun Mar 10, 2013 7:01 pm
by wpns
/*
Then I'd use rsync to make and maintain an incremental, file-by-file, image of the Linux partition.
*/

Does that work on a running system?

Re: Saving SD-image to mac?

Posted: Mon Mar 11, 2013 9:05 am
by RaTTuS
wpns wrote:/*
Then I'd use rsync to make and maintain an incremental, file-by-file, image of the Linux partition.
*/

Does that work on a running system?
yes .....
YMMV
depending that you are not changing system files at the same time you should be fine

Re: Saving SD-image to mac?

Posted: Wed Apr 24, 2013 9:05 am
by bender86
Salut,

Quand j'essaie de backuper la carte sur mon macavec:
sudo dd bs=1m if=/dev/rdisk0 of=RPi.img

ça tourne indéfiniment et si je l'arrête avec CTRL + C, je m'apperçois que la taille est déjà à plus de 15Go or c'est une carte de 4Go

Si une âme charitable pouvait m'aider :)

Re: Saving SD-image to mac?

Posted: Fri Apr 26, 2013 1:01 pm
by thbodart
Bonjour bender86.

Il y a beaucoup de chance que disk0 soit le disque principal du Mac et pas la carte SD.

Thierry