When playing with file system related stuff, especially for studying how they work at the low level with a hex editor, we are in need of many disk images. In such situations, instead of acquiring real disk images, it is possible to artificially create disk images on demand with any number of partitions we want with different file system times with a custom size. In this blog post, I'm writing down the steps to follow, in order to create such a disk image with the partition table and a single FAT32 partition.
(1) Creating a 100MB raw file.
dd if=/dev/zero of=image.dd iflag=fullblock bs=1M count=100 && sync
(2) Mounting the blank image into a loop device.
sudo losetup loop0 image.dd
Now, if you run the command losetup, you should see an output where loop device loop0 is mounted with the image.
(3) Let's partition this new loop device using GParted tool. For that, first we should install it.
sudo apt-get install gparted
(4) Open the GParted tool using the following command. Follow the steps of the screenshots in order to create the partition table and a FAT32 partition.
sudo -H gparted /dev/loop0
dd if=/dev/zero of=image.dd iflag=fullblock bs=1M count=100 && sync
(2) Mounting the blank image into a loop device.
sudo losetup loop0 image.dd
Now, if you run the command losetup, you should see an output where loop device loop0 is mounted with the image.
(3) Let's partition this new loop device using GParted tool. For that, first we should install it.
sudo apt-get install gparted
(4) Open the GParted tool using the following command. Follow the steps of the screenshots in order to create the partition table and a FAT32 partition.
sudo -H gparted /dev/loop0
GParted window. |
Creating a partition using the "Device" menu. |
Select partition type "msdos" and apply. |
Our drive with a partition table but no partitions yet. |
Creating a partition using the "Partition" menu. |
Select "File system" type as fat32 and click add. |
Newly created partition. Size is smaller because of the partition table, etc. |
Click on the button to apply file system creation operation to the drive. |
Click apply to go ahead. |
All done. Click "close" to finish and close the GParted window. |
(5) Unmount the loop device.
sudo losetup -d /dev/loop0
Now, our image.dd file contains a partition table of msdos type and a single partition with FAT32 file system. We can check it using a command available on Sleuthkit as follows.
sudo losetup -d /dev/loop0
Now, our image.dd file contains a partition table of msdos type and a single partition with FAT32 file system. We can check it using a command available on Sleuthkit as follows.
sudo apt-get install sleuthkit
mmls image.dd
mmls image.dd
Cheers!
References:
[1] https://askubuntu.com/questions/667291/create-blank-disk-image-for-file-storage
References:
[1] https://askubuntu.com/questions/667291/create-blank-disk-image-for-file-storage
~************~
ReplyDeleteHelpful artical.
Thanks for a well written and informative post.
How to Edit RAW Images As a Beginner & Why You Need Them