Saturday, August 21, 2021

How to backup and restore Raspberry Pi MicroSD card on Mac and Windows

 

In order to take a backup following are the basic steps:

  1. Connect the Micro SD card.
  2. Create an Micro SD card image which will act as a backup image.
In order to restore a backup following are the basic steps:
  1. Connect the Micro SD card.
  2. Format the Micro SD card.
  3. Write the Micro SD card image on the Micro SD card.


On Windows


To take backup

  • Connect your Micro SD card

    • Ensure that your computer have an SD card slot.
    • Insert Micro SD card in the SD card adapter which comes with the Micro SD card.
    • Insert the SD card adapter in the SD card slot.
    • Check if Windows is able to detect the card. SD card will have a boot as name.

  • Install Win32 Disk Imager (One of best softwares to use for this purpose but feel free to use other software. Though the steps for other software will be similar.)


  • Open Win32 Disk Imager




  • Select the location for the file where back is required to be created and the file name by either selecting the folder icon (blue icon) or by typing the path. Ensure that the file name should end with .img.


  • Select the SD card from Device dropdown.



  • Click on "Read" button and relax as this is going to take some time to create the backup file.


To restore a backup

  • Connect SD card 


  • Format the SD card

  • Open Win32 Disk Imager


  • Select the file from which the backup is required to be restored.


  • Select the SD card from Device dropdown


  • Select Write and relax. This will take more time as compared to the time it took for backup.




On Mac


To take a backup

  • Connect the SD card. Note: the SD card will not be detected as a card to read the contents and you may see an error popup. Ignore the error popup.

  • Open the Terminal and run this command
$ diskutil list

This command will display all the connected storage devices

 


  • Identify the Name, Size and Volume of your SD card by looking at the output


  • Type this command to create a backup file for the SD card (ensure the file extension is .dmg)
$ sudo dd if=<Volume> of=<Location>/<filename>.dmg 
e.g. sudo dd if=/dev/disk1 of=~/Desktop/pi-backup.dmg


To restore a backup

  • Connect the SD card (Ensure that the card is a blank card or is pre-formatted)


  • List the disk volumes using the following command (refer output above)

$ diskutil list


  • Run the following command to restore the backup

$ sudo dd if=<Location of file>/<filename>.dmg of=<Volume>

e.g. sudo dd if=~/Desktop/pi-backup.dmg of=/dev/disk1


How to get rid of crazy "remote identification changed" error

 In your life if you ever used SSH to access a machine from two different computers or laptops then you might have encountered this error:

[user@hostname ~]$ ssh pi@bestpi.in.universe @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the RSA key sent by the remote host is 5e:45:f9:a8:af:38:3d:b1:a5:c3:76:1d:02:f5:77:00. Please contact your system administrator. Add correct host key in /home/hostname /.ssh/known_hosts to get rid of this message. Offending RSA key in /var/lib/sss/pubconf/known_hosts:4 RSA host key for pong has changed and you have requested strict checking. Host key verification failed.


You might be wondering what in the world did you do wrong. Well....nothing actually. How to get rid of this error (and remove yourself from guilt), just use this command on the terminal:

ssh-keygen -R <host>

for e.g. ssh-keygen -R 192.168.0.19

 

 

SD Card Partitioning in Windows

The handy dandy tool for disk partitioning is Disk Management  and it works like a charm for Hard Disks. But, when a similar thing is tried ...