Create file image container

  1. BS and COUNT should be lowercase:

    dd if=/dev/zero of=~/theFile.img bs=1M count=10240

  2. you need to make the /media/MountPoint directory if it doesn't already exist:

    sudo mkdir -p /media/MountPoint

Apart from those two things, what you have there should work.

It's usually better to be explicit than rely on implicit behaviour, so you might want to change the mount line to:

sudo mount -t ext4 -o loop ~/theFile.img /media/mountPoint


Except for the capital letters in the dd options and not including the loop option in mount, I find this perfectly valid. mkfs is warning you that is not using a block device to make sure that you know what you're doing.

Anyway, at the end, you will be using a loop device:

$ dd if=/dev/zero of=~/theFile.img bs=1M count=10
$ /sbin/mkfs.ext4 theFile.img
$ sudo mount -o loop theFile.img /mnt/tmp/
$ df -h

/dev/loop0            9,7M  1,1M  8,1M  12% /mnt/tmp

Tags:

Filesystems

Dd