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.