diff --git a/ceph-keyring-create-initial b/ceph-keyring-create-initial index cf81d3d..43d4eb9 100755 --- a/ceph-keyring-create-initial +++ b/ceph-keyring-create-initial @@ -15,4 +15,4 @@ ceph-authtool "$fname" --gen-key -n client.admin \ --cap mon 'allow *' \ --cap osd 'allow *' \ --cap mgr 'allow *' \ - --cap mds 'allow' + --cap mds 'allow *' diff --git a/ceph-osd-create-on-all-disks b/ceph-osd-create-on-all-disks new file mode 100755 index 0000000..ebc932d --- /dev/null +++ b/ceph-osd-create-on-all-disks @@ -0,0 +1,9 @@ +#!/bin/sh + +lsblk -b | awk '/^sd/ { print $1 " " $4/(1024^4) }' | +( + while read disk size; do + /opt/ungleich-tools/ceph-osd-create-start /dev/$disk hdd $size + + done +) diff --git a/ceph-osd-create-start b/ceph-osd-create-start index 405b3c2..e38db4e 100755 --- a/ceph-osd-create-start +++ b/ceph-osd-create-start @@ -20,15 +20,15 @@ magic="ceph osd volume v026" set -x set -e -if [ $# -ne 3 ]; then - echo "$0 disk class osdweight" +if [ $# -lt 2 ]; then + echo "$0 disk class [osdweight]" echo "class = hdd or ssd" exit 1 fi export DEV=$1;shift export CLASS=$1; shift -export WEIGHT=$1; shift + uuid_metadata=$(uuidgen) uuid_block=$(uuidgen) @@ -42,15 +42,14 @@ dev_block="/dev/disk/by-partuuid/$uuid_block" --partition-guid="0:$uuid_metadata" \ --typecode=0:4fbd7e29-9d25-41b8-afd0-062c0ceff05d \ --mbrtogpt -- $DEV - /sbin/udevadm settle --timeout=600 - # Using gdisk --largest-new does not change the name or set guid; # So use 2 steps instead /sbin/sgdisk --largest-new=0 --mbrtogpt -- $DEV /sbin/udevadm settle --timeout=600 + lastpart=$(gdisk -l $DEV | tail -n1 | awk '{ print $1 }') /sbin/sgdisk --change-name="${lastpart}:ceph block" \ --partition-guid="${lastpart}:$uuid_block" \ @@ -58,7 +57,6 @@ lastpart=$(gdisk -l $DEV | tail -n1 | awk '{ print $1 }') --mbrtogpt -- $DEV /sbin/udevadm settle --timeout=600 - /sbin/mkfs -t xfs -f -i size=2048 -- "$dev_metadata" mountpath=/var/lib/ceph/osd/ceph-${osd_id} @@ -85,6 +83,14 @@ touch "$mountpath/sysvinit" ceph-osd --cluster ceph -i "${osd_id}" --mkfs chown -R ceph:ceph "$mountpath" +if [ $# -eq 1 ]; then + WEIGHT=$1; shift +else + devname=$(readlink -f $dev_block) + nodev=$(echo $devname | sed 's,/dev/,,') + WEIGHT=$(lsblk -l -b | awk "/^$nodev/ { print \$4/(1024^4) }") +fi + ceph osd crush add osd.${osd_id} ${WEIGHT} host=$(hostname) echo "$metadata_dev /var/lib/ceph/osd/ceph-${osd_id} xfs noatime 0 0" >> /etc/fstab diff --git a/ceph-pool-create b/ceph-pool-create old mode 100644 new mode 100755 index 891347e..531f236 --- a/ceph-pool-create +++ b/ceph-pool-create @@ -1,9 +1,12 @@ #!/bin/sh -pool=$1; shift +if [ $# -ne 2 ]; then + echo "$0 name pgs" + exit 1 +fi -echo "This script is not finished to create pool $pool" +name=$1; shift +pg=$1;shift -exit 1 - -ceph osd pool application enable +ceph osd pool create "$name" "$pg" +ceph osd pool application enable "$name" rbd diff --git a/disk-create-fresh-gpt b/disk-create-fresh-gpt new file mode 100755 index 0000000..76d8a1a --- /dev/null +++ b/disk-create-fresh-gpt @@ -0,0 +1,5 @@ +#!/bin/sh + +disk=$1 + +printf 'g\nw' | fdisk $disk diff --git a/remove-all-partitions b/remove-all-partitions new file mode 100755 index 0000000..60456d4 --- /dev/null +++ b/remove-all-partitions @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ $# -ne 1 ]; then + echo $0 disk-to-be-deleted + exit 1 +fi + +disk=$1 + +sgdisk -Z "$disk" +dd if=/dev/zero of=$disk bs=1M count=10 diff --git a/remove-all-partitions-from-all-disks b/remove-all-partitions-from-all-disks new file mode 100755 index 0000000..7df5220 --- /dev/null +++ b/remove-all-partitions-from-all-disks @@ -0,0 +1,5 @@ +#!/bin/sh + +for disk in $(fdisk -l | grep "^Disk /dev" | sed -e 's/Disk //' -e 's/:.*//'); do + sgdisk -Z "$disk" +done