答案1
我最近遇到了同样的问题,除了上面引用的 URL 之外没有找到更多信息。
在 Maas 和 Curtin 开发人员的帮助下,我能够提出一个工作场景,并在这篇博客中进行了描述邮政。
我希望它可以为您和其他面临同样问题的人提供帮助。
答案2
如果您可以通过命令行进行操作,我可以这样做:
-> 准备
PROFILE=maas-mgmt
maas login ${PROFILE} http://localhost/MAAS/api/2.0 \
<Your API-Key>
maas ${PROFILE} machines read | jq '.[] | select(.status_name=="Ready") | {hostname: .hostname, system_id: .system_id, status: .status, in: [.interface_set[].name]|sort }' --compact-output
HOST_ID=<put in the id of your system> # eg. abcxyz
-> 第一步:清理
删除所有 LV
ALL_LVS=$(maas ${PROFILE} volume-groups read ${HOST_ID} | jq '.[] |."logical_volumes"[] | "\(.system_id):\(.id)"' --compact-output | sed 's/"//g')
for THIS_LV in ${ALL_LVS} ; do
THIS_HOST_ID=$(echo ${THIS_LV} | awk -F":" '{print $1}')
THIS_LV_ID=$(echo ${THIS_LV} | awk -F":" '{print $2}')
maas ${PROFILE} block-device unmount ${THIS_HOST_ID} ${THIS_LV_ID}
maas ${PROFILE} block-device delete ${THIS_HOST_ID} ${THIS_LV_ID}
done
删除所有卷组
ALL_VG_IDS=$(maas ${PROFILE} volume-groups read ${HOST_ID} | jq '.[] | .id')
for VG_ID in ${ALL_VG_IDS} ; do
maas ${PROFILE} volume-group delete ${HOST_ID} ${VG_ID}
done
删除所有 md-RAID 设备
MD_RAIDS=$(maas ${PROFILE} raids read ${HOST_ID})
MD_DEVICES=$(echo ${MD_RAIDS} | jq '.[] | .id')
for MD_DEVICE in ${MD_DEVICES} ; do
SYSTEM_ID=$(echo $PARTITION | awk -F":" '{print $1}')
DEVICE_ID=$(echo $PARTITION | awk -F":" '{print $2}')
ID=$(echo $PARTITION | awk -F":" '{print $3}')
maas ${PROFILE} raid delete ${HOST_ID} ${MD_DEVICE}
done
#
删除所有分区
BLOCK_DEVICES=$(maas ${PROFILE} block-devices read ${HOST_ID})
PARTITIONS=$(echo ${BLOCK_DEVICES} | jq '.[] | ."partitions"[] | "\(.system_id):\(.device_id):\(.id)"' --compact-output | sed 's/"//g')
for PARTITION in ${PARTITIONS} ; do
SYSTEM_ID=$(echo $PARTITION | awk -F":" '{print $1}')
DEVICE_ID=$(echo $PARTITION | awk -F":" '{print $2}')
ID=$(echo $PARTITION | awk -F":" '{print $3}')
maas ${PROFILE} partition delete ${SYSTEM_ID} ${DEVICE_ID} ${ID}
done
删除所有 bcache 设备
BCACHE_DEVICE_IDS=$(maas ${PROFILE} bcaches read ${HOST_ID} | jq '.[] .id')
for MY_ID in ${BCACHE_DEVICE_IDS} ; do
maas ${PROFILE} bcache delete ${HOST_ID} ${MY_ID}
done
删除所有 bcache 缓存集
BCACHE_CACHE_SETS=$(maas ${PROFILE} bcache-cache-sets read ${HOST_ID} | jq '.[] .id')
for MY_ID in ${BCACHE_CACHE_SETS} ; do
maas ${PROFILE} bcache-cache-set delete ${HOST_ID} ${MY_ID}
done
删除所有分区
BLOCK_DEVICES=$(maas ${PROFILE} block-devices read ${HOST_ID})
PARTITIONS=$(echo ${BLOCK_DEVICES} | jq '.[] | ."partitions"[] | "\(.system_id):\(.device_id):\(.id)"' --compact-output | sed 's/"//g')
for PARTITION in ${PARTITIONS} ; do
SYSTEM_ID=$(echo $PARTITION | awk -F":" '{print $1}')
DEVICE_ID=$(echo $PARTITION | awk -F":" '{print $2}')
ID=$(echo $PARTITION | awk -F":" '{print $3}')
maas ${PROFILE} partition delete ${SYSTEM_ID} ${DEVICE_ID} ${ID}
done
-> 第二步:新配置
这只是我的设置,请根据您的需要进行调整:
获取所需设备的 ID
ALL_BLOCKDEVICES=$(maas ${PROFILE} block-devices read ${HOST_ID})
P3600_ID=$(echo ${ALL_BLOCKDEVICES} | jq '.[] | select(.model|contains("SSDPEDME020T4D"))|.id')
P3700_ID=$(echo ${ALL_BLOCKDEVICES} | jq '.[] | select(.model|contains("SSDPEDMD020T4D"))|.id')
ALL_HDDS=$(echo ${ALL_BLOCKDEVICES} | jq '.[] | select(.tags[]|contains("rotary"))| .id')
BCACHE_CACHE_DEVICE_1_ID=$(maas ${PROFILE} bcache-cache-sets create ${HOST_ID} cache_device=${P3600_ID} | jq '. .id')
创建系统分区和 bcache 设备
declare -i MY_COUNTER=0
RAID_BOOT_IDS=""
RAID_ROOT_IDS=""
for MY_HDD in ${ALL_HDDS} ; do
if [[ ${MY_COUNTER} -lt 2 ]] ; then
## the first two devices will be mixed used for system _and_ OSD
BOOT_PART_ID=$(maas ${PROFILE} partitions create ${HOST_ID} ${MY_HDD} size=2G bootable=yes | jq '. .id')
RAID_BOOT_IDS="${RAID_BOOT_IDS} ${BOOT_PART_ID}"
SYSTEM_PART_ID=$(maas ${PROFILE} partitions create ${HOST_ID} ${MY_HDD} size=400G | jq '. .id')
RAID_ROOT_IDS="${RAID_ROOT_IDS} ${SYSTEM_PART_ID}"
MAX_SIZE=$(maas ${PROFILE} block-device read ${HOST_ID} ${MY_HDD} | jq '. .available_size')
MY_BCACHE_PART_ID=$(maas ${PROFILE} partitions create ${HOST_ID} ${MY_HDD} size=${MAX_SIZE} | jq '. .id')
maas ${PROFILE} bcaches create ${HOST_ID} cache_set=${BCACHE_CACHE_DEVICE_1_ID} backing_partition=${MY_BCACHE_PART_ID} cache_mode=writeback name=bcache${MY_COUNTER}
else
## all others will be OSD only devices
maas ${PROFILE} bcaches create ${HOST_ID} cache_set=${BCACHE_CACHE_DEVICE_1_ID} backing_device=${MY_HDD} cache_mode=writeback name=bcache${MY_COUNTER}
fi
MY_COUNTER+=1
done
创建用于启动的软件 RAID
BOOT_RAID_PARTITION_ID_1=$(awk '{print $1}' <<<${RAID_BOOT_IDS})
BOOT_RAID_PARTITION_ID_2=$(awk '{print $2}' <<<${RAID_BOOT_IDS})
RAID_BOOT_ID=$(maas ${PROFILE} raids create ${HOST_ID} name="md/boot" level=raid-1 partitions={${BOOT_RAID_PARTITION_ID_1},${BOOT_RAID_PARTITION_ID_2}} | jq ' . | .virtual_device | .id')
maas ${PROFILE} block-device format ${HOST_ID} ${RAID_BOOT_ID} fstype=ext4 label="boot"
maas ${PROFILE} block-device mount ${HOST_ID} ${RAID_BOOT_ID} mount_point="/boot"
为系统卷组创建软件 RAID,为“/”创建逻辑卷
ROOT_RAID_PARTITION_ID_1=$(awk '{print $1}' <<<${RAID_ROOT_IDS})
ROOT_RAID_PARTITION_ID_2=$(awk '{print $2}' <<<${RAID_ROOT_IDS})
RAID_ROOT_ID=$(maas ${PROFILE} raids create ${HOST_ID} name="md/root" level=raid-1 partitions={${ROOT_RAID_PARTITION_ID_1},${ROOT_RAID_PARTITION_ID_2}} | jq ' . | .virtual_device | .id')
HOST_NAME=$(maas ${PROFILE} machines read | jq '.[] | select(.system_id=="'$HOST_ID'") | .hostname'| sed 's/"//g')
VOL_GR_ID=$(maas ${PROFILE} volume-groups create ${HOST_ID} name=${HOST_NAME}_SYSTEM_VG uuid=$(uuidgen) block_devices=${RAID_ROOT_ID} | jq '. .id')
ROOT_LV_ID=$(maas ${PROFILE} volume-group create-logical-volume ${HOST_ID} ${VOL_GR_ID} name=root-lv size=200G uuid=$(uuidgen) | jq '. .id')
maas ${PROFILE} block-device format ${HOST_ID} ${ROOT_LV_ID} fstype=ext4 uuid=$(uuidgen) label="ROOT"
maas ${PROFILE} block-device mount ${HOST_ID} ${ROOT_LV_ID} mount_point="/"
####### Alternativ? #########################################
### without LV, only one root-device
# maas ${PROFILE} block-device format ${HOST_ID} ${RAID_ROOT_ID} fstype=ext4 label="root"
# maas ${PROFILE} block-device mount ${HOST_ID} ${RAID_ROOT_ID} mount_point="/"
#############################################################