]> git.proxmox.com Git - ceph.git/blame - ceph/src/ceph-disk-udev
bump version to 12.0.3-pve3
[ceph.git] / ceph / src / ceph-disk-udev
CommitLineData
7c673cae
FG
1#! /bin/sh
2
3# Wrapper for the ceph udev rules. Since older versions of udev+blkid
4# do not support gpt label fields, this shell script is invoked from
5# the udev rule to read the needed gpt label fields and call the
6# appropriate ceph OSD functions.
7
8PARTNO=$1
9NAME=$2
10PARENT_NAME=$3
11
12# Get GPT partition type guid
13ID_PART_ENTRY_TYPE=$(/usr/sbin/sgdisk --info=${PARTNO} /dev/${PARENT_NAME} | grep "Partition GUID code" | awk '{print $4}' | tr '[:upper:]' '[:lower:]')
14
15if [ -z "$ID_PART_ENTRY_TYPE" ]; then
16 exit
17fi
18
19ID_PART_ENTRY_UUID=$(/usr/sbin/sgdisk --info=${PARTNO} /dev/${PARENT_NAME} | grep "Partition unique GUID" | awk '{print $4}' | tr '[:upper:]' '[:lower:]')
20
21# set up the symlinks
22mkdir -p /dev/disk/by-partuuid
23ln -sf ../../${NAME} /dev/disk/by-partuuid/$ID_PART_ENTRY_UUID
24mkdir -p /dev/disk/by-parttypeuuid
25ln -sf ../../${NAME} /dev/disk/by-parttypeuuid/${ID_PART_ENTRY_TYPE}.${ID_PART_ENTRY_UUID}
26
27case $ID_PART_ENTRY_TYPE in
28
2945b0969e-9b03-4f30-b4c6-b4b80ceff106)
30 # JOURNAL_UUID
31 # activate ceph-tagged journal partitions.
32 /usr/sbin/ceph-disk -v activate-journal /dev/${NAME}
33 ;;
34
3545b0969e-9b03-4f30-b4c6-5ec00ceff106)
36 # DMCRYPT_JOURNAL_UUID
37 # Map journal if using dm-crypt
38 /sbin/cryptsetup --key-file /etc/ceph/dmcrypt-keys/${ID_PART_ENTRY_UUID} --key-size 256 create ${ID_PART_ENTRY_UUID} /dev/${NAME}
39 ;;
40
4145b0969e-9b03-4f30-b4c6-35865ceff106)
42 # DMCRYPT_LUKS_JOURNAL_UUID
43 # Map journal if using dm-crypt
44 /sbin/cryptsetup --key-file /etc/ceph/dmcrypt-keys/${ID_PART_ENTRY_UUID} luksOpen /dev/${NAME} ${ID_PART_ENTRY_UUID}
45 ;;
46
474fbd7e29-9d25-41b8-afd0-062c0ceff05d)
48 # OSD_UUID
49 # activate ceph-tagged partitions.
50 /usr/sbin/ceph-disk -v activate /dev/${NAME}
51 ;;
52
534fbd7e29-9d25-41b8-afd0-5ec00ceff05d)
54 # DMCRYPT_OSD_UUID
55 # Map data device and activate ceph-tagged partitions
56 # for dm-crypted data devices
57 /sbin/cryptsetup --key-file /etc/ceph/dmcrypt-keys/${ID_PART_ENTRY_UUID} --key-size 256 create ${ID_PART_ENTRY_UUID} /dev/${NAME}
58 bash -c 'while [ ! -e /dev/mapper/${ID_PART_ENTRY_UUID} ];do sleep 1; done'
59 /usr/sbin/ceph-disk activate /dev/mapper/${ID_PART_ENTRY_UUID}
60 ;;
61
624fbd7e29-9d25-41b8-afd0-35865ceff05d)
63 # DMCRYPT_LUKS_OSD_UUID
64 # Map data device and activate ceph-tagged partitions
65 # for dm-crypted data devices
66 /sbin/cryptsetup --key-file /etc/ceph/dmcrypt-keys/${ID_PART_ENTRY_UUID} luksOpen /dev/${NAME} ${ID_PART_ENTRY_UUID}
67 bash -c 'while [ ! -e /dev/mapper/${ID_PART_ENTRY_UUID} ];do sleep 1; done'
68 /usr/sbin/ceph-disk activate /dev/mapper/${ID_PART_ENTRY_UUID}
69 ;;
70
7189c57f98-2fe5-4dc0-89c1-f3ad0ceff2be)
72 # TOBE_UUID
73 ;;
74
7589c57f98-2fe5-4dc0-89c1-5ec00ceff2be)
76 # DMCRYPT_TOBE_UUID
77 ;;
78
79*)
80 # Not a Ceph device
81 ;;
82
83esac
84
85exit