Cloning an SD card

My phone has been acting up, but the problem seems to go away when I pull the SD card. In addition to data, I have several apps stored on it. Can I just plug it into a card reader, ctrl-A/copy to my Win 7 HDD, then put in a blank SD card and copy back? Or will I end up with missed files/blocks or other hiccups? Google search results have been inconsistent (some say it’s fine; others say you need a clone program).
The phone is a Samsung Galaxy S, if it makes a difference.

This is just an experienced guess but, if your computer can read it, you should just be able to copy the folders and files to a new flash memory card. There isn’t anything that I know of that is special about reading or writing to one for a Samsung. It is worth a try because it is so easy.

I don’t know much about that phone but I’m gonna guess that you can’t do what you propose, because the card needs to have a specific filesystem on it. What are you going to format the blank sd card with from your windows PC? NTFS? I don’t think that’s going to work, I’m pretty sure android uses linux filesystems (ext4?).

Not only that, I tried to do a little googling and it appears that the Galaxy S even has a specific partition layout without one partition using something called RFS.

I suppose you can just try it tho, to see what happens. Can’t hurt anything.

Are you comfortable with linux? Cloning the card would be pretty easy in linux.

No progress yet. I tried to use Acronis’ clone tool, but couldn’t get around a “failed to read the snapshot manager volume” error.

I have Linux (Ubuntu 12), whether I’m comfortable or not is a different story. It’s a virtual machine on a Window’s 7 host (Virtualbox). I can see the two cards, and Googling suggests the DD command is the way to go, but I’ve yet to find a good, easy-to-follow explanation of how to use it—or whether it is the best tool. I tried searching in the repository for ‘clone’, but returns were filled with clones of games.

Any Linux-based advice? Other options?

You bet.

I assume you can plug in two sd cards at once? Start up gparted(its in the software center if you need to install it).

It will show all your disks, including the sd cards. Select the failing one using the labeled button near the upper right corner. Mine for example is called /dev/sdd and marked at just under 4 GB. Its a grey button, but that depends on your system theme. You can see what disks you have, then plug the sd card in, and select refresh to be certain of its name.

Click the coloured bar that stretches across the window, which shows its ratio of used verse remaining space(mine is labeled /dev/sdd1). Or you can select it with the text below that bar, if you have several.

Now you can either right click and select copy, or control-c.

Next, using that drive selection button again, find the new sd card. It should be equal in size or larger. select the partition by clicking the bar, and paste in your old contents. You might get some straight forward warnings at this point. You might have to delete its partition for instance.

Do a sanity check. Make sure you are doing the right thing to the right disks. If all is well, click the apply button. Wait for it to copy.

Its pretty safe until you press the apply button.

If I am at all unclear, ask questions before proceeding.

dd would do it.

dd does a block for block copy - and ignores the file system or anything else. Just copies bytes across to the raw underlying device.

It has somewhat arcane command line options, confusingly doesn’t obey normal unix conventions. You can check the man page, but it should be easy enough.

Copy the contents of the card to a file. Remove the old card, put new one in, copy the file to the card.

#  dd if=/dev/xxx of=~/sd_card_file  bs=1MB
#  dd if=~/sd_card_file of=/dev/xxx  bs=1MB

of= means output file
if= means input file
/dev/xxx is the device name of the SD card
bs= is the block size of the transfer. This is optional, but if you make it say 1MB, the copy will go significantly faster, as the system will do the operations in larger chunks.

The temporary file is ~/sd_card_file - call it what you like. It will be very big - so it needs to go somewhere that can hold it.

The only variable is what your machines calls the sd card device. It will something in /dev, typically called sdletter
To find out what your machine calls the SD card, stick it in the slot, then use the mount command to see where it found it.

Something like:

# mount
... stuff about proc, none, mapper ....
/dev/sda0   on  /boot type ext3 (rw)
/dev/sdb   on  /where_the_sd_card_appears

You want the /dev/sdX name - that is the name of the actual device that represents the sd card. You must be absolutely certain you get the name right. Getting this wrong when you do the copy to the card could be disastrous. So double check. When you do the copy from the card you will get a file that is the same size as the card’s maximum contents, not just the size of the files stored on the card. So big. If you do get a file of the expected size you at least have conformation that the device entry you copied from was the right one.

ETA, ninja’ed a bit. It is 1am here, so I’m sure FuzzyOgre can set you straight. I’m off to do zzzzzs.

Well, my exposure to Android phones (owning and hacking two in as many years) and general scuttlebutt on various Android modding fora tell me that Android removable SD cards are formatted VFAT by default, so Windows would just treat it like an SD card from your camera (or a really big really fast floppy disk).

Ah, OS partitioning of internal MMC is different. Android phone manufacturers often go to great lengths to make the internal partitions (A) linux-friendly, or (B) paranoia secure (for DRM security, and to make network providers happy). But you can’t get at any of that through Windows, and you certainly can’t take it physically out of the phone to plug it into another device, so that’s OK.

True, but even Windows XP can do a decent job cloning an SD card in the expected VFAT format. I have actually done a clone and transfer from a smaller SD to a larger one using a straightforward file copy process (copy one sdcard to Windows directory, switch sdcard, copy back from directory). Worked fine.

I’m missing something.

First, Gparted would display everything fine, but the right-click copy option was greyed out on all drives (virtual drive and the two SD cards). So I tried the DD option, but the output/input file was too small. Here’s a c/p from the terminal window:

vm@vm-VirtualBox:~$ sudo dd if=/dev/sdf1 of=/home/vm/TEMP/14card bs=1MB
[sudo] password for vm: 
dd: reading `/dev/sdf1': Input/output error
111+1 records in
111+1 records out
111960064 bytes (112 MB) copied, 30.6569 s, 3.7 MB/s
vm@vm-VirtualBox:~$ sudo dd if=/home/vm/TEMP/14card of=/dev/sdd1 bs=1MB
111+1 records in
111+1 records out
111960064 bytes (112 MB) copied, 7.76992 s, 14.4 MB/s

I even verified it by browsing to the directory; the output file was only 112 MB, not the 12 GB that is actually on the card.

ETA: I was using the path I saw in Gparted, which was SDletternumber. Trying it without the number…

Hmmm…“dd if=/dev/sdf of=/home/vm/TEMP/14card2 bs=1MB” didn’t work either-I ended up with a 113 MB file this time. :confused:

That “input/output error” shows that the source card is damaged somehow, and that is causing your problems. You can tell dd to ignore bad blocks by adding “conv=sync,noerror” to the command line.

dd if=/dev/sdf of=/home/vm/TEMP/14card2 bs=1k conv=sync,noerror

Note that I’m specifying 1k block size here instead of 1MB, this way you keep as much data as possible when it has to skip a block. It’ll be a bit slower this way however.

The “if” should be /dev/sdf, the entire disk. /dev/sdf1 will be only the first partition.

Oh hmm, good point then. Well, I did say he could just give it a try and see :stuck_out_tongue:

I’m not sure if I follow this point, what would be the harm of just cloning the entire card, including this partition? He’s using the newly cloned card in the same device (he wants to transfer it from the old card which is failing).

So it ran for a while, scrolling a changing:

dd: reading '/dev/sdf': Input/output error
110332+14914444 records in 
15022776+0 records out
15383322624 bytes (15 GB) copied, 4531.5 s, 3.4 MB/s

The 110332 seems to have stayed static. The 14914444 and the 15022776 seem to have been incrementing by one. The bytes copied are incrementing by 1024, which makes sense. The other numbers, not so much.

I then put the file onto the 32GB card using:

vm@vm-VirtualBox:~$ sudo dd if=/home/vm/TEMP/14card5 of=/dev/sdh1 bs=1MB conv=sync,noerror
[sudo] password for vm: 
15997+1 records in
15998+0 records out
15998000000 bytes (16 GB) copied, 5033.08 s, 3.2 MB/s

I changed the bs= back to 1MB thinking that since I won’t need to skip a block, I could use the larger increment. I put it on sdh1 hoping to put it all in the first (only?) partition. When I experimented, I’d ended up with a not-completely functional 16GB partition and unallocated space. Looking at the drive with Gparted, I’m a bit pessimistic. It’s not in accord with what I just saw in terminal. It said (among other things)

 Used: 9.19 MiB
Unused: 29.71 GiB
Warning: init H: non DOS media. Cannot initialize 'H:' mlabel:Cannot initialize drive 

Looking at its files shows a lot of gobbledegook. Trying again without the partition number, seeing if that helps. Whether or not I get the clone thing to work out, I’m still curious as to what resulted in the corruption. The 14GB card still reads fine.

Another tack I could take: I’ve successfully copied all the pictures/video that were on the phone, the only truly irreplaceable data. The reason I was hoping to clone this was to avoid having to reinstall all the apps and preferences I’d move to the card. Is there an easy way of rebuilding the SD card from within the Android system? That is, if cloning a drive isn’t as easy as I thought it would be (particularly if the source drive has problems) is there any automated process to rebuilding things?

Ran it again, copying to the SD card without adding the partition:

But Gparted came back with two partitions (one 14 GB; the rest unallocated). Further, it had a new warning “ Unable to read the contents of the file system! Because of this some operations may be unavailable.”

Putting the card in my phone, the photos weren’t in the gallery and apps were coming back as uninstalled.

However, plugging in a USB cable and looking at the contents did show a full set of files, including the pictures.


You definitely can’t take an image of a disk and try to stuff it into a partition. Disk to disk, or partition to partition only.

Try going with the bs=1k on your write as well. You’re right that it shouldn’t matter tho. Otherwise I don’t know what could be wrong (unless you have many bad blocks, esp in that other partition – that would do it too).

Too late for edit: I also note that your bytes when you read the old card doesn’t match the bytes you wrote when imaging the new one. So that’s not going to work either.