I'm not sure why you would've had difficulties using mkfs on a regular block device. I'm running Debian testing and the following works for me:
Code:
root@thirtyseven:~# dd if=/dev/zero of=test.img bs=1024 count=10240 # 10M
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.207998 s, 50.4 MB/s
root@thirtyseven:~# mkfs.ext3 test.img
mke2fs 1.41.12 (17-May-2010)
test.img is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
2560 inodes, 10240 blocks
512 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=10485760
2 block groups
8192 blocks per group, 8192 fragments per group
1280 inodes per group
Superblock backups stored on blocks:
8193
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
I can also partition the file as if it were a disk:
Code:
root@thirtyseven:~# parted test.img
GNU Parted 2.2
Using /root/test.img
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
(parted) p
Model: (file)
Disk /root/test.img: 10.5MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
(parted)
You won't want to use partitioning like this, however, if you're just playing around with LVM. I personally think of partitioning a hark disk as a way of getting block devices out of the disk without having to worry about other applications (like LiveCDs or OS installers) messing those block devices up. If you want to play with RAID or LVM, I suggest you just do
Code:
for n in $(seq 1 10); do dd if=/dev/zero of=testDevice$n.img bs=1024 count=10240; done
You should then be able to execute commands against those files the same way you could against a partition. If, for some reason, you must have a block device, you can always look into losetup for creating a loopback device over the file.
If you continue to have trouble doing so, please post the error messages you are getting along with your distro and version.