简体   繁体   中英

Problem with executing bash script to execute windows VM install

Bash script

#!/bin/sh
WINIMG=~/vm/Win10_21H2_English_x64.iso
VIRTIMG=~/vm/virtio-win-0.1.217.iso
qemu-system-x86_64 --enable-kvm -drive driver=raw,file=~/vm/win10.img,if=virtio -m 6144 \
-net nic,model=virtio -net user -cdrom ${WINIMG} \
-drive file=${VIRTIMG},index=3,media=cdrom \
-rtc base=localtime,clock=host -smp cores=4,threads=8 \
-usb -device usb-tablet \
-net user,smb=$HOME

Output of run

qemu-system-x86_64: -drive driver=raw,file=~/vm/win10.img,if=virtio: Could not open '~/vm/win10.img': No such file or directory

Not sure why it responds as "No such file or directory", as i have checked all three files are there as seen below

loo@loo-System-Product-Name:~/Desktop/lunaLand/vm$ ls
virtio-win-0.1.217.iso  vm.sh  Win10_21H2_English_x64.iso  win10.img

The following script should resolve the "No such file or directory" error:

#!/bin/sh
WINIMG=~/Desktop/lunaLand/vm/Win10_21H2_English_x64.iso
VIRTIMG=~/Desktop/lunaLand/vm/virtio-win-0.1.217.iso
qemu-system-x86_64 --enable-kvm -drive driver=raw,file=~/Desktop/lunaLand/vm/win10.img,if=virtio -m 6144 \
-net nic,model=virtio -net user -cdrom ${WINIMG} \
-drive file=${VIRTIMG},index=3,media=cdrom \
-rtc base=localtime,clock=host -smp cores=4,threads=8 \
-usb -device usb-tablet \
-net user,smb=$HOME

The files are located on the desktop in the lunaland/vm folder and not in a vm folder in user loo's home directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM