2

UEFI has the infrastructure to support complex applications at boot-time. One of the most urgent needs of the hour is a UEFI application for GPT disk management.

A lot of partition management cannot be done by an OS because of how tied it is to the files on the disk. A UEFI boot manager that can exist on the ESP would have only a single requirement of the ESP not being deleted.

Also, keeping it directly in the ESP is the most convenient way to deal with disk and partition problems, as opposed to having a boot disk. In fact, having 2 separate hard disks with their own ESPs and identical copies of the diskmgmt.efi (let's call it that) will render the computer fully flexible.

Are there any such projects/products?

3

It's highly specialized and limited, but gptsync runs as an EFI application. This program was originally part of the now-abandoned rEFIt project. I've updated it for rEFInd, though. Note that gptsync is exclusively used to create hybrid MBRs, which are ugly, dangerous, and of limited utility, so I don't recommend gptsync for general use; but for certain specialized use cases (such as dual-booting Windows and OS X on a Mac), it can be a useful tool.

MariusMatutiae suggested using my gdisk, but it's not available as a native EFI application. It probably won't be in the near future, either, because gdisk is written in C++ and I know of no affordable C++ compiler for EFI. Most EFI applications are written in C, and it's possible to build C applications under Linux with GCC and either the GNU-EFI or Tianocore toolkits. C++ can theoretically be compiled for EFI with GCC, but most of the C++ library is not supported, and gdisk relies heavily on the C++ library. There's an Intel C++ compiler for EFI, but it's ridiculously expensive (roughly $1,000, IIRC), so I'm not going to buy it. If somebody with access to that compiler would care to try to build gdisk for EFI, I'd be happy to help out or accept patches, but for the moment that won't happen.

An easier solution might be to port parted or fdisk to EFI. (Until recently, fdisk didn't support GPT; but the latest versions do.) I haven't looked into this possibility, though.

For the moment, partitioning can be done by booting a live CD/DVD/USB flash drive. Granted, this isn't as fast as launching a partitioning tool from an EFI shell or EFI boot manager, but it's not that slow to get up and running. Disk partitioning is a task that shouldn't need to be performed very often, except perhaps in a lab that does testing of hardware or OS configurations or the like.


UPDATE:

As alluded to in the comments, the project to port GPT fdisk to EFI has borne fruit, in the form of the UEFI GPT fdisk project. This is basically an add-on library that provides a subset of C++ features for EFI -- enough to build the gdisk binary for EFI.

  • Well I was just thinking of porting gdisk to EFI... But how on earth would the compiler resolve high-level library calls to UEFI structures, even if the Intel compiler was available? I've been checking out diskpart.efi source code, and it's vastly different in organization than any C code I've seen, in fact looks more like Win32 code.. – Milind R Jan 18 '14 at 16:41
  • Mostly, I'm excited about the possibility of doing disk partitioning from the UEFI shell. – Milind R Jan 18 '14 at 16:51
  • 1
    parted is indeed pretty big. My comment about the ease of porting was based mainly on the poor availability of a C++ compiler for EFI -- to port gdisk, you'd first need to port all the C++ libraries to EFI, and that would be an undertaking that would make porting both fdisk and parted look trivial! – Rod Smith Jan 18 '14 at 20:37
  • 1
    Not really all the C++ libraries. You only seem to use streams and a couple of other bits and pieces. You don't seem to be using shared pointers, futures, deques, or locales, for examples. The hard part would actually be your own block I/O classes, rather than the standard C++ library, I suspect. Adding an EFI target to the OpenWatcom C++ compiler would seem like something to investigate. But this is veering into StackOverflow territory. – JdeBP Jan 20 '14 at 21:20
  • 1
    FWIW, I've been corresponding with somebody who's working to get enough of the C++ libraries ported to EFI to get gdisk working. I can make no promises at this point, but if this effort bears fruit, gdisk might become available as a native EFI application in the not-too-distant future, so keep an eye on it. – Rod Smith Feb 8 '14 at 15:57
1

If you had called it diskpart.efi you'd even have had the name right. ☺

There's certainly a niche available for a better tool. EFI versions of some of the more capable partitioning tools would be welcome, I suspect. EFI does graphics. They could even be GUI tools.

  • Yeah I found out about it few minutes after I posted it. But where would I find it? It's not there in the Windows 8 ISO, for example. – Milind R Jan 16 '14 at 12:17
  • Ah my mistake, found it here – Milind R Jan 16 '14 at 12:39
  • I tried it out... It's extremely primitive, not something anyone should be using in the 21st century. How hard would it be to build on this source code, ONLY for EFI and ONLY for layouts compliant to spec? I read your FGAs on boot process and BPB, and I'm simply horrified... – Milind R Jan 16 '14 at 14:52
  • Having looked at it again closely, it seems a lot more sophisticated than I gave it credit for. Perhaps I can try to implement the pleasing interface of gdisk building on this code. – Milind R Jan 21 '14 at 12:31
  • @MilindR let us know if you build it, I would be interested in trying it out. – CMCDragonkai Dec 6 '15 at 13:09
0

There is of course gdisk:

GPT fdisk (aka gdisk) is a text-mode menu-driven program for creation and manipulation of partition tables

Its author, Rod Smith, often answers questions on this forum. You may address your requests for new features directly to him here.

What is it exactly that you find lacking in gdisk?

  • I would like it to be a native EFI application/executable, so that I can run it outside of an OS, just using UEFI. After all, most disk partitioning tools resort to boot-time operations when the disk is locked by the OS. – Milind R Jan 16 '14 at 12:15

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.