linux - how to list partitions of specific type?
I am looking for a way to list all partitions of a specific type on linux. (Specifically: all EFI system partitions).
I know 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?
EDIT
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 EF00
or ef
.
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.
lsblk -o +PARTTYPE
includes the partition type UUID in the listing. The EFI System Partition type UUID is C12A7328-F81F-11D2-BA4B-00A0C93EC93B
, so grepping for this (in lower case, or use the -i
flag with grep) lists your ESPs.