How To Create Files Of A Certain Size In Linux

Create Files Of A Certain Size In Linux

4 Responses

  1. Luc Van Rompaey says:

    Just a sidenote: With the bash shell, you can do inline arithmetic, so you won’t have to calculate how many bytes go into 5 MiB beforehand.
    Just do:
    fallocate -l $(( 5 * 1024 * 1024 )) ostechnix.txt

  2. AshkanV says:

    I think its good to mention that the first 2 command only allocate file with the given size in the file system, which is means no IO overhead.
    but the other two create an empty file and extending it by writing data in it, which means LOTS of IO overhead

    By the way thanks for good and useful article.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.