Fill up disk space in android device
Asked Answered
T

2

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
Tectonics answered 15/7, 2014 at 11:23 Comment(3)
Have you tried drastically increasing the block size?Baritone
@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.Tectonics
adb shell dd if=/dev/zero of=/sdcard/deleteme bs=100m count=1024Azide
N
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

Nidus answered 23/7, 2014 at 6:36 Comment(3)
another way of filling up the device is to run 'cat file1 >> file1' which on Android loops until you are out of disk space :)Hypno
How to clear after the job done?Azide
@nhoxbypass, to remove file: "adb shell" cd to your directory with file and "rm myfile.dat"Nidus
E
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.

Equiangular answered 23/8, 2014 at 10:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.