Latest From Our Blog

Create Binary Image with Linux

To create an image file on Linux we have various options to do the job. We have commands like dd, truncate, mkfile and others. On most linux systems we have fallocate installed by default. The command fallocate is supported only on certain file systems such ext4, xfs, ocfs2 and btrfs.  The best choice to create a large file on a Linux system is the command fallocate. Fallocate only allocates/reserves blocks and marking them as uninitialized without requiring I/O and CPU time. This is much faster than creating a file by filling it with zeros like the command dd does.

 

To make sure we have sufficient disk space to create an image file, we use the command df.

Output:

We can see, that we have enough disk space to create some image files.  To create an image file we use the command fallocate.

Syntax:

 

Example to create a 100 Megabyte file:

Example to create a 1 Gigabyte file:

Example to create a 10 Gigabyte file:

Let’s verify our new file.:

Output:

 

Tags

Leave a Reply

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