3

I have a Mac and want to transfer about 30 GB of data to a larger SD card for use with a new Android phone.

The phone in question is a Galaxy Stratosphere II.

There doesn't seem to be a straightforward way to do this.

So far I have tried

  • Copying using Android File Transfer, with the phone connected via USB. This seemed to work, running at about 10MB/s, but didn't retain the file timestamps, which is unacceptable to me. Since the app seems to only provide access via a drag-and-drop interface, I don't think there's a way to use it to copy files while retaining timestamps.
  • Copying using scp -pr via SSHDroid running on the phone, via another wifi network. This also worked, retaining timestamp information, but was painfully slow (<1 MB/s).
  • Plugging the SDCard into my MacBook Pro. This doesn't work: it is not a recognized filesystem. I tried using a third-party SD Card reader also, with the same result.
  • Using adb push to copy files over a USB connection. This also doesn't work, even when I add /. to the end as suggested by this answer.

simple-mtpfs might be an option, but the given build instructions reference non-existent executables.

Alt Mounter also sounds like it does what I want, but is indicated as being "***EXTREMELY BETA***" and thus is not something I'd prefer to trust with my important files.

When I upgraded a different SD card, I experimented with copying files to the SD card in a connected reader via a Linux VM. This seemed to work but would mysteriously cut out after copying a fraction of the data. I think that time I ended up just using scp and leaving it to run for a day or two.

I'm continuing to dig into this, but perhaps someone can save me some time. Is there an easy way to do this?

1 Answer 1

1

Both OSX and Android provide basic POSIX utilities, so I ended up going old school on this one:

$ tar czv "$PATH_TO_ORIGINAL_SDCARD" | split -b 2048m - sdcard-

This command creates 2GB-sized chunks of an archive of the sdcard contents, with names like sdcard-aa, sdcard-ab, and so on. The 2GB split is necessary because Android File Transfer can only copy files of 4GB or less in size.

Then I copied the files over to the phone using (surprise!) Android File Transfer and recombined and unarchived them in Terminal Emulator* using this command:

$ cat sdcard-* | tar xzv

*: it was actually a bit more complicated than this. Gory details:

So actually Android doesn't really come with basic POSIX utilities, or at least if it does, they are not readily available to the Terminal Emulator app.

I thought that it did because SSHDroid provides these utilities via busybox. I suspect that Android doesn't allow processes to execute files that their user does not own; this would explain why there is no app available that installs busybox for non-rooted phones.

busybox is a utility that can execute any of a large number of POSIX commands, depending on what name it is called with. People arrange for it to be called with names other than busybox by creating symbolic links to it with names like, for example, tar.

However, it turns out that it is possible to install busybox in your own Terminal Emulator app home directory. So that's what I did. Steps:

  • Grab the file busybox-android from the eponymous github project.
  • Get it onto your device (see above!). Put it somewhere public that you'll have access to from a Terminal Emulator session. Just call it busybox.
  • Start a Terminal Emulator session. Make a directory ~/bin and copy the busybox file from the public place you put it to that new directory.
    • Since the cp command is not available in a Terminal Emulator session (!) do it this way: cat $PATH_TO_BUSYBOX/busybox > ~/bin/busybox
  • Now cd ~/bin and create a symbolic link: ln -s busybox tar.
  • Now you should be able to cd /storage/extSdCard/ and concatenate and extract the contents of your archive files to it using cat $PATH_TO_ARCHIVE/sdcard-* | ~/bin/tar xzv.
  • It will be extracted with whatever prefix directories were the path to the sdcard contents when you created the archive set, e.g. /Volumes/oldphone/. So now move everything from that subdirectory (we'll call it $OLD_SDCARD_CONTENTS) to the root of your current SD card.
    • sh (the shell used by Terminal Emulator) doesn't seem to have any way to select all the hidden files in a directory, so I ran bash to do this. Under bash, mv $PATH_TO_FILES/.[^.]* $DEST will move all hidden files. Remember that you have to access bash via a symlink to busybox, or just do this part via ssh (which is actually what I did).

Whew! Glad that's over. I really hope I don't end up accepting this answer; there should be a much easier way to do all of this.

Of course, I could have just untarred the archive in an ssh session from my computer, but this would have required me to run my computer for however long it was going to take. Plus, like, of course busybox should be available in Terminal Emulator.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .