[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Useful use of dd



On 7/2/21 4:25 AM, Teemu Likonen wrote:
* 2021-07-02 12:52:53+0200, Thomas Schmitt wrote:

Teemu Likonen wrote:
For this new subject I will add another use: quickly create empty file
of specific size, for example 5 * 1024 bytes:
    $ dd of=empty obs=1024 seek=5 count=0

Not to forget creation of sparse files with few disk consumption.

My example above already does that.

     $ dd of=empty obs=100G seek=1 count=0
     $ ls -gGlhs empty
     0 -rw-r--r-- 1 100G 2021-07-02 14:21:18 empty

Zero blocks actually allocated, so far.


Thanks for the clue regarding viewing sparse files:

2021-07-02 14:39:52 dpchrist@dipsy ~/sandbox/dd
$ dd if=/dev/zero of=zero bs=1M count=5
5+0 records in
5+0 records out
5242880 bytes (5.2 MB, 5.0 MiB) copied, 0.0125097 s, 419 MB/s

2021-07-02 14:41:57 dpchrist@dipsy ~/sandbox/dd
$ dd if=/dev/urandom of=urandom bs=1M count=5
5+0 records in
5+0 records out
5242880 bytes (5.2 MB, 5.0 MiB) copied, 0.026771 s, 196 MB/s

2021-07-02 14:44:11 dpchrist@dipsy ~/sandbox/dd
$ ls -gGls --block-size=1 [a-z]*
      0 -rw-r--r-- 1 5242880 Jul  2 14:21 dd-sparse
      0 -rw-r--r-- 1 5242880 Jul  2 14:24 truncate-sparse
5242880 -rw-r--r-- 1 5242880 Jul  2 14:42 urandom
5242880 -rw-r--r-- 1 5242880 Jul  2 14:40 zero


David


Reply to: