I need to list the partition type GUID's from the command line.

Note: This is not the same as the partition UUID.

Basically I'm needing to search for all disks that have the Ceph OSD type GUID:


The intention is to emulate some things done with ceph-disk (python) in bash script on CoreOS. Why? so I can mount them to the appropriate place automatically with ceph-docker.

  • Do you really need the GUID, not just the type that fdisk -l displays or the code that gdisk -l displays? – Gilles 'SO- stop being evil' Jun 5 '15 at 1:00
  • Good point. I've also found that I might be able to grep on /dev/disk/by-parttypeuuid, – Matt H Jun 5 '15 at 1:03
  • gdisk/fdisk displays them as "ceph data" – Matt H Jun 5 '15 at 1:04

lsblk - list block devices is your friend.

# lsblk -p -o NAME,PARTTYPE
├─/dev/vda1  c12a7328-f81f-11d2-ba4b-00a0c93ec93b
├─/dev/vda2  ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
| improve this answer | |

This was my ultimate solution using blkid -p

function find_osds()
    local osds
    declare -a dev_list
    mapfile dev_list < <(lsblk -l -n -o NAME --exclude 1,7,11) # note -I not available in all versions of lsblk, use exclude instead
    for dev in "${dev_list[@]}"; do
        dev=/dev/$(trim "$dev")
        if blkid -p "$dev" | fgrep -q '4fbd7e29-9d25-41b8-afd0-062c0ceff05d'; then
    echo "${osds[@]}"
| improve this answer | |

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.