Skip to content

Create a filesystem on a file

13/02/2012

I was always wondering if it’s possible to create a filesystem on a file instead of a disk partition. Finally, I just discovered that it’s not only possible, it’s really very easy and intuitive procedure. In fact, one could even create a swap partition and mount this one instead of a physical one!

It is really very simple to create a new filesystem on a file: create the file with the desired size and format this file with the desired filesystem. After the creation, mounting the file with the loop option will do the obvious job of mounting the filesystem.

   $ dd if=/dev/zero of=FILENAME bs=1M count=128
   $ mkfs.ext2 FILENAME

These commands create a filesystem on a file of 128MB. Other filesystems can be created with similar commands.

Keep also in mind that most of the tools that create the filesystems will complain about using a file instead of a disk partition (block-device). Yet they will continue their operation after explaining or forcing the tool to operate as it is intended.

Advertisements
Leave a Comment

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: