Create files with specific sizes?
Create files with specific sizes?
am 14.12.2004 09:52:20 von Khan
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
Re: Create files with specific sizes?
am 14.12.2004 10:12:18 von qwms-avib
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
Re: Create files with specific sizes?
am 14.12.2004 10:24:42 von Khan
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
Re: Create files with specific sizes?
am 14.12.2004 10:41:19 von SVisor
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
Fw: Re: Create files with specific sizes?
am 14.12.2004 11:55:17 von Peter Garrett
Begin forwarded message:
Date: Tue, 14 Dec 2004 10:41:19 +0100
From: SVisor
To: linux-newbie@vger.kernel.org
Subject: Re: Create files with specific sizes?
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
-
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
Re: Create files with specific sizes?
am 14.12.2004 19:54:56 von Simon Valiquette
SVisor a =E9crit :
>>=20
>> dd if=3D/dev/zero of=3Dfile1 bs=3D1k count=3D1024
>=20
> I wanted a file of garbage, not zeroes.
> So I tried: dd if=3D/dev/random of=3Dfile bs=3D1k count=3D1024
>=20
If you don't need encryption-level random numbers (just noise) you=20
can use urandom. It will also be much faster because it will continue=20
to send data even when his entropy pool will be exhausted.
dd if=3D/dev/urandom of=3Dfile bs=3D1k count=3D1024
> But to my suprise I got only a ~4k file. I know that dev/random may r=
un=20
> 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=20
/dev/random could generate random numbers much faster. So when it's=20
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.=
=20
Once exhausted, the others bits are *much* slower to get. I mean, in=
=20
the order of 1,000,000 times slower than urandom unless you have a=20
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
Re: Create files with specific sizes?
am 14.12.2004 20:20:29 von qwms-avib
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
Re: Create files with specific sizes?
am 16.12.2004 02:14:07 von Eric Bambach
On Tuesday 14 December 2004 02:52 am, Khan wrote:
> Hello,
>
> is there any way (some command) that will allow me to create blank fi=
les
> with specific sizes, eg 1MB, 5MB, 10MB etc.
>
> TNX
Just for the sake of chipping in...dd supports the K,M,GB suffixes so y=
ou=20
don't have to remember odd numbers (1024,2048,3096). You can just writ=
e=20
dd if=3D/dev/urandom of=3D/myfile bs=3D1M count=3D1
dd if=3D/dev/urandom of=3D/myfile bs=3D10M count=3D1
dd if=3D/dev/urandom of=3D/myfile bs=3D5M count=3D1
dd if=3D/dev/urandom of=3D/myfile bs=3D5G count=3D1 ;)
Manpage for DD:
The GNU fileutils-4.0 version also allows the
following multiplicative suffixes in the specification of blo=
cksizes
(in bs=3D, cbs=3D, ibs=3D, obs=3D): M=3D1048576, G=3D1073741824,=
and so on for T,
P, E, Z, Y. A `D' suffix makes them decimal: kD=3D1000, MD=
=3D1000000,
GD=3D1000000000, etc. (Note that for ls, df, du the size of M =
etc. is
determined by environment variables, but for dd it is fixed.)
HTH!
--=20
----------------------------------------
--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=20
----------------------------------------
-
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
Re: Create files with specific sizes?
am 16.12.2004 10:47:51 von SVisor
....
>> 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
Re: Create files with specific sizes?
am 17.12.2004 22:15:25 von Simon Valiquette
SVisor a =E9crit :
>=20
>>> I wanted a file of garbage, not zeroes.
>>> So I tried: dd if=3D/dev/random of=3Dfile bs=3D1k count=3D1024
>=20
> Nope I did not abort it, I just moved the mouse to generate more rand=
om=20
> numbers (with dd running in X terminal). What dd says is:
>=20
> 0+1024 records in
> 0+1024 records out
>=20
You have read and written 1024 partial blocks (ie. not complete).=20
Why? I don't know.
You did'nt say if the produced file is always the same size, or=20
differents but always bigger (or smaller) than 4K? Please give the=20
exact value(s) as it can hint at what the problem is. I have the=20
impression that you get only 4 bytes per block readed. You can=20
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=20
couple of seconds. If it works (and get a very big file), then the=20
problem is not related to the random devices. I suppose here that you=20
had the same problem with random and urandom.
By curiosity, try this and report the exact file size produced (and=20
check if it is random data).
dd if=3D/dev/urandom of=3D/tmp/file.cp bs=3D1 count=3D1024x1024
> But the file still is just ~4k. Maybe a bug?
>=20
Maybe, but I would be surprised. I suspect that if you do a=20
reinstall from scratch (or use a Knoppix disk) you will not see your=20
problem any more. You did'nt even said which Linux distribution you ar=
e=20
using, so with that little information I can't help much. By the way, =
I=20
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
Re: Create files with specific sizes?
am 18.12.2004 12:05:17 von SVisor
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