Mount file as disk in Linux

An example of using dd to create a 1GB file.

dd if=/dev/zero of=testfile bs=1M count=1024

Or alternatively, create a sparse file ( very quick to create, but will lead to fragmentation later)

dd if=/dev/zero of=testfile bs=1M seek=1024 count=0

Large files can be formatted with a file system and mounted:

mkfs.ext3 -F testfile
mount -o loop -t ext3 testfile /mnt
umount /mnt
Mount file as disk in Linux

Leave a Reply

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