Sometimes you may need to create empty disk image in Linux from an image file. In this article, we will look at how to create empty disk image in Linux.
How to Create Empty Disk Image in Linux
Here are the steps to create empty disk image in Linux. You will need to install hfsutils package for this purpose.
1. Install hfsutils
Open terminal and run the following command to install hfsutils.
$ sudo apt-get install hfsutils
2. Create Image File
Let us say your image is located at /home/file.img. Run the following command to create an image. Replace /home/file.img with path to your image file.
dd if=/dev/zero of=/home/file.img bs=1 count=0 seek=1G
We have created disk with space for 1GB file. If you want to modify it, you may do so by updating the values for bs, count & seek options above. Here’s how they work.
3. Format Image
Run the following command to format the image.
sudo hformat -l File /home/file.img
4. Mount Image
Mount the image with the following commands.
sudo mkdir /mnt/file$
sudo mount -t hfs -o loop /home/file.img /mnt/file
5. Copy Files
You can copy your files into this newly mounted disk volume and unmount it when you are done.
sudo umount /mnt/file
That’s it. In this article, we have looked at how to easily create blank disk for file storage.