Linux / UNIX: Create Large 1GB Binary Image File With dd Command

1
1027

How do I create 1 GB or 10 GB image file instantly with dd command under UNIX / Linux / BSD operating systems using a shell prompt?

You can use dd command to create image files for network or file system testing. First, make sure you’ve sufficient disk space to create a image file using dd:

 

$ df -H
To create 1MB file (1024kb), enter:
$ dd if=/dev/zero of=test.img bs=1024 count=0 seek=1024
To create 10MB file , enter:
$ dd if=/dev/zero of=test.img bs=1024 count=0 seek=$[1024*10]
To create 100MB file , enter:
$ dd if=/dev/zero of=test.img bs=1024 count=0 seek=$[1024*100]
$ ls -lh test.img

To create 10GB, file:
$ dd if=/dev/zero of=10g.img bs=1000 count=0 seek=$[1000*1000*10]
Sample output:

0+0 records in
0+0 records out
0 bytes transferred in 0.000014 secs (0 bytes/sec)

Verify file size (note bs factor in original dd command):
$ ls -lh 10g
-rw-r–r– 1 root wheel 9.3G Jun 2 12:07 10g.img

Originally posted 2016-02-26 00:11:21.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here