Pieter-Jan5000
Posts: 40
Joined: Tue Jun 12, 2012 7:20 pm

Saving SD-image to mac?

Fri Aug 31, 2012 11:15 am

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!
http://www.pieter-jan.com/

ghans
Posts: 7893
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Saving SD-image to mac?

Fri Aug 31, 2012 2:31 pm

Any good compression program will see the free space , making
the resulting file ~ 700 megs big.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Saving SD-image to mac?

Fri Aug 31, 2012 2:56 pm

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 .
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

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

Re: Saving SD-image to mac?

Fri Aug 31, 2012 3:13 pm

if you use rsync you don't have to switch the Pi off....
rsync -a / remotemachineip:/backupdirectory
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

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Saving SD-image to mac?

Fri Aug 31, 2012 3:19 pm

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.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
Mortimer
Posts: 938
Joined: Sun Jun 10, 2012 3:57 pm

Re: Saving SD-image to mac?

Fri Aug 31, 2012 3:31 pm

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?
--------------
The purpose of a little toe is to ensure you keep your furniture in the right place.

Pieter-Jan5000
Posts: 40
Joined: Tue Jun 12, 2012 7:20 pm

Re: Saving SD-image to mac?

Fri Aug 31, 2012 3:58 pm

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 ...
http://www.pieter-jan.com/

User avatar
PIstolero
Posts: 101
Joined: Mon Jul 23, 2012 6:28 am
Location: paradise city, where the grass is green and the girls are pretty

Re: Saving SD-image to mac?

Fri Aug 31, 2012 4:02 pm

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)
Last edited by PIstolero on Fri Aug 31, 2012 4:05 pm, edited 1 time in total.

User avatar
Mortimer
Posts: 938
Joined: Sun Jun 10, 2012 3:57 pm

Re: Saving SD-image to mac?

Fri Aug 31, 2012 4:04 pm

Mac OS X has gzip.
--------------
The purpose of a little toe is to ensure you keep your furniture in the right place.

wpns
Posts: 128
Joined: Sat Sep 01, 2012 2:50 pm

Re: Saving SD-image to mac?

Sat Sep 01, 2012 6:27 pm

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*)

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Saving SD-image to mac?

Sat Sep 01, 2012 6:45 pm

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.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

James80A
Posts: 1
Joined: Fri Sep 21, 2012 10:41 pm

Re: Saving SD-image to mac?

Fri Sep 21, 2012 10:55 pm

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.

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

Re: Saving SD-image to mac?

Sat Sep 22, 2012 7:46 am

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

jtillinghast
Posts: 6
Joined: Mon Mar 04, 2013 1:26 am

Re: Saving SD-image to mac?

Sat Mar 09, 2013 9:59 pm

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?

ghans
Posts: 7893
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Saving SD-image to mac?

Sat Mar 09, 2013 11:03 pm

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
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

wpns
Posts: 128
Joined: Sat Sep 01, 2012 2:50 pm

Re: Saving SD-image to mac?

Sun Mar 10, 2013 7:01 pm

/*
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?

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

Re: Saving SD-image to mac?

Mon Mar 11, 2013 9:05 am

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

bender86
Posts: 10
Joined: Thu Apr 18, 2013 6:08 pm

Re: Saving SD-image to mac?

Wed Apr 24, 2013 9:05 am

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 :)

thbodart
Posts: 1
Joined: Sat Apr 20, 2013 8:04 am

Re: Saving SD-image to mac?

Fri Apr 26, 2013 1:01 pm

Bonjour bender86.

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

Thierry

Return to “Beginners”