1. You want that $100.00 in your pocket or an Amazon Fire TV don't you? Well here's the deal. With our new updated look we are in desperate need of an updated logo. The 'old' one has certainly served us well, but it's time. Find all the details here: bit.ly/1q0k6Wa
  2. DroidForums.net is currently undergoing a major software upgrade. If you are experiencing any problems logging in please: Contact Us

Backup sd partition using dd

Discussion in 'Galaxy Nexus Development' started by Shivels, May 20, 2012.

  1. Shivels
    Offline

    Shivels New Member

    Joined:
    Mar 20, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Hi guys and gals,

    I just spent the better part of today figuring out how to create a block by block backup of the /sdcard partition. Long story short, I reverted my phone back to stock and did not know it was going to erase my /sdcard partition. So I wanted to create a backup of the /sdcard partition to run through foremost and scalpel to see if I could recover my pictures. Here are the steps to create the backup:

    Prerequisites: You must be rooted and have Android Terminal Emulator installed. I suggest grabbing a good beer as well.

    1. Make or buy an OTG cable. If you are going to make your own cable, do not buy a RocketFish cable because these cables do not have 5 pins going into the micro USB end ( I learned this the hard way).

    2. Install a kernel which supports mounting NTFS drives. I used Samurai Akira's kernel. The reason for using NTFS is because FAT32 has a 4GBish single file limit and our GNex /sdcard partition is 28GBs.

    3. Now this is the tricky part. The stock battery only last long enough to get 20GB of the partition. So I decided to use a power supply to simulate the battery. In order to do this, you will need to solder wires to the 2nd and 4th pin on the bettery compartment. If you are looking at the Nexus with its battery removed and the sim crad slot is on the left, the 1st pin is the leftmost pin. The 2nd pin is the negative lead and the 4th pin is the positive lead. I used a voltage of 3.8471 to power the phone. A voltage of 4.238 caused the phones screen to flicker and a voltage of 3.701 caused the phone tell me to "Connect your Charger" and then the phone shut down.

    4. Plug in the usb drive using the OTG cable.

    5. Run the following commands in the Android Terminal Emulator:

    1. First we need root privileges:
    $ su

    2. Now we need to create a folder on the /sdcard partition:
    # mkdir /sdcard/usbstick

    3. Now we need to find out what the external drive is called:
    # cat /proc/partitions

    4. Now you should see a list of your partitions. My external drive was always either sda5 or sdb5. Now we need to
    mount the drive into the usbstick folder:
    # ntfs-3g /dev/block/sda5 /sdcard/usbstick

    5. Now let's create the dd image of the partition:
    # dd=/dev/block/mmcblk0p12 of=/sdcard/usbstick/sdbackup.img

    5. Alright now grab a second (or first) beer and come back in about 6 hours and the backup will be complete. If you want to try and recover data I suggest using foremost or scapel. Anyways, good luck and have fun.

    Cheers,
    Shivels
    Last edited: May 20, 2012
  2. brymck
    Offline

    brymck New Member

    Joined:
    Jun 25, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Sorry about the gravedig, but this thread was extremely helpful to me...however there were a few incorrect things in here so I wanted to try to make it 100% for anyone else who tries this in the future.

    1. You definitely will not be able to make a full backup with even the extended battery (only got 17 GB img file with that)
    2. Pay attention to the device your USB stick is. Mine was consistently /dev/block/sda1
    3. In order to use ntfs-3g, you must install the module first. I installed Samurai Akira's kernel to be able to mount NTFS (as leankernel does not support NTFS afaik), but ntfs-3g is a separate module. Instructions from here helped GREATLY with that, specifically copying to /system/bin and chmod'ing the file.
    4. Proper command for making the dd backup is - # dd if=/dev/block/mmcblk0p12 of=/sdcard/usbstick/sdbackup.img (small typo in your instructions)
    5. You may have to play around with the voltage to get the phone to boot and stay on. At first, 3.8v worked to boot the phone, but when I started mounting the USB stick, it reset the phone and wouldn't recognize the USB drive. I needed to reboot a few times at varying voltages, finally set it to 3.85 and it recognized the drive and stayed on for the full 6 or 7 hours to create the img file.
    6. A desoldering iron will be your best friend...solder inside the bend of those pins is tough as hell to get out without one.

    I'm having issues recovering files from /sdcard/dcim, but that's another story that I think has to do with scalpel more than the image file I created.
Search tags for this page
android backup /dev/block
,

android dd backup

,
android dd partition mount
,
android partition dd
,
android sdcard dd
,
android terminal dd
,

backup android partitions

,
backup sd card 2nd partition
,

dd android backup

,
dd android partitions
,
dd if=/dev/block/mmcblk0p21 of=/sdcard/backup-recovery.img
,
dd sdcard sdext
,
how to backup partitioned sd card
,

http ://www.droidforums.net/forum/galaxy-nexus-development/2

,
permission denied sd card dd