public inbox for linux-newbie@vger.kernel.org
 help / color / mirror / Atom feed
* Create files with specific sizes?
@ 2004-12-14  8:52 Khan
  2004-12-14  9:12 ` qwms-avib
  2004-12-16  1:14 ` Eric Bambach
  0 siblings, 2 replies; 10+ messages in thread
From: Khan @ 2004-12-14  8:52 UTC (permalink / raw)
  To: linux-newbie

Hello,

is there any way (some command) that will allow me to create blank files 
with specific sizes, eg 1MB, 5MB, 10MB etc.

TNX


-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Create files with specific sizes?
  2004-12-14  8:52 Create files with specific sizes? Khan
@ 2004-12-14  9:12 ` qwms-avib
  2004-12-14  9:24   ` Khan
  2004-12-14  9:41   ` SVisor
  2004-12-16  1:14 ` Eric Bambach
  1 sibling, 2 replies; 10+ messages in thread
From: qwms-avib @ 2004-12-14  9:12 UTC (permalink / raw)
  To: dlqf-ed4s; +Cc: Linux-Newbie

Khan wrote:
>
> is there any way (some command) that will allow me to 
> create blank files with specific sizes, eg 1MB, 5MB, 10MB etc.

dd if=/dev/zero of=file1 bs=1k count=1024
dd if=/dev/zero of=file2 bs=1k count=5120
dd if=/dev/zero of=file3 bs=1k count=10240

-rw-r--r-- 1 steven  users   1048576 Dec 14 22:09 file1
-rw-r--r-- 1 steven  users   5242880 Dec 14 22:09 file2
-rw-r--r-- 1 steven  users  10485760 Dec 14 22:09 file3

Cheers,
Steven

____________________________
http://www.basiclinux.com.ru
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Create files with specific sizes?
  2004-12-14  9:12 ` qwms-avib
@ 2004-12-14  9:24   ` Khan
  2004-12-14  9:41   ` SVisor
  1 sibling, 0 replies; 10+ messages in thread
From: Khan @ 2004-12-14  9:24 UTC (permalink / raw)
  To: linux-newbie

qwms-avib@dea.spamcon.org wrote:
> Khan wrote:
> 
>>is there any way (some command) that will allow me to 
>>create blank files with specific sizes, eg 1MB, 5MB, 10MB etc.
> 
> 
> dd if=/dev/zero of=file1 bs=1k count=1024
> dd if=/dev/zero of=file2 bs=1k count=5120
> dd if=/dev/zero of=file3 bs=1k count=10240
> 
> -rw-r--r-- 1 steven  users   1048576 Dec 14 22:09 file1
> -rw-r--r-- 1 steven  users   5242880 Dec 14 22:09 file2
> -rw-r--r-- 1 steven  users  10485760 Dec 14 22:09 file3

TNX!


-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Create files with specific sizes?
  2004-12-14  9:12 ` qwms-avib
  2004-12-14  9:24   ` Khan
@ 2004-12-14  9:41   ` SVisor
  2004-12-14 18:54     ` Simon Valiquette
  2004-12-14 19:20     ` qwms-avib
  1 sibling, 2 replies; 10+ messages in thread
From: SVisor @ 2004-12-14  9:41 UTC (permalink / raw)
  To: linux-newbie

I have a follow up question.

...
>>is there any way (some command) that will allow me to 
>>create blank files with specific sizes, eg 1MB, 5MB, 10MB etc.
...
> dd if=/dev/zero of=file1 bs=1k count=1024

I wanted a file of garbage, not zeroes.
So I tried: dd if=/dev/random of=file bs=1k count=1024

But to my suprise I got only a ~4k file. I know that dev/random may run 
out of values. But should dd not wait until there are enought of data?

// Jarmo

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Create files with specific sizes?
  2004-12-14  9:41   ` SVisor
@ 2004-12-14 18:54     ` Simon Valiquette
  2004-12-16  9:47       ` SVisor
  2004-12-14 19:20     ` qwms-avib
  1 sibling, 1 reply; 10+ messages in thread
From: Simon Valiquette @ 2004-12-14 18:54 UTC (permalink / raw)
  To: linux-newbie

SVisor a écrit :
>> 
>> dd if=/dev/zero of=file1 bs=1k count=1024
> 
> I wanted a file of garbage, not zeroes.
> So I tried: dd if=/dev/random of=file bs=1k count=1024
> 

   If you don't need encryption-level random numbers (just noise) you 
can use urandom.  It will also be much faster because it will continue 
to send data even when his entropy pool will be exhausted.

dd if=/dev/urandom of=file bs=1k count=1024

> But to my suprise I got only a ~4k file. I know that dev/random may run 
> out of values. But should dd not wait until there are enought of data?

   That's exactly what it is supposed to do.  Perhaps you tought 
/dev/random could generate random numbers much faster.  So when it's 
entropy pool was exhausted after 4KB, you tought it stopped working.

   By default, there is only a reserve of 4k of entropy in /dev/random. 
  Once exhausted, the others bits are *much* slower to get.  I mean, in 
the order of 1,000,000 times slower than urandom unless you have a 
special device to generate random numbers in hardware.

   You can see how much unused entropy you have with that:

cat /proc/sys/kernel/random/entropy_avail


Simon Valiquette
http://gulus.USherbrooke.ca
http://www.gulus.org

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Create files with specific sizes?
  2004-12-14  9:41   ` SVisor
  2004-12-14 18:54     ` Simon Valiquette
@ 2004-12-14 19:20     ` qwms-avib
  1 sibling, 0 replies; 10+ messages in thread
From: qwms-avib @ 2004-12-14 19:20 UTC (permalink / raw)
  To: g3fr-jc21; +Cc: hpfx-0ctl, Linux-Newbie

SVisor wrote:
>
> >>is there any way (some command) that will allow me to 
> >>create blank files with specific sizes, eg 1MB, 5MB, 10MB etc.
> ...
> > dd if=/dev/zero of=file1 bs=1k count=1024
> 
> I wanted a file of garbage, not zeroes.

Just pick a sufficiently large file or device 
for your input stream.  For example:

dd if=/dev/hda of=file1 bs=1k count=1024

Cheers,
Steven

____________________________
http://www.basiclinux.com.ru
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Create files with specific sizes?
  2004-12-14  8:52 Create files with specific sizes? Khan
  2004-12-14  9:12 ` qwms-avib
@ 2004-12-16  1:14 ` Eric Bambach
  1 sibling, 0 replies; 10+ messages in thread
From: Eric Bambach @ 2004-12-16  1:14 UTC (permalink / raw)
  To: Khan; +Cc: linux-newbie

On Tuesday 14 December 2004 02:52 am, Khan wrote:
> Hello,
>
> is there any way (some command) that will allow me to create blank files
> with specific sizes, eg 1MB, 5MB, 10MB etc.
>
> TNX

Just for the sake of chipping in...dd supports the K,M,GB suffixes so you 
don't have to remember  odd numbers (1024,2048,3096). You can just write 
dd if=/dev/urandom of=/myfile bs=1M count=1
dd if=/dev/urandom of=/myfile bs=10M count=1
dd if=/dev/urandom of=/myfile bs=5M count=1
dd if=/dev/urandom of=/myfile bs=5G count=1 ;)

Manpage for DD:

The GNU fileutils-4.0 version also allows  the
       following  multiplicative  suffixes  in the specification of blocksizes
       (in bs=, cbs=, ibs=, obs=): M=1048576, G=1073741824, and so on  for  T,
       P,  E,  Z,  Y.   A  `D' suffix makes them decimal: kD=1000, MD=1000000,
       GD=1000000000, etc.  (Note that for ls, df, du the size of  M  etc.  is
       determined by environment variables, but for dd it is fixed.)

HTH!

-- 
----------------------------------------
--EB

> All is fine except that I can reliably "oops" it simply by trying to read
> from /proc/apm (e.g. cat /proc/apm).
> oops output and ksymoops-2.3.4 output is attached.
> Is there anything else I can contribute?

The latitude and longtitude of the bios writers current position, and
a ballistic missile.

                --Alan Cox LKML-December 08,2000 

----------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Create files with specific sizes?
  2004-12-14 18:54     ` Simon Valiquette
@ 2004-12-16  9:47       ` SVisor
  2004-12-17 21:15         ` Simon Valiquette
  0 siblings, 1 reply; 10+ messages in thread
From: SVisor @ 2004-12-16  9:47 UTC (permalink / raw)
  To: linux-newbie

...
>> I wanted a file of garbage, not zeroes.
>> So I tried: dd if=/dev/random of=file bs=1k count=1024
...
>   That's exactly what it is supposed to do.  Perhaps you tought 
> /dev/random could generate random numbers much faster.  So when it's 
> entropy pool was exhausted after 4KB, you tought it stopped working.

Nope I did not abort it, I just moved the mouse to generate more random 
numbers (with dd running in X terminal). What dd says is:

0+1024 records in
0+1024 records out

But the file still is just ~4k. Maybe a bug?

// Jarmo

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Create files with specific sizes?
  2004-12-16  9:47       ` SVisor
@ 2004-12-17 21:15         ` Simon Valiquette
  2004-12-18 11:05           ` SVisor
  0 siblings, 1 reply; 10+ messages in thread
From: Simon Valiquette @ 2004-12-17 21:15 UTC (permalink / raw)
  To: linux-newbie

SVisor a écrit :
> 
>>> I wanted a file of garbage, not zeroes.
>>> So I tried: dd if=/dev/random of=file bs=1k count=1024
> 
> Nope I did not abort it, I just moved the mouse to generate more random 
> numbers (with dd running in X terminal). What dd says is:
> 
> 0+1024 records in
> 0+1024 records out
> 

   You have read and written 1024 partial blocks (ie. not complete). 
Why?  I don't know.

   You did'nt say if the produced file is always the same size, or 
differents but always bigger (or smaller) than 4K?  Please give the 
exact value(s) as it can hint at what the problem is.  I have the 
impression that you get only 4 bytes per block readed.  You can 
experiment with different values to try to find a patern.

   Also, check if the produced file really is random data.


   Try "cp /dev/urandom /tmp/file.cp" and type CTRL-C after waiting a 
couple of seconds.  If it works (and get a very big file), then the 
problem is not related to the random devices.  I suppose here that you 
had the same problem with random and urandom.


   By curiosity, try this and report the exact file size produced (and 
check if it is random data).

dd if=/dev/urandom of=/tmp/file.cp bs=1 count=1024x1024


> But the file still is just ~4k. Maybe a bug?
> 

   Maybe, but I would be surprised.  I suspect that if you do a 
reinstall from scratch (or use a Knoppix disk) you will not see your 
problem any more.  You did'nt even said which Linux distribution you are 
using, so with that little information I can't help much.  By the way, I 
can't reproduce your problem.


Simon Valiquette
http://www.gulus.org
http://gulus.USherbrooke.ca

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Create files with specific sizes?
  2004-12-17 21:15         ` Simon Valiquette
@ 2004-12-18 11:05           ` SVisor
  0 siblings, 0 replies; 10+ messages in thread
From: SVisor @ 2004-12-18 11:05 UTC (permalink / raw)
  To: linux-newbie

Simon Valiquette wrote:

...
>>>> I wanted a file of garbage, not zeroes.
>>>> So I tried: dd if=/dev/random of=file bs=1k count=1024
...
>   You have read and written 1024 partial blocks (ie. not complete). 
> Why?  I don't know.
> 
>   You did'nt say if the produced file is always the same size, or 
> differents but always bigger (or smaller) than 4K?  Please give the 
> exact value(s) as it can hint at what the problem is.  I have the 
> impression that you get only 4 bytes per block readed.  You can 
> experiment with different values to try to find a patern.

The size varies. Did a few test: 2843..3815..7414 bytes.
Biggest with: bs=512 count=1024x2.
Others with: bs=1024 count=1024 (only the smallest and biggest listed).

>   Also, check if the produced file really is random data.

It looks random alright.

>   Try "cp /dev/urandom /tmp/file.cp" and type CTRL-C after waiting a 

/dev/urandom works. Its /dev/random that does not.

Did: "cp /dev/random file" and it did block (as expected) until I 
aborted it (31299 bytes). It seems that dd gives up after a while.

...
>   By curiosity, try this and report the exact file size produced (and 
> check if it is random data).
> 
> dd if=/dev/urandom of=/tmp/file.cp bs=1 count=1024x1024

Well it did produce: 1048576 bytes of random data. As expected.

dd if=/dev/random of=/tmp/file.cp bs=1 count=1024x1024

Does block dd (as it waits for more values), as expected (got bored and 
aborted it, result 52381 bytes). The problem just occurs with 
/dev/random and blocksizes bigger than 1.

Tried: bs=512 count=1024x2 - got 7414
Tried: bs=512 count=2      - got 680

...
>> But the file still is just ~4k. Maybe a bug?
...
> more.  You did'nt even said which Linux distribution you are using, so 

Once it was SuSE 8.1 (or 8.2 I do not remember). dd is version 4.5.8. 
kernel is build by SuSE ( 2.4.20-4GB-athlon ).

> with that little information I can't help much.  By the way, I can't 
> reproduce your problem.

Well nothing to loose sleep over. I was just suprised of the result. 
Anyway this computer is due an upgrade. Did for fun test this on another 
(home built) system with dd version 5.2.1. There it worked as expected, 
  blocked until I aborted it (378 bytes). The low count is probably 
because I accessed that computer remotly with ssh (no mouse motion that 
provides seed to /dev/random). So this "problem" is probably solved by 
upgrading dd.

Thanks for your time.

// Jarmo

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2004-12-18 11:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-14  8:52 Create files with specific sizes? Khan
2004-12-14  9:12 ` qwms-avib
2004-12-14  9:24   ` Khan
2004-12-14  9:41   ` SVisor
2004-12-14 18:54     ` Simon Valiquette
2004-12-16  9:47       ` SVisor
2004-12-17 21:15         ` Simon Valiquette
2004-12-18 11:05           ` SVisor
2004-12-14 19:20     ` qwms-avib
2004-12-16  1:14 ` Eric Bambach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox