7

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:

4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D

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.

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

2 Answers 2

7

lsblk - list block devices is your friend.

# lsblk -p -o NAME,PARTTYPE
NAME         PARTTYPE
/dev/vda     
├─/dev/vda1  c12a7328-f81f-11d2-ba4b-00a0c93ec93b
├─/dev/vda2  ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
...
2
  • Since the original question mentioned that this is for a script, the -P option to lsblk might be of interest which prints the desired values in a way that can be eval-ed in a shell script.
    – josch
    Commented Mar 10, 2022 at 13:54
  • 1
    Root rights not required
    – radioxoma
    Commented May 5, 2023 at 21:13
1

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
            osds+=($dev)
        fi
    done
    echo "${osds[@]}"
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .