Analysis of dd command under Android shell

2020/04/15 12:52
Reading 1.7K

1、 Preface

During the recent test, the minor editor encountered a scenario where the storage space of the Android phone needed to be constructed was insufficient, and it also needed to cover and verify various models. However, it was too tedious to copy a single large file to the test machine. The minor editor found that the dd command under Linux could help the minor editor to complete this task, Just take this opportunity to share some usage of dd command under Android shell:

2、 Dd command introduction

Dd is the next very useful command in Linux, which is used to read, convert and output data;  
The dd command is also supported under the Android shell!  
Common command parameters supported in the Android shell are as follows:
    1. If=file name: enter a file name, that is, specify the source file.  
/Dev/zero is mainly used to create an empty file of specified length for initialization. Generally, if parameter value will be set to this item when you need to create an empty file!
    2. Of=file name: output file name, that is, specify the destination file.  
    3. Ibs=bytes: read bytes at a time, that is, specify a block size as bytes.  
Obs=bytes: output bytes at a time, that is, specify a block size as bytes.  
Bs=bytes: simultaneously set the read in/output block size to bytes.  
    4. Count=blocks: only blocks are copied, and the block size is equal to the number of bytes specified by ibs.

3、 Operation example

1. Generate a 10M empty file in the mobile phone/mnt/sdcard/directory

 adb shell dd if = /dev/ zero of = /mnt/ sdcard/yyybigfile bs= ten million four hundred and eighty-five thousand seven hundred and sixty count= one

Note: bs does not support writing by using units (for example: bs=10M), which is different from dd command in Linux system

2. Generate a large file in the phone/mnt/sdcard/directory to fill the entire phone storage space

 adb shell dd if = /dev/ zero of = /mnt/ sdcard/yyybigfile bs= four billion two hundred and ninety-four million nine hundred and sixty-seven thousand two hundred and ninety-five

Note: bs=4294967295 (about 4GB) is the maximum read in/output block size under the mobile phone, which can shorten the filling time of large files

3. Package the yysdk file in the phone/mnt/sdcard/directory and compress it with gzip

 adb shell “dd if = /mnt/sdcard /yysdk | gzip > /mnt /sdcard/yyybigfile .gz”

Note: It is more convenient to copy the folder under the phone to the local after compression

4、 Summary

Of course, the use scenarios of dd command in the Linux environment are not limited to these. Interested partners can learn about them. In future work, you may also encounter similar problems, such as whether the files and pictures are downloaded normally under abnormal conditions (insufficient local space), and whether there are abnormal prompts. I hope this article can give you some help and reference.


This article is shared from the WeChat official account Sogou QA.
In case of infringement, please contact support@oschina.cn Delete.
Participation in this article“ OSC Source Innovation Plan ”, welcome you to join us and share with us.

Expand to read the full text
Loading
Click to lead the topic 📣 Post and join the discussion 🔥
Reward
zero comment
zero Collection
zero fabulous
 Back to top
Top