Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I copy the contentsof data/ to sdcard/ without using adb?

Tags:

android

Hi I need to copy/move the contents of data/tombstones to sdcard/tombstones

I'm using the command below:

mv data/tombstones /sdcard/tombstones

"failed on 'tombstones' - Cross-device link"

but I'm getting above error.

like image 344
Shrikant Tudavekar Avatar asked Aug 24 '10 11:08

Shrikant Tudavekar


1 Answers

You have a SANE VERSION of the mv command

paraphrasing a few bits from lbcoder from xda and darkxuser from androidforums

"failed on 'tombstones' - Cross-device link"

It means that you can't create a hard link on one device (filesystem) that refers to a file on a different filesystem.

This is an age-old unix thing. You can NOT move a file across a filesystem using most implementations of mv. mv is not made to copy data from device to device, it simply changes a file's location within a partition. Since /data and /sdcard are different partitions, it's failing.

Consider yourself fortunate that you have a SANE VERSION of the mv command that doesn't try anyway -- some old versions will actually TRY to do this, which will result in a hard link that points to NOTHING, and the original data being INACCESSIBLE.

The mv command does NOT MOVE THE DATA!!! It moves the HARDLINK TO THE DATA.

If you want to move the file to a different filesystem, you need to use the "cp" command. Copy the file to create a SECOND COPY of it on a different filesystem, and then DELETE the OLD one with the "rm" command.

A simple move command:

#!/bin/bash
dd if="$1" of="$2"
rm -f "$1"

You will note that the "cp" command returns true or false depending on the successful completion of the copy, therefore the original will only be removed IF the file copied successfully.

OR

#!/bin/bash
cat data/tombstones > sdcard/tombstones
rm data/tombstones

These script can be copied into some place referenced by the PATH variable and set executable.


Different Interface

If you need a different interface from adb you may move files using the FileExplorer in DDMS View.

Side note:

You can move a file into a folder when:

  • You're root;
  • It is your app directory;
  • You've used chmod from adb or elsewhere to change permissions
like image 186
Dheeraj Bhaskar Avatar answered Oct 21 '22 12:10

Dheeraj Bhaskar