Does there exist a native UEFI disk/partition manager?

7,292

Solution 1

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.

Solution 2

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.

Share:
7,292

Related videos on Youtube

Milind R
Author by

Milind R

I am a graduate of Computational Science from Indian Institute of Science, Bangalore, India. I have been working on computers for quite a few years now, though I haven't received formal education in the field :)

Updated on September 18, 2022

Comments

  • Milind R
    Milind R over 1 year

    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?

  • Milind R
    Milind R over 10 years
    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
    Milind R over 10 years
    Ah my mistake, found it here
  • Milind R
    Milind R over 10 years
    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
    Milind R over 10 years
    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
    Milind R over 10 years
    Mostly, I'm excited about the possibility of doing disk partitioning from the UEFI shell.
  • Milind R
    Milind R over 10 years
    Update: It does not support C++. And agreed, fdisk might be easier, but parted? Isn't it much more massive than gdisk?
  • Rod Smith
    Rod Smith over 10 years
    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!
  • JdeBP
    JdeBP over 10 years
    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.
  • Milind R
    Milind R over 10 years
    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
    Milind R over 10 years
    @JdeBP Would EDK2 be too difficult?
  • JdeBP
    JdeBP over 10 years
    M. Smith has a page on that subject.
  • Rod Smith
    Rod Smith over 10 years
    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.
  • CMCDragonkai
    CMCDragonkai over 8 years
    @MilindR let us know if you build it, I would be interested in trying it out.
  • Milind R
    Milind R over 8 years
    @CMCDragonkai I haven't even got close to starting this, but someone else has done this.