Search code examples
uefi

Update EFI partition table cache


As part of an automated software deployment, I'm writing a harddisk image from an EFI application. After that is complete, the cached partition table is no longer up to date, so I need to force a reload.

I haven't found an API to either explicitly flush the partition table cache or to simulate a media change (which would probably violate the expectations of ...->MediaInfo->Removable == FALSE anyway).

Do I need a reboot, or have I overlooked something?


Solution

  • I've found it. Partition tables may be altered only while holding an exclusive handle to the BLOCK_IO_PROTOCOL for the device.

    Opening the handle in exclusive mode will detach any other drivers, including block IO protocols for partitions and the partition table cache. On closing the exclusive handle, the partition table is re-read.