Creating file of arbitrary size in Solaris

We use command for testing purpose on FS. I created a file name called "file.500mb" where i need size of  500MB.
Solaris :
# mkfile 500M file.500mb
# du -sh file.500mb
 500M   file.500mb
bash-3.00# ls -l file.500mb
-rw------T   1 root     root     524288000 Feb 17 04:11 file.500mb

We can also do this in other way as below, which creates size of 512MB, we can change the counts/bs  depend upon requirement. changing BS will make faster

# dd if=/dev/zero of=/file1g count=500 bs=1024k
500+0 records in
500+0 records out
bash-3.00# du -sh /file1g
 500M   /file1g


Linux :

Mkfile command will not work, instead we use "dd" command  or /dev/urandom as below.


# head -c 1024m /dev/urandom > /fs1/file1g
# du -sh /fs1/file1g
1.1G    /fs1/file1g

# cat /dev/urandom /fs1/filename after some times, do ctrl+c to kill,

[OR]

# dd if=/dev/zero of=/fs1/file1g count=500 bs=2048k
500+0 records in
500+0 records out
1048576000 bytes (1.0 GB) copied, 26.3419 seconds, 39.8 MB/s
[root@linux1 admin]# du -sh /fs1/file1g
1001M   /fs1/file1g

No comments: