I want to create virtual 500GB ext4 disks on external usb disks and samba/nfs shares.
For test purposes, I first tried with a 1GB file using the following commands.
sudo dd if=/dev/zero of=/mnt/smbshare/VHD.img bs=1M count=1000 mkfs.ext4 /mnt/smbshare/VHD.img
It works to get a 1GB ext4 filesystem, but
dd is slow (10MB/s). So I tried to create a 10GB file with
sudo dd if=/dev/zero of=/mnt/smbshare/VHD2.img bs=1G seek=10 count=0. It took few milliseconds, but in this case command
mkfs.ext4 /mnt/smbshare/VHD.img returned the following error message:
mke2fs 1.43.3 (04-Sep-2016)
warning: Unable to get device geometry for VHD2.img
VHD2.img: Permission denied while setting up superblock
Is there a fast way to create the file so it can be successfully formatted, for example by changing the
dd parameters, adding a further step after
dd, or by using an alternate way to create the file?