Fill up HD fastest way

D

drunkenfist

Hi,

I'm writing a Perl script that fills a HD with random data as fast as possible.

open(FILE,'>garbage.dat');
while(1) { print FILE rand() }

This is terribly slow, so I did some tweaking:

open(FILE,'>garbage.dat');
while(1) {
print FILE (rand() x 10000)
}

ha, that one is a lot faster!

Any faster way?
 
T

Tassilo v. Parseval

Also sprach (e-mail address removed):
I'm writing a Perl script that fills a HD with random data as fast as possible.

open(FILE,'>garbage.dat');
while(1) { print FILE rand() }

This is terribly slow, so I did some tweaking:

open(FILE,'>garbage.dat');
while(1) {
print FILE (rand() x 10000)
}

ha, that one is a lot faster!

Any faster way?

Yes.

system "cat /dev/urandom > garbage.dat";

Of course, this makes some gentle assumptions, like the existence of
/dev/urandom and cat(1).

Tassilo
 
S

Sam Holden

On 23 Oct 2003 09:26:29 GMT,
Hi,

I'm writing a Perl script that fills a HD with random data as fast as possible.

open(FILE,'>garbage.dat');
while(1) { print FILE rand() }

This is terribly slow, so I did some tweaking:

open(FILE,'>garbage.dat');
while(1) {
print FILE (rand() x 10000)
}

ha, that one is a lot faster!

And a lot less "random"...
 
S

Sisyphus

Hi,

I'm writing a Perl script that fills a HD with random data as fast as possible.

open(FILE,'>garbage.dat');
while(1) { print FILE rand() }

This is terribly slow, so I did some tweaking:

open(FILE,'>garbage.dat');
while(1) {
print FILE (rand() x 10000)
}

The same "random" number will be repeated 10000 times.
Not my idea of a HD full of "random" data :)

Cheers,
Rob
 
L

Lambik69

Any faster way?

how about something like:
#!/usr/bin/perl -w
use strict;

sub fisher_yates_shuffle {
my $array = shift;
my $i;
for ($i = @$array; --$i; ) {
my $j = int rand ($i+1);
next if $i == $j;
@$array[$i,$j] = @$array[$j,$i];
}
}

my @array = 1..1000000;
open(FILE,'>garbage.dat');
while(1) {
print FILE fisher_yates_shuffle (\@array);
}
close FILE;
 
E

Eric J. Roode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

how about something like:
#!/usr/bin/perl -w
use strict;

sub fisher_yates_shuffle {

Is that really faster?

- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP5e6PWPeouIeTNHoEQI2SgCg3fMP0z3YuCAN1nSaDjUGaAOl8eMAnilo
u14RrlPjR0iMbwkDw7oirCey
=Mwor
-----END PGP SIGNATURE-----
 
D

drunkenfist

Abigail said:
(e-mail address removed) ([email protected]) wrote on MMMDCCV
September MCMXCIII in <URL:~~
~~ Hi,
~~
~~ I'm writing a Perl script that fills a HD with random data as fast as possib
~~
~~ open(FILE,'>garbage.dat');

That opens a file, it won't fill a hard disk with random data - you will
still be left with a filesystem, and it won't overwrite existing files.

I'd do:

system "dd if=/dev/urandom of=/dev/rdsk/c1t6d2s2 bs=1024k"

(Assuming /dev/rdsk/c1t6d2s2 is the disk to be filled).

ehh, forgot to mention 'fill free space'. It should be portable as well.
 
R

Roy Johnson

How about
$fmt='%c'x100;
printf $fmt, map(int(rand(256)), 1..100) while 1;
or (probably better)
print pack('C100', map(int(rand(256)), 1..100)) while 1;

They're more random than just digits.
 
R

Roy Johnson

(e-mail address removed) (Roy Johnson) wrote in message A bit less random, a lot faster:

## Adjust numbers to taste.
my $preroll=pack('C17000', map(int(rand(256)), 1..17000));
print substr($preroll, rand(16000), 1000) while 1;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,364
Latest member
Stevanida

Latest Threads

Top