Skip to content

Commit

Permalink
Merge pull request #23 from Cray-HPE/MTL-2284
Browse files Browse the repository at this point in the history
MTL-2284 New Hypervisor Partition Scheme
  • Loading branch information
rustydb authored Oct 19, 2023
2 parents 178431a + 450fef1 commit 05cbecf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
42 changes: 31 additions & 11 deletions crucible/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
# TODO: Rewrite script in Python or Go.

mount -L data
rm -f /tmp/fstab && touch /tmp/fstab

##############################################################################
# constant: METAL_FSOPTS_XFS
#
Expand Down Expand Up @@ -78,9 +80,13 @@ oval_drive_scheme=LABEL
oval_drive_authority=ROOTRAID
vm_drive_scheme=LABEL
vm_drive_authority=VMSTORE
vm_index=0
vm_letter_counter=({0..9} {a..z} _)
yc=11

metal_disks=2
metal_boot_size_end=5
metal_boot_size=5
metal_root_size=50
metal_md_level=mirror
metal_minimum_disk_size=16

Expand Down Expand Up @@ -304,14 +310,20 @@ _find_boot_disk_overlayfs_spec() {
function partition_os {
local disks
IFS=" " read -r -a disks <<< "$@"
local metal_boot_size_end
local metal_root_size_end

metal_boot_size_end="${metal_boot_size}"
metal_root_size_end="$((metal_boot_size_end + ${metal_root_size}))"

local boot_raid_parts=()
local oval_raid_parts=()
for disk in "${disks[@]}"; do

parted --wipesignatures -m --align=opt --ignore-busy -s "/dev/$disk" -- mklabel gpt \
mkpart esp fat32 2048s "${metal_boot_size_end}GB" set 1 esp on \
mkpart primary xfs "${metal_boot_size_end}GB" 100%
mkpart primary xfs "${metal_boot_size_end}GB" "${metal_root_size_end}GB" \
mkpart primary xfs "${metal_root_size_end}GB" 100% \

# NVME partitions have a "p" to delimit the partition number, add this in order to reference properly in the RAID creation.
if [[ "$disk" =~ "nvme" ]]; then
Expand All @@ -320,6 +332,10 @@ function partition_os {

boot_raid_parts+=( "/dev/${disk}1" )
oval_raid_parts+=( "/dev/${disk}2" )

mkfs.xfs -f -L "${vm_drive_authority}_${vm_letter_counter[yc]}" "/dev/${target}${nvme:+p}1" || echo >&2 "Failed to create ${vm_drive_authority}_${vm_letter_counter[yc]}"
printf '% -18s\t% -18s\t%s\t%s %d %d\n' "${vm_drive_scheme}=${vm_drive_authority}_${vm_letter_counter[yc]}" /vms xfs "$METAL_FSOPTS_XFS" 0 0 >> /tmp/fstab
((++yc))
done

# metadata=0.9 for boot files.
Expand Down Expand Up @@ -350,7 +366,9 @@ function partition_vm {
fi

partprobe "/dev/${target}"
mkfs.xfs -f -L ${vm_drive_authority} "/dev/${target}${nvme:+p}1" || echo >&2 "Failed to create ${vm_drive_authority}"
mkfs.xfs -f -L "${vm_drive_authority}_${vm_index}" "/dev/${target}${nvme:+p}1" || echo >&2 "Failed to create ${vm_drive_authority}_${vm_index}"
printf '% -18s\t% -18s\t%s\t%s %d %d\n' "${vm_drive_scheme}=${vm_drive_authority}_${vm_index}" /vms xfs "$METAL_FSOPTS_XFS" 0 0 >> /tmp/fstab
vm_index="$((vm_index + 1))"
partprobe "/dev/${target}"
}

Expand Down Expand Up @@ -618,9 +636,9 @@ function setup_overlayfs {
{
printf '% -18s\t% -18s\t%s\t%s %d %d\n' "${boot_drive_scheme}=${boot_drive_authority}" /metal/recovery vfat defaults 0 0
printf '% -18s\t% -18s\t%s\t%s %d %d\n' "${oval_drive_scheme}=${oval_drive_authority}" / xfs defaults 0 0
printf '% -18s\t% -18s\t%s\t%s %d %d\n' "${vm_drive_scheme}=${vm_drive_authority}" /vms xfs "$METAL_FSOPTS_XFS" 0 0
printf '% -18s\t% -18s\t%s\t%s %d %d\n' tmpfs /tmp tmpfs "$METAL_FSOPTS_TMPFS" 0 0
} > "${mpoint}/${live_dir}/${overlayfs_spec}/etc/fstab"
cat /tmp/fstab >> "${mpoint}/${live_dir}/${overlayfs_spec}/etc/fstab"

# udev
if [ ! -f /etc/udev/rules.d/80-ifname.rules ]; then
Expand Down Expand Up @@ -707,16 +725,18 @@ EOF
error=1
fi

umount "${mpoint}"
rmdir "${mpoint}"

mkdir -p /data
mount -L data /data
mkdir -p /vms
mount -L VMSTORE /vms
mkdir -p /vms/assets
rsync -rltDv /data/ /vms/assets/
umount /vms
mkdir -p /vms/store0
# Always mount the first VMSTORE index.
mount -L VMSTORE_0 /vms/store0
mkdir -p /vms/store0/assets
rsync -rltDv /data/ /vms/store0/assets/
umount /vms/store0

umount "${mpoint}"
rmdir "${mpoint}"
if [ "$error" -ne 0 ]; then
return 1
fi
Expand Down
6 changes: 3 additions & 3 deletions crucible/scripts/management-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set -euo pipefail

BOOTSTRAP=/srv/cray/bootstrap
CAPACITY=100
MGMTCLOUD=/vms/cloud-init/management-vm
MGMTCLOUD=/vms/storeA/cloud-init/management-vm
INTERFACE=lan0
SSH_KEY=/root/.ssh/
DEPLOYMENT_SSH_KEY_TYPE=ed25519
Expand Down Expand Up @@ -153,7 +153,7 @@ sed -i'' '/deployment_id$/d' /root/.ssh/authorized_keys
cat "$SSH_TEMP/deployment_id.pub" >> /root/.ssh/authorized_keys
rm -rf "$SSH_TEMP"

if virsh pool-define-as management-pool dir --target /var/lib/libvirt/management-pool; then
if virsh pool-define-as management-pool dir --target /vms/storeA/pools/fawkes-management-storage-pool; then
virsh pool-start --build management-pool
virsh pool-autostart management-pool

Expand All @@ -162,7 +162,7 @@ if virsh pool-define-as management-pool dir --target /var/lib/libvirt/management
# This way, the ending capacity will match what the user specified.
virsh vol-create-as --pool management-pool --name management-vm.qcow2 "$((CAPACITY - 1))G" --prealloc-metadata --format qcow2
management_vm_image=''
management_vm_image="$(find /vms/assets -name "management-vm*.qcow2")"
management_vm_image="$(find /vms/store0/assets -name "management-vm*.qcow2")"
virsh vol-upload --sparse --pool management-pool management-vm.qcow2 --file "${management_vm_image}"
virsh vol-resize --pool management-pool management-vm.qcow2 "${CAPACITY}G"
fi
Expand Down

0 comments on commit 05cbecf

Please sign in to comment.