From 7a711b5733e1ea6b913e0d2e1ef322e7c69149a6 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Thu, 1 May 2025 21:27:27 -0400 Subject: [PATCH] improvements based on experience of a bunch of disk migrations --- .../files/simple/usr/local/bin/create-vm | 15 +++--- .../files/simple/usr/local/bin/vm-disk | 48 +++++++++++-------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/roles/kvmhost/files/simple/usr/local/bin/create-vm b/roles/kvmhost/files/simple/usr/local/bin/create-vm index 2c3fa8d..25a7612 100755 --- a/roles/kvmhost/files/simple/usr/local/bin/create-vm +++ b/roles/kvmhost/files/simple/usr/local/bin/create-vm @@ -94,7 +94,9 @@ On vm hosts with local storage, disks are grouped into sets of 3 disks, in which per-vm raid arrays are created by creating lvm logical volumes and then creating an mdadm or btrfs array. While the disks themselves are not technically a single raid array, that is their functional purpose so we -call them each an array. +call them each an array. The default is btrfs. Please consider it a rule +to avoid creating nested btrfs subvolumes. We've never seen a good +reason to do it, but it can create difficulties. If there is more than one array on a single machine, we need to specify which one to use by passing the name of one its VG members with @@ -127,7 +129,8 @@ to undo what it has done. Be sure to read the output! -m --mdraid : Create an ext4 filesystem on mdraid. We force this option on hosts older than t11. WARNING: this could take an hour or more for a big disk, run - in screen or tmux. + in screen or tmux. TODO: figure this out for + savannah-virsh. Example: $0 www.gnu.org 5000 512 2 flidas @@ -632,10 +635,10 @@ EOF # volume group names, separated by command at the start. disk_arrays=( , - # community0p 3.46t rust disks as of 2024-09-07 - vgata-WDC_WD4004FZWX-00GBGB0_NHG3PK4M - vgata-ST4000DM000-1F2168_Z3028BKA - vgata-WDC_WD40EZRX-00SPEB0_WD-WCC4E0304017 + # community0p 20t rust disks as of 2025-05-01 + vgata-TOSHIBA_MG10AFA22TE_9430A1FLFM8J + vgata-TOSHIBA_MG10AFA22TE_9440A01ZFM8J + vgata-TOSHIBA_MG10AFA22TE_9440A022FM8J , # community0p 925g as of 2024-09-07 vgata-Samsung_SSD_850_EVO_1TB_S3PJNB0J902536K diff --git a/roles/kvmhost/files/simple/usr/local/bin/vm-disk b/roles/kvmhost/files/simple/usr/local/bin/vm-disk index 4c86da4..8172cb8 100755 --- a/roles/kvmhost/files/simple/usr/local/bin/vm-disk +++ b/roles/kvmhost/files/simple/usr/local/bin/vm-disk @@ -22,7 +22,7 @@ usage() { cat <&2 exit 1 fi -for disk in "${all_disks[@]}"; do check-source-dev; done - -### fancy filename for our generated script, eg: 2025-03-19-001 -mkdir -p /root/vm-disk-generated -date_stamp=$(date +%F) -for (( i=0; i < 999; i++ )); do - script_gen="/root/vm-disk-generated/$date_stamp-$(printf %03d $i)" - if [[ ! -s $script_gen ]]; then - break - fi -done - -initialize-script-gen target_dev_regex='^[a-z]+$' for disk in "${all_disks[@]}"; do @@ -262,9 +254,25 @@ for disk in "${all_disks[@]}"; do exit 1 fi - m virsh detach-disk "$source_vm" "$target_dev" --persistent + virsh detach-disk "$source_vm" "$target_dev" --persistent done +if [[ $subcmd == detach ]]; then + exit 0 +fi + +### fancy filename for our generated script, eg: 2025-03-19-001 +mkdir -p /root/vm-disk-generated +date_stamp=$(date +%F) +for (( i=0; i < 999; i++ )); do + script_gen="/root/vm-disk-generated/$date_stamp-$(printf %03d $i)" + if [[ ! -s $script_gen ]]; then + break + fi +done + +initialize-script-gen + vm-disk-wipe -- 2.25.1