1

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?

  • 2
    Unable to get device geometry for VHD2.img is just a warning. Can permission denied be because you created the file with sudo but then invoked mkfs without sudo? – Kamil Maciorowski Jul 15 at 5:16
  • @KamilMaciorowski It finally appears that sudo solved the issue for the second mkfs, because the second sudo dd created a file VHD2.img with permissions -rw-r--r-- while in the first case it created a file VHD.img with permissions -rwxrw-rw-. I wonder why different parameters of dd create files with different permissions ? – hello world Jul 15 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.