Showing posts with label dd. Show all posts
Showing posts with label dd. Show all posts

Tuesday, 15 January 2013

How to Create a File of a Particular Size in UNIX or Linux

I needed a file with a size of 512 bytes for an Oracle test. I created it as follows:

UBUNTU > dd if=/dev/zero of=test1 bs=1 count=512
512+0 records in
512+0 records out
512 bytes (512 B) copied, 0.0140867 s, 36.3 kB/s
UBUNTU > ls -l test1
-rw-rw-r-- 1 andrew andrew 512 Aug 11 22:34 test1
UBUNTU >

To create a file with a size of 1000 bytes, you only have to change count=512 to count=1000:

UBUNTU > dd if=/dev/zero of=test2 bs=1 count=1000
1000+0 records in
1000+0 records out
1000 bytes (1.0 kB) copied, 0.0174102 s, 57.4 kB/s
UBUNTU > ls -l test2
-rw-rw-r-- 1 andrew andrew 1000 Aug 11 22:35 test2
UBUNTU >

Wednesday, 9 January 2013

Disk Speed

You can use the following command to see the speed of a hard disk: 

UBUNTU > time dd if=/dev/zero of=large_file \
> bs=4096 count=2000000
2000000+0 records in
2000000+0 records out
8192000000 bytes (8.2 GB) copied, 192.95 s, 42.5 MB/s

real 3m13.102s
user 0m6.148s
sys 1m29.718s
UBUNTU >