WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How can I make an image file from working SD card.  (Read 2282 times)

Offline stoker

  • Newbie
  • *
  • Posts: 15
How can I make an image file from working SD card.
« on: September 04, 2017, 06:49:50 AM »
Hi

I've been working on a little project using piCore on a rPI3 for a while now and thought I should back-up my SD card to an image file so that I could, if need be, write a new SD card that would behave exactly like the one I'm currently using.

When I put the working SD card into my Ubuntu laptop and ran:
   
    mount | grep "/media/*"

I can see 2 entries:

    /dev/mmcblk0p1 on /media/ian/piCore type vfat
    /dev/mmcblk0p2 on /media/ian/ab8d10da-a8b7-4852-b39d-f73228f492c6b type ext4

Can I make a single image file from this somehow? If so how?

Cheers
Ian

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: How can I make an image file from working SD card.
« Reply #1 on: September 04, 2017, 06:56:54 AM »
Hi stoker
To do the whole drive you probably need to use  /dev/mmcblk0  directly.


Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 661
Re: How can I make an image file from working SD card.
« Reply #3 on: September 04, 2017, 01:10:46 PM »
And my extra hints is to visit this dude's funny site how DD works.

http://www.noah.org/wiki/Dd_-_Destroyer_of_Disks

Offline stoker

  • Newbie
  • *
  • Posts: 15
Re: How can I make an image file from working SD card.
« Reply #4 on: September 05, 2017, 02:04:53 AM »
Thanks for the replies and links, unfortunately my SD card reader has just packed up so I can't try them out, hopefully have a new one tomorrow.

Cheers
Ian

Offline stoker

  • Newbie
  • *
  • Posts: 15
HowTo: Make an image file from working SD card.
« Reply #5 on: September 08, 2017, 03:07:40 AM »
Here's a quick HowTo. It's based on the info and links received in this thread. The process has been tested using an Ubuntu 16.04 PC with a usb SD card reader.

Make an image file from SD card to Linux computer

1) Insert micro SD card into computer.

2) Identify the SD card on your system
   $ sudo fdisk -l
   
   In my case fdisk returned Disk /dev/sdc with 2 partiions: /dev/sdc1 and /dev/sdc2

3) Un-mount the disk partitions
   $ sudo umount /dev/sdc1
   $ sudo umount /dev/sdc2
   
4) Make the image file (this can take a while and you don't get much info from dd unless there's an error). You could monitor file as it's being written using ls -l. to see the progress.
   $ sudo dd if=/dev/sdc of=~/myTCimage.img bs=4M

5) When dd finished, you should get some info about the copy reported to the terminal and an image file in your home directory. If all was OK remove the SD card, you're done.
   
To write an image file to SD card from Linux computer.

1) Insert a new micro SD card into computer.

2) Ensure disk isn't mounted steps 2) and 3) above.

3) Copy image file to new SD card. The command shown assumes your image is in your home directory. Again this can take a while.
   $ sudo dd if=~/myTCimage.img of=/dev/sdc bs=4M

4) When dd finished, you should get some info about the copy reported to the terminal. If all was OK
   remove the SD card and try it in your rPi.

Cheers
--Ian

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: How can I make an image file from working SD card.
« Reply #6 on: September 08, 2017, 04:26:42 AM »
To see dd's progress:
Code: [Select]
dd status=progress if=...
Download a copy and keep it handy: Core book ;)

Offline jefferee

  • Newbie
  • *
  • Posts: 31
Re: How can I make an image file from working SD card.
« Reply #7 on: September 08, 2017, 08:03:19 AM »
I'll generally just shove a USB stick into the Pi and run something like

Code: [Select]
dd if=/dev/mmcblk0 of=/mnt/sda1/image.img bs=1M count=400
(I keep mmcblk0p2 fairly small so that backing it up goes quickly).