Create files with specific sizes?
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 3 lines · Khan
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Review
Quoted 12 lines · [email protected] wrote:
Quoted 1 line · Khan
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(quoted diff) +0
-3-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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
I have a follow up question.
...
Quoted 1 line
Quoted 1 line
is there any way (some command) that will allow me to create blank files with specific sizes, eg 1MB, 5MB, 10MB etc.
...
Quoted 1 line
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 6 lines · SVisor
Quoted 2 lines
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
Quoted 1 line
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 7 lines · SVisor
Quoted 3 lines
Quoted 3 lines
is there any way (some command) that will allow me to create blank files with specific sizes, eg 1MB, 5MB, 10MB etc.
...
Quoted 1 line
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 6 lines · 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
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!
Signature · 2 lines
---------------------------------------- --EB
Quoted 4 lines
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
...
Quoted 2 lines
Quoted 2 lines
I wanted a file of garbage, not zeroes.
So I tried: dd if=/dev/random of=file bs=1k count=1024
...
Quoted 2 lines
That's exactly what it is supposed to do. Perhaps you tought
/dev/randomcould 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Quoted 9 lines · SVisor
Quoted 3 lines
Quoted 3 lines
I wanted a file of garbage, not zeroes.
So I tried: dd if=/dev/random of=file bs=1k count=1024Nope 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
Quoted 2 lines
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Simon Valiquette wrote:
...
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
I wanted a file of garbage, not zeroes.
So I tried: dd if=/dev/random of=file bs=1k count=1024
...
Quoted 5 lines
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).
Quoted 1 line
Also, check if the produced file really is random data.
It looks random alright.
Quoted 1 line
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.
...
Quoted 4 lines
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
...
Quoted 1 line
Quoted 1 line
But the file still is just ~4k. Maybe a bug?
...
Quoted 1 line
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 ).
Quoted 1 line
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs