ungleich-tools/ceph/ceph-osd-activate-all
2021-09-12 07:42:39 +02:00

51 lines
1.3 KiB
Bash
Executable file

#!/bin/sh
# Nico Schottelius, 2018-02-20
# Copyright ungleich glarus ag
set -e
set -x
tmpdir=$(mktemp -d)
# XFS based partition scheme
for dev in $(fdisk -l | awk '$6 ~/Ceph/ { print $1 }'); do
if mount | grep ^$dev ; then
echo Skipping $dev, already mounted
continue
fi
mount "$dev" "$tmpdir"
id=$(cat "${tmpdir}/whoami")
# Chown the dev device to be accessible for ceph
chown ceph:ceph "${tmpdir}/block"
umount "$dev"
dir="/var/lib/ceph/osd/ceph-$id"
mkdir -p "$dir"
mount "$dev" "$dir"
if [ -e /etc/monit ]; then
/opt/ungleich-tools/monit-ceph-create-start "osd.$id"
else
/etc/init.d/ceph start "osd.$id"
fi
done
# LVM based / manual does not work atm:
# + grep ceph.block_device
# + sed -e s/.*ceph.osd_id=// -e s/,.*//
# + ceph-volume lvm activate --no-systemd 112
# --> UnboundLocalError: local variable 'tags' referenced before assignment
#for osdid in $(lvs -o lv_tags | grep ceph.block_device| sed -e 's/.*ceph.osd_id=//' -e 's/,.*//'); do
# ceph-volume lvm activate --no-systemd $osdid
# /opt/ungleich-tools/monit-ceph-create-start "osd.$osdid"
#done
# Activate all volumes in the OS
vgchange -ay
# Using this with a fake /bin/systemctl
ceph-volume lvm activate --all
rmdir "$tmpdir"