Clone RPi: Difference between revisions
Andre Castro (talk | contribs) |
Andre Castro (talk | contribs) |
||
Line 36: | Line 36: | ||
/dev/mmcblk0p2 97728 3766271 3668544 1.8G 83 Linux | /dev/mmcblk0p2 97728 3766271 3668544 1.8G 83 Linux | ||
</pre> | </pre> | ||
What to look for: | |||
* '''Start''' and '''End''' units are sectors, | |||
* '''sector size''' is 512 bytes | |||
The | To clone use the <code>dd</code> cloning tool. | ||
* The sector (or block size) <code>bs</code> will be the value of the '''sector size''' | |||
* <code>count</code> will be given the '''End''' of the last device (/dev/mmcblk0p2) + 1: 3766271+1 . | |||
* <code>bs=512</code> is the '''sector size''' | |||
* <code>if=/dev/mmcblk0</code> from /dev/mmcblk0 | |||
* to image file (rpi.img) </code>of=rpi.img</code> | |||
sudo dd if=/dev/mmcblk0 of=rpi.img bs=512 count=3766272 | |||
When done eject the SD-card and you'll have your Raspberry Pi image clone to a file | |||
==Clone file to card== | |||
sudo dd bs=4M if=rpi.img of=/dev/mmcblk0 | |||
==from image file to card== | ==from image file to card== |
Revision as of 17:08, 8 April 2017
Cloning a Raspberry Pi disk onto a image file can be quite useful, as it will safe you the time of installing the whole system, applications, etc. And you can have a copy of an disk in an image, ready to be cloned onto another SD-card and ran.
the following steps will show how do this.
Resizing the partitions
Shutdown the Pi and remove its SD-card.
Insert the SD-card to you computer and run gparted software, as sudo.
Select the SD-card (/dev/mmcblk/)
Select the larger partition (the one with loads of empty space) and reduce the empty space, leaving a bit of empty space (around 2000 MB) for temporary files,caches,log files,etc.
When done close the Gparted
Clone
from SD-card to image file
sudo fdisk -l /dev/mmcblk0
Will give the length of each partition, in my case it is:
Disk /dev/mmcblk0: 3.8 GiB, 4025483264 bytes, 7862272 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x0004a452 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 16 97727 97712 47.7M b W95 FAT32 /dev/mmcblk0p2 97728 3766271 3668544 1.8G 83 Linux
What to look for:
- Start and End units are sectors,
- sector size is 512 bytes
To clone use the dd
cloning tool.
- The sector (or block size)
bs
will be the value of the sector size count
will be given the End of the last device (/dev/mmcblk0p2) + 1: 3766271+1 .bs=512
is the sector sizeif=/dev/mmcblk0
from /dev/mmcblk0- to image file (rpi.img) of=rpi.img
sudo dd if=/dev/mmcblk0 of=rpi.img bs=512 count=3766272
When done eject the SD-card and you'll have your Raspberry Pi image clone to a file
Clone file to card
sudo dd bs=4M if=rpi.img of=/dev/mmcblk0
from image file to card
Insert the new card, to where you'll clone the image
sudo dd bs=4M if=rpi.img of=/dev/mmcblk0
Once done,
- eject the new card
- insert it in the Pi
- connect the network port
- power the Pi
If all is good you will see crazy blinking leds. Wait for the them to stop and look for the Pi's IP address with
nmap -sP 192.168.1.1-255