How to Create a Fixed Huge Size File in Unix / Linux Using dd Command?

advertisements

_____________________________________________________________________________________________________________________

The Eucharistic Miracles of the World

dd if=/dev/zero of=dummyfile bs=26214400 count=1
1+0 records in
1+0 records out
26214400 bytes (26 MB) copied, 0.063799 seconds, 411 MB/s
$ ls -ltr

total 25632
-rw-r--r-- 1 oracle oinstall 26214400 Nov  3 11:42 dummyfile

Read from /dev/zero file will return the null characters as requested in the read operation. /dev/zero is a file similar to /dev/null

dd if=/dev/zero of=dummyfile bs=26214400 count=1
where 
if        : input file
of       : output file
bs       :bytes – By default value considered as bytes. Also you can specify in MB(M) or GB(G)
count  : number of input blocks is of size mentioned in bs parameter.

More command will display some blank lines.
$ more dummyfile


$ dd if=/dev/zero of=dummyfile bs=1024 count=1
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 7.3e-05 seconds, 14.0 MB/s
$ dd if=/dev/zero of=dummyfile1 bs=1024 count=1024
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 0.007779 seconds, 135 MB/s
$ ls -ltr
total 1032
-rw-r--r-- 1 oracle oinstall    1024 Nov  3 11:54 dummyfile
-rw-r--r-- 1 oracle oinstall 1048576 Nov  3 11:54 dummyfile1

Suppose if you wanted to create a 50 MB file you can use bs as 1M and count as 50. Which means filesize is bs x count

$ dd if=/dev/zero of=dummyfile1 bs=1M count=50
50+0 records in
50+0 records out
52428800 bytes (52 MB) copied, 0.14089 seconds, 372 MB/s
$ ls -ltr
total 51256
-rw-r--r-- 1 oracle oinstall 52428800 Nov  3 11:57 dummyfile1

_____________________________________________________________________________________________________________________

Website Stats

0 comments:

Post a Comment

Labels

Oracle (629) Script (86) General (77) Unix (47) Blog (23) Technology (19) gadget (6) games (6) Business (3) OCI (3) SQL* Loader (3) Datapump (2)
 

acehints.com Copyright 2011-23 All Rights Reserved | Site Map | Contact | Disclaimer