Create a filesystem in a file

4 views
Skip to first unread message

Mike Bigalke

unread,
Jul 5, 2009, 4:12:44 PM7/5/09
to cwelug
 Here's the link.

http://blog.dipinkrishna.info/2009/07/how-to-create-custom-file-system-within.html

But I decided to copy the post and reproduce it here, for those of you who don't like listening to music embedded in a web page.



With the power bestowed upon us, we can create a Linux file system in a file. Humanly speaking, we can create a file containing specific file system and mount it as if it were a partition of a hard drive.
To do this, we must first create the file:
touch filename

Then run the dd command to give a file size:
dd if=/dev/zero of=/tmp/filename bs=1024 count=102400

In this example a 100 MB file will be created in /tmp. You can modify the parameter "of" to change the location of the new file and parameters "count" and "bs" to change the file size.
Now give it to our file format with the file system you want.
Ext3 For example:
mkfs.ext3 filename

After the file created and formatted, it is now ready to be mounted:

mount -t ext3 /tmp/filename /mnt/filename -o loop

As you may know, the parameter "-o loop" should be used as the file is not a "Block device" or block device.
Clever. We already have our system file nested within the main filesystem.
Reply all
Reply to author
Forward
0 new messages