User Tools

Site Tools


how_to_make_a_sd_image_from_sd_bootable_os

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

how_to_make_a_sd_image_from_sd_bootable_os [2014/03/13 13:31]
sam created
how_to_make_a_sd_image_from_sd_bootable_os [2014/03/13 14:22] (current)
sam
Line 1: Line 1:
 ====== How To Make A SD Image From SD Bootable OS ====== ====== How To Make A SD Image From SD Bootable OS ======
 +
 +<WRAP noprint><​WRAP left box 60%>
 +//__About this Article__//
 +  * **Author**: sam --- sam@cubietech.com --- 2014/03/13 01:33
 +  * **Copyrights**:​ [[http://​creativecommons.org/​licenses/​by-sa/​3.0/​|CC Attribution-Share Alike 3.0 Unported]]
 +  * **Contributors**:​ [[http://​cubieboard.org/​|Cubieboard Community]] : ...
 +</​WRAP></​WRAP>​
 +
 +===== Abstract =====  ​
 +we may want to backup our SD bootable OS which have installed many application software. We can make SD Bootable OS into a SD card image.here is guide for you.This guide is for Linux platform only.
 +  
 +  
 +===== Prerequisites =====  ​
 +   * Any Linux environment,​​ we want fdisk, dd, tar,  commands
 +   * An SD Card which must have installed a OS 
 +  ​
 +  
 +==== Steps:​====  ​
 +
 +
 +
 +==== (1) Unpacking you  SD card OS.  ====
 +==== 1.Unpacking the first partition (including script.bin uImag bootscr ) ====
 +  $sudo umount /media/*
 +  $sudo mount /dev/sdb1 /mnt    ​
 +  $sudo tar -cp * |sudo gzip -9 > ~/​bootfs.tar.gz
 +  $sudo umount /mnt
 +
 +
 +==== 2.Unpacking the second partion (file systerm) ====
 +
 +   $sudo mount /dev/sdb2 /mnt
 +   $sudo tar -cp * |sudo gzip -9 > ~/​rootfs.tar.gz
 +
 +
 +==== (2) Begining making imgae ====
 +==== 1.Create a empty image and write uboot in it ====
 +
 +  $ mkdir WORK_DIR
 +  $cd $WORK_DIR  ​
 +  //creating empty image , this space is 2.5G,you can change by yourself
 +  $sudo dd if=/​dev/​zero of=disk.img count=5000000 ​   ​
 +  //​associating /dev/loop0 with the image
 +  $sudo losetup /dev/loop0 disk.img ​              
 +  $sudo dd if=/​dev/​zero of=/​dev/​loop0 bs=1k count=1024 ​  
 +  $sudo dd if=u-boot-sunxi-with-spl.bin of=/​dev/​loop0 bs=1024 seek=8 ​ //write uboot in image
 +  ​
 +  ​
 +==== 2.Partitioning====
 +
 +  $sudo fdisk /dev/loop0
 +
 +Using the fdisk command to create 2 partitions on the SD Card, e.g.
 +  * 1st partitions start from 2048 sectors, 64MB in size
 +  * 2nd partitions just keep it all default
 +
 +Show bellow
 +  ​
 +  Device Boot            Start         ​End ​     Blocks ​  ​Id ​ System
 +  /​dev/​loop0p1 ​           2048      133119 ​      ​65536 ​  ​83 ​ Linux
 +  /​dev/​loop0p2 ​         133120 ​    ​4999999 ​    ​2433440 ​  ​83 ​ Linu
 +
 +Also we recommend you to look at [[http://​linux-sunxi.org/​Bootable_SD_card |Bootable_SD_card]]
 +
 +
 +
 +  
 +==== 3.Mounting the partition and move OS to image ====
 +
 +  $cd $WORK_DIR
 +  associateing /dev/loop0 with image again 
 +  $sudo losetup -d /dev/loop0 && sudo losetup /dev/loop0 disk.img ​
 +  //​associateing ​ /dev/loop1 with the first partition of /​dev/​loop0,​1048576=512*2048)  ​
 +  $sudo losetup -o 1048576 /dev/loop1 /​dev/​loop0 ​           ​
 +  //format the first partition
 +  $sudo mkfs.vfat /​dev/​loop1  ​
 +  //format the second partitions
 +  $sudo mkfs.ext4 /​dev/​loop2 ​  
 +  $sudo mount /dev/loop1 /mnt   
 +  //​decompressing bootfs.tar.gz to the first partition
 +  $sudo tar -zxvf ~/​bootfs.tar.gz -C /​mnt  ​
 +  $sudo umount /mnt
 +  $sudo mount /dev/loop2 /​mnt  ​
 +  //​decompressing rootfs.tar.gz to second partition
 +  $sudo tar -zxvf ~/​rootfs.tar.gz -C /mnt 
 +  $sync && umount /mnt
 +  //cancel associating
 +  $losetup -d /​dev/​loop2  ​
 +  //cancel associating
 +  $losetup -d /​dev/​loop1 ​  
 +  //cancel associating
 +  $losetup -d  /​dev/​loop0  ​
 +
 +
 +
  
  
-<WRAP noprint> 
-{{tag>​Cubieboard Cubietruck}} 
-</​WRAP>​ 
how_to_make_a_sd_image_from_sd_bootable_os.1394688660.txt.gz · Last modified: 2014/03/13 13:31 by sam