Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OT = just a quicky

0 views
Skip to first unread message

David Stanaway

unread,
Feb 1, 2002, 2:49:49 AM2/1/02
to

On Friday, February 1, 2002, at 06:39 PM, Damir Horvat wrote:

> On Fri, 1 Feb 2002 15:22:51 +0800
> "Jason Lim" <mail...@jasonlim.com> wrote:
>
>> Hi,
>>
>> Just wanted to know... how do I make a file with all 1s or 0s or
>> something with a certain size (eg. 100Mb)?
>>
>> I was thinking 'dd something' but there is probably a better way?
>
> why not dd?
>
> dd if=/dev/zero of=/tmp/yourfile bs=1m count=100
>


Also, piping through tr could be handy.

dd if=/dev/zero bs=1m count=100 |tr "\0" "1" > /tmp/yourfile

==============================
David Stanaway
Personal: da...@stanaway.net
Work: da...@netventures.com.au


--
To UNSUBSCRIBE, email to debian-is...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Jason Lim

unread,
Feb 1, 2002, 3:20:39 AM2/1/02
to
Thanks Damir, Nathan, and David...

I was doing if=/dev/random (forgot all about /dev/zero), and it was taking
a very long time to get even near 100M, so I thought there would be a
better way. Using /dev/zero helped a lot... and I could use tr to change
them to 1s (created two versions... but I think both would be
approximately the same speed).

Thanks again.


> dd if=/dev/zero of=/tmp/yourfile bs=1m count=100

> dd if=/dev/zero bs=1m count=100 |tr "\0" "1" > /tmp/yourfile

--

Donovan Baarda

unread,
Feb 1, 2002, 8:08:18 PM2/1/02
to
On Fri, Feb 01, 2002 at 04:11:51PM +0800, Jason Lim wrote:
> Thanks Damir, Nathan, and David...
>
> I was doing if=/dev/random (forgot all about /dev/zero), and it was taking
> a very long time to get even near 100M, so I thought there would be a
> better way. Using /dev/zero helped a lot... and I could use tr to change
> them to 1s (created two versions... but I think both would be
> approximately the same speed).

I'm not surprised /dev/random was slow. This is the "true" random number
generator that relys on entropy collected from truely random events like
key-presses, serial interrupts, etc. This means it will stall when it runs
out of entropy. Bashing keys and wiggling your mouse will speed it up, as
this feeds it more entropy.

If you would be content with "almost" random numbers, use /dev/urandom. This
uses /dev/random to seed a random-number generator. This means it is still
pretty random, but it doesn't stall when /dev/random runs out of entropy.

--
----------------------------------------------------------------------
ABO: finger a...@minkirri.apana.org.au for more info, including pgp key
----------------------------------------------------------------------

0 new messages