Compare commits

...

2 Commits

3 changed files with 12 additions and 11 deletions

View File

@ -4,10 +4,10 @@
core_count=$(nproc --all) core_count=$(nproc --all)
# Check if nproc --all returns a numerical value greater than 2 # Check if nproc --all returns a numerical value greater than 2
if (( core_count > 1 )); then if (( core_count > 2 )); then
echo "System has more than 1 core (nproc --all: $core_count)." echo "System has more than 2 core (nproc --all: $core_count)."
else else
echo "Warning: System has only $core_count core)." echo "Warning: System has only $core_count core)."
echo "The script requires at least two cores" echo "The script requires at least four cores"
exit 1 # Exit with an error code to indicate the condition is not met exit 1 # Exit with an error code to indicate the condition is not met
fi fi

View File

@ -39,14 +39,15 @@ virt-install \
--machine q35 \ --machine q35 \
--name "$vm_name" \ --name "$vm_name" \
--boot uefi \ --boot uefi \
--cpu host-model,topology.sockets=1,topology.cores=2,topology.threads=1 \ --cpu host-model,topology.sockets=1,topology.cores=2,topology.threads=2 \
--vcpus 2 \ --vcpus 4 \
--memory 2048 \ --memory 4096 \
--video virtio \ --video virtio \
--channel unix,target.type=virtio,target.name=org.qemu.guest_agent.0 \
--autoconsole none \ --autoconsole none \
--console pty,target.type=virtio \ --console pty,target.type=virtio \
--sound none \ --sound none \
--network type=user,model=virtio \ --network type=default,model=virtio \
--controller type=virtio-serial \ --controller type=virtio-serial \
--controller type=usb,model=none \ --controller type=usb,model=none \
--controller type=scsi,model=virtio-scsi \ --controller type=scsi,model=virtio-scsi \
@ -55,7 +56,7 @@ virt-install \
--rng /dev/urandom,model=virtio \ --rng /dev/urandom,model=virtio \
--disk path=/var/lib/libvirt/images/"$vm_name".img,format=raw,bus=virtio,cache=writeback,size=10 \ --disk path=/var/lib/libvirt/images/"$vm_name".img,format=raw,bus=virtio,cache=writeback,size=10 \
--location=https://download.fedoraproject.org/pub/fedora/linux/releases/42/Everything/x86_64/os/ \ --location=https://download.fedoraproject.org/pub/fedora/linux/releases/42/Everything/x86_64/os/ \
--initrd-inject "./dishes/$vm_name".cfg \ --initrd-inject ./dishes/"$vm_name".cfg \
--extra-args "inst.ks=file:$vm_name.cfg" --extra-args "inst.ks=file:/$vm_name.cfg"
echo "virt-install command executed with VM name: $vm_name" echo "virt-install command executed with VM name: $vm_name"

View File

@ -6,8 +6,8 @@ total_memory=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
# Convert to MiB by dividing by 1024 (since MemTotal is in KiB) # Convert to MiB by dividing by 1024 (since MemTotal is in KiB)
total_memory_mb=$(( total_memory / 1024 )) total_memory_mb=$(( total_memory / 1024 ))
if [[ "$total_memory_mb" -lt "2048" ]]; then if [[ "$total_memory_mb" -lt "4096" ]]; then
echo "Not enough RAM: The system has only ${total_memory_mb}MiB of RAM, but at least 2048 MiB is required." echo "Not enough RAM: The system has only ${total_memory_mb}MiB of RAM, but at least 4096 is required."
exit 1 exit 1
else else
echo "Sufficient memory available. System has ${total_memory_mb}MiB of RAM." echo "Sufficient memory available. System has ${total_memory_mb}MiB of RAM."