LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to create a large file (https://www.linuxquestions.org/questions/linux-software-2/how-to-create-a-large-file-558205/)

NewBudda 06-01-2007 02:14 AM

How to create a large file
 
Hi all,
I would like to create a file that takes up a lot of disc space on Debian. Say 5 GB or more. Is there a way that I can create such a file from nothing? The reason I am asking is this: I would like to artifically fill my server after reinstallation and then shred that file to overwrite any information that might be left in the difference between a clean install and the previous install with data.
If theres a command to create a from "nothing" please let me know...

theYinYeti 06-01-2007 02:28 AM

dd if=/dev/zero of=/path/to/bigfile count=10000000

Yves.

dasy2k1 06-01-2007 06:06 AM

try piping /dev/urandom to a file, not sure how you woudl stop it when you got to the right size tho

pixellany 06-01-2007 06:53 AM

Quote:

Originally Posted by dasy2k1
try piping /dev/urandom to a file, not sure how you woudl stop it when you got to the right size tho

dd is your friend

To use a pipe, you would have to do something like "cat /dev/urandom" I don't know if that's legal (and I am not about to try......;) )

syg00 06-01-2007 07:03 AM

Sure it is, but you wouldn't pipe it - use it instead of /dev/zero in dd.
Use a decent blocksize as well.

NewBudda 06-01-2007 05:38 PM

thanks YinYeti, it worked like a charm!

theYinYeti 06-04-2007 02:06 AM

You're welcome :)

Note that dd is more powerfull than my knowledge reckons ;) Thanks syg00 for reminding me about that. In my example, I used the default block size, which is 512 Bytes. By specifying a saner block size, you could at least simplify the computations that give you the "count" argument.
Besides, /dev/random or similar may indeed interest you if you want random content in your result file.

Yves.

Edit: see here:
http://www.linuxquestions.org/questi...d.php?t=362506


All times are GMT -5. The time now is 10:45 PM.