I am looking for a way to list all partitions of a specific type on linux. (Specifically: all EFI system partitions).
blkid can filter on filesystem type: the command
blkid -t TYPE=vfat returns the correct results, but is not very robust: there might be other vfat filesystems which aren't ESPs, or there might be ESPs formatted with a different filesystem.
So, is there an equivalent command that can list devices but filter on partition type?
I need a list of all EFI System Partitions (or ESPs). These partitions have partition type
EF00 in gdisk or partition type
ef in fdisk. They are most commonly formatted as vfat.
Now, I can use
blkid to list all partitions which are formatted with vfat, but that leaves two problems:
a) There might be EFI partitions not formatted with vfat (or not formatted at all) which would be missing from the list, and
b) there might be regular filesystemes formatted as vfat, which would be included in the list incorrectly. So matching on filesystem type is not the way to go. That's why I am looking for something that can match on partition type, so
If such a command does not exist, I would probably need to do the following to get at the information I want:
- list all disks
- for each disk, find out if there is an MBR or GPT partition table on it
- list the partition table
- filter the results to only print the ESP partitions
This is cumbersome and error-prone, so if an equivalent of
blkid exists that is able to match partition types, I would like to use that.