LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Create a Large file in Linux (https://www.linuxquestions.org/questions/linux-newbie-8/create-a-large-file-in-linux-4175543067/)

linuxmantra 05-19-2015 07:10 PM

Create a Large file in Linux
 
I want to create a large file size lets says 600G. I used command
# fallocate -l 600G file01
Although I got the file of my size but the things is, there is no data. I want to create a file with size 600G and random data in it.

Any suggestion?

goumba 05-19-2015 08:02 PM

This is going to take a while, but something like this should work for you:

Code:

dd if=/dev/random of=filename bs=1M count=6000
You could also use bs=1G count=6 but you may get an error about not enough memory on such an operation.

syg00 05-19-2015 08:07 PM

Quote:

Originally Posted by goumba (Post 5364785)
This is going to take a while

This may qualify as the understatement of the day so far .... :p

linuxmantra 05-19-2015 08:09 PM

Quote:

Originally Posted by goumba (Post 5364785)
This is going to take a while, but something like this should work for you:

Code:

dd if=/dev/random of=filename bs=1M count=6000
You could also use bs=1G count=6 but you may get an error about not enough memory on such an operation.

Thanks, Yes, I was testing 'dd' command.But, the thing is it is slow. My command was:
# dd dd if=/dev/urandom of=file01 bs=1024 count=2097152

Little confusion, which one to use /dev/random or /dev/urandom so that I don't have to wait long to populate my file.

syg00 05-19-2015 10:44 PM

As the manpag says, urandom will be quicker, but not as random. May not matter.
There is also frandom, but probably isn't available in your distro, so you'd have to compile and insmod it.

For junk (rather than truly random data) to fill a file like that, I generate a small random file (10 Meg say), and merely copy it multiple times to the destination file. Much quicker, but not close to random.


All times are GMT -5. The time now is 07:36 PM.