Solved bhyve windows install fails - 0x80070057


I am starting with bhyve. My goal is to completely replace Virtualbox for a few reasons which would be off topic.

I followed the wiki and also am using vm-bhyve port. It seemed simple enough but got stuck in the process of installing windows. The disk can't be formatted.

So, to start, I am running FreeBSD 11.0p1, behyve is fresh from ports. UEFI rom is from ports as well (tried the one from the wiki page; no luck there; so I stuck with the newer one). I am using a file container as a hard drive. I am trying to install windows 7 with the modified ISO. Unattended install works and jams at the disk partitioning tasks.

bhyve -c 2 -s 0,hostbridge -s 4,ahci-hd,/mnt/vm/wintest/disk0.img -s 3,ahci-cd,/mnt/vm/.iso/win7_enterprise.iso -s 10,virtio-net,tap0 -s 31,lpc -l com1,/dev/nmdm0A -l bootrom,/mnt/vm/.config/BHYVE_UEFI.fd -m 4G -H -w wintest

The error from the console is 0x80070057 which basically means the system can't do anything with my disk.

From there, I launched a Windows cmd console and started diskpart. I looked at the partitions and they are set as the AutuUnattend.xml defines them. One EFI partition, one MSR and the last one a Primary.

I then attempted to format the EFI; it formats fine (FAT32). I then moved to the Primary and I can't get it to format NTFS. Each time I try, I get "The parameter is incorrect".
DISKPART> select disk 0

Disk 0 is now the selected disk.

DISKPART> list partition

  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
  Partition 1    System             400 MB  1024 KB
  Partition 2    Reserved           128 MB   401 MB
  Partition 3    Primary             49 GB   529 MB

DISKPART> select partition 3

Partition 3 is now the selected partition.

DISKPART> format fs=ntfs quick

    0 percent completed

DiskPart has encountered an error: The parameter is incorrect.
See the System Event Log for more information.

I searched for a while and found various causes going from existing partitions preventing new partitioning to bad disk.

I formatted the partition using the format command. It did it but left some things to repair. Using chkdsk, I repaired them but can't continue from there; each time I restart, the installation hangs because of the invalid format.

Has anyone seen this?

For Win7 (and 2k8), the sector size of the emulated hard drive has to be forced to 512 bytes. Often on file-backed images, or ZFS zvols, the block size will be 4KB or greater - older versions of Windows aren't able to deal with that.

The ahci-hd part of your config file should be modified to:
    -s 4,ahci-hd,/mnt/vm/wintest/disk0.img,sectorsize=512