Long Way
Copy SD Card 8GB with DD
In linux you can use DD to copy the whole image of a SD Card. Find the attached SD Card device
Code: Select all
$ df -h | grep sd
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 19G 4.1G 14G 24% /
/dev/sda5 87G 21G 63G 25% /home
/dev/sdc2 3.0G 1.8G 1.1G 63% /media/mcon/rootfs
/dev/sdc1 56M 19M 38M 33% /media/mcon/3312-932F
Make an image of the Sd Card attached.
Code: Select all
$ sudo umount /dev/sdx
$ sudo dd if=/dev/sdx of=sdcard.img bs=1024
$ ls -lrt | grep sdcard.img
-rw-r--r-- 1 root root 7948206080 Aug 28 10:04 sdcard.img
- if - input file or device
of - output file or device
bs - block size
Write Image with DD
To write the image file copied above to an sd card. Find the location of the Sd Card attached
Code: Select all
$ df -h | grep sd
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 19G 4.1G 14G 24% /
/dev/sda5 87G 21G 63G 25% /home
/dev/sdc2 3.0G 1.8G 1.1G 63% /media/mcon/rootfs
/dev/sdc1 56M 19M 38M 33% /media/mcon/3312-932FCode: Select all
$ sudo $ mount | grep /dev/sd
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
/dev/sda5 on /home type ext4 (rw)
/dev/sdb1 on /home/mcon/Storage type ext4 (rw,nosuid,nodev,_netdev)
/dev/sdd1 on /media/mcon/A9E7-0ECD type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks2)
/dev/sdc2 on /media/mcon/rootfs type ext4 (rw,nosuid,nodev,uhelper=udisks2)
/dev/sdc1 on /media/mcon/3312-932F type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks2)Code: Select all
$ sudo umount /dev/sdx1
$ sudo umount /dev/sdx2
$ sudo dd if=sdcard.img of=/dev/sdx bs=1024Quicker or Putting a regular 4GB image on 4+ Gb Sd Card
If the SDCard is bigger than the partitions then copying the whole card is a waste of time and HDD space. Below I will show you how to copy just what is needed.
Copy the MBR and Partitions
The MBR is stored in the the first 512 bytes of the disk. It consist of 3 parts:
- The first 446 bytes contain the boot loader.
The next 64 bytes contain the partition table (4 entries of 16 bytes each, one entry for each primary partition).
The last 2 bytes contain an identifier
Code: Select all
$ sudo dd if=/dev/sdc of=mbr.img bs=512 count=1Code: Select all
$ sudo dd if=mbr.img of=/dev/sdcCode: Select all
$ sudo dd if=mbr.img of=/dev/sdc bs=446 count=1Code: Select all
$ sudo dd if=mbr.img of=/dev/sdc bs=1 skip=446 count=64Code: Select all
$ sudo dd if=sdcard.img of=just-mbr.img bs=512 count=1DD Copy just the partitions on the SD Card.
Code: Select all
$ sudo df -T
...
/dev/sdc2 3.0G 1.8G 1.1G 63% /media/mcon/rootfs
/dev/sdc1 56M 19M 38M 33% /media/mcon/3312-932F
...
$ sudo dd if=/dev/sdc1 of=partition1.img bs=1024
$ sudo dd if=/dev/sdc2 of=partition2.img bs=1024
$ ls -lrt
total 3203080
-rw-r--r-- 1 root root 512 Aug 28 13:23 mbr.img
-rw-r--r-- 1 root root 58720256 Aug 28 13:24 partition1.img
-rw-r--r-- 1 root root 3221225472 Aug 28 13:27 partition2.imgThis is dangerous. You must be certain that the MBR image with the Partition Table matches that of the partitions you are going to put into them otherwise the data will be corrupt on the Sd Card.
Step 1 - Restore the MBR
First find the location of the Sd Card then restore.
Code: Select all
$ sudo dd if=mbr.img of=/dev/sdc
Code: Select all
$ sudo dd if=partition1.img of=/dev/sdc1 bs=1024
$ sudo dd if=partition2.img of=/dev/sdc2 bs=1024