Add rbd image synth script
This commit is contained in:
parent
eebcdd032b
commit
86e20322e2
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh
|
||||
# Resynthesize a RBD image and it's metadata
|
||||
# caskd - CC0
|
||||
# This has been useful to me to get rid of a manually removed rbd image that still had selfmananged object snapshots
|
||||
# References:
|
||||
# - https://fnordahl.com/2017/04/17/ceph-rbd-volume-header-recovery/
|
||||
# - https://aaronlauterer.com/blog/2023/ceph-rbd-how-does-it-store-data/
|
||||
|
||||
# NOTES:
|
||||
# Snapshots have the snap sequence id in the snapshot omapkey and the latest on snap_seq
|
||||
# You can get the snapseq via rados listsnaps
|
||||
|
||||
name="nnd-rootfs"
|
||||
ID="888c078eb3c49a"
|
||||
pool="libvirt"
|
||||
|
||||
set -ex
|
||||
|
||||
# Create header
|
||||
rados -p "$pool" put rbd_header."$ID" /dev/null
|
||||
echo -en \\x3d\\x00\\x00\\x00\\x00\\x00\\x00\\x00 | rados -p "$pool" setomapval rbd_header."$ID" features
|
||||
echo -en \\x17\\x00\\x00\\x00rbd_data."$ID" | rados -p "$pool" setomapval rbd_header."$ID" object_prefix
|
||||
echo -en \\x16 | rados -p "$pool" setomapval rbd_header."$ID" order
|
||||
echo -en \\x00\\x00\\x00\\x00\\x04\\x00\\x00\\x00 | rados -p "$pool" setomapval rbd_header."$ID" size
|
||||
echo -en \\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00 | rados -p "$pool" setomapval rbd_header."$ID" snap_seq
|
||||
|
||||
# Add name for image
|
||||
echo -en \\x0e\\x00\\x00\\x00"$ID" | rados -p "$pool" put rbd_id."$name" /dev/stdin
|
||||
|
||||
# Add image to rbd_directory
|
||||
echo -en \\x0e\\x00\\x00\\x00"$ID" | rados -p "$pool" setomapval rbd_directory name_"$name"
|
Loading…
Reference in New Issue