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

Creation of empty files [was: Useful use of dd]



On 7/2/21 11:51 AM, Kushal Kumaran wrote:
On Fri, Jul 02 2021 at 01:26:23 PM, Teemu Likonen <tlikonen@iki.fi> 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


2021-07-02 14:20:47 dpchrist@dipsy ~/sandbox/dd
$ dd of=dd-sparse bs=1M seek=5 count=0
0+0 records in
0+0 records out
0 bytes copied, 6.9482e-05 s, 0.0 kB/s

2021-07-02 14:21:16 dpchrist@dipsy ~/sandbox/dd
$ ll dd-sparse
-rw-r--r-- 1 dpchrist dpchrist 5242880 2021-07-02 14:21:16 dd-sparse

2021-07-02 14:21:40 dpchrist@dipsy ~/sandbox/dd
$ du --bytes dd-sparse
5242880	dd-sparse


There's

     $ truncate --size 5k testfile

for this purpose.


2021-07-02 14:23:34 dpchrist@dipsy ~/sandbox/dd
$ time truncate --size 5M truncate-sparse

real	0m0.002s
user	0m0.002s
sys	0m0.001s

2021-07-02 14:24:25 dpchrist@dipsy ~/sandbox/dd
$ ll truncate-sparse
-rw-r--r-- 1 dpchrist dpchrist 5242880 2021-07-02 14:24:25 truncate-sparse

2021-07-02 14:24:30 dpchrist@dipsy ~/sandbox/dd
$ du --bytes truncate-sparse
5242880	truncate-sparse


I expected sparse files, but du(1) does not indicate such (?).


Comments?


David


Reply to: