correct drives bug with uefi mode

This commit is contained in:
primardj 2024-01-24 01:00:49 +00:00
parent 177b5cec3e
commit f4177bdbd4

View file

@ -35,6 +35,7 @@ OPTION available
can be either set or unset. By default is unset.
options=<option> additinal options to give to qemu. By default is
-display gtk -vga qxl
create_disk=<loc_disk> Def a create disk to boot on. Is necessary for using create, or need the variable INSTALLATION_DISK_LOCATION to be set.
"
MAIN_LOCATION="$HOME/virtual_machine"
OPTION="-display gtk \
@ -89,7 +90,7 @@ start_the_vm() {
-net nic \
-net user"$FORWARD",hostname="$VMHOSTNAME" \
-m "$MEMORY" \
-drive file="${MAIN_LOCATION}/${LOCATION}/${VMDRIVE}" \
-drive file="${MAIN_LOCATION}/${LOCATION}/${VMDRIVE}",index=2,id=maindrive,media=disk \
$OPTION
}
@ -132,7 +133,8 @@ CREATE() {
OPTION="$OPTION \
-boot d \
-drive file=$1,media=cdrom"
-drive file=$1,if=none,media=cdrom,id=drive-cd1 \
-device ide-cd,drive=drive-cd1,id=cd1,bootindex=1"
start_the_vm
@ -208,13 +210,16 @@ cd "$( dirname "$( readlink -f "$0" )" )" || exit
# Véréfie qu'il y ait bien un fichier de config pour la vm que l'on tente de démarer dans la cas contraire en génére un.
# possibilitée de générer à nouveau le fichier de config avec vm-start nom-vm init
if [ "$2" == "init" ]
then
INIT "$1"
elif [ ! -f "conf/$1-vm_var.sh" ]
if [ ! -f "conf/$1-vm_var.sh" ]
then
echo "no config file found. creating one in conf/${1}-vm_var.sh"
INIT "$1"
if [ "$2" == "init" ]
then
# Exit, it is the end of the program.
exit 0
fi
fi
#Vérifie si l'option UEFI est set dans le fichier de config. Si oui l'ajoutte aux options.
@ -232,6 +237,11 @@ for (( i=3; i<=$#; i++)); do
"uefi")
set_uefi
;;
"create_disk")
INSTALLATION_DISK_LOCATION="${!i#*=}"
echo "${!i#*=}"
echo "${INSTALLATION_DISK_LOCATION}"
;;
esac
done
@ -261,12 +271,11 @@ case "$2" in
;;
"create")
echo "creating VM"
if [ $# -ge 3 ]
if [ ! "${INSTALLATION_DISK_LOCATION}" == "" ]
then
echo "using image disk $3"
CREATE "$3"
echo "using image disk ${INSTALLATION_DISK_LOCATION}"
CREATE "${INSTALLATION_DISK_LOCATION}"
else
echo "$#"
echo "Error, no image defined." >&2
fi
;;
@ -274,7 +283,11 @@ case "$2" in
echo "suppressing all data of the vm $1"
SUPPRESS "$1"
;;
"*")
"init")
echo "Init volume $1"
INIT "$1"
;;
*)
echo "commande $2 inconnue" >&2
HELP
esac