1

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 -fcombined with grep could do it, I am not quite sure what you mean by EFI system partitions. – mzhaase Nov 23 '16 at 11:19
2

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.

0

1) For list partitions of specific type:

:~# lsblk -ln -o NAME,TYPE
...
sda          disk
sda1         part
sda1_crypt   crypt
vg0xa-system lvm
vg0xa-swap   lvm
vg0xa-tmp    lvm
vg0xa-var    lvm
vg0xa-usr    lvm
...

See also: lsblk -ln -o NAME,PARTTYPE

2) or more specifically:

:~# lsblk -ln -o NAME,TYPE | grep sda1_crypt
sda1_crypt   crypt
  • I'm not looking for partitions of a specific filesystem type, but of a specific partition type. I'll expand my question. – roelvanmeer Nov 23 '16 at 12:20

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.