13

I want to fill my device disk space with any dump data as part of stress testing.

I tried writing bytes into a file in external storage; obviously larger & more spacious the disk is longer it will take to get filled. [approx half a minute for 1GB]

Can we do anything from adb shell in this case? I checked creating dump data using dd command:

dd if=/dev/zero of=/tmp/tempFiller.deleteMe bs=1024 count=$COUNT

which basically copies dump data to destination file Hence it also takes significant time. [approx 1 minute for 1GB]

Is there any faster approach? for a normal user / super user?

I also tried fallocate, truncate & mkfile commands in adb shell, but none of these commands are found even inside su. I guess these are bash commands & installing bash shell in Android device will require the device to be rooted.

fallocate -l 10G gentoo_root.img
truncate -s 10M output.file
mkfile 10240m 10Gigfile
Community
  • 1
  • 1
jQueen
  • 552
  • 1
  • 7
  • 16
  • Have you tried drastically increasing the block size? – Sky Kelsey Jul 23 '14 at 01:10
  • @SkyKelsey, yes I've tried in both approaches; when we write bytes in file programatically we need to take care about max size a bytearray can hold (Integer.MAX) & also the available heap to our app. In case of dd command as well if we try larger byte size at once, it doesn'e work; so maybe it also validates internally. – jQueen Jul 23 '14 at 04:37
  • `adb shell dd if=/dev/zero of=/sdcard/deleteme bs=100m count=1024` – nhoxbypass Aug 11 '22 at 11:26

2 Answers2

8

I tried same thing in past. My purpose was filling all memory on device. After experiments I found out that dd is the best way for writing big files. My best speed was when I used 1MB for block size. I used 100MB files in order to have ability to balance free space on device.

Writing 100MB file:

dd if=/dev/zero of=myfile.dat bs=1048576 count=100

Also for quick experiments I've used written free app FillMemory

0x8BADF00D
  • 7,138
  • 2
  • 41
  • 34
1

1GB in half a minute (30 seconds) is a write speed of over 30MB/s. Considering that the external storage on most Android devices these days is actually a Secure Digital flash card, that speed could very well be the maximum speed supported by either the card or the card interface of your device.

If using dd with a moderate block size (e.g. bs=1M) does not improve things, then chances are that you have just reached the limits of your current hardware.

thkala
  • 84,049
  • 23
  • 157
  • 201