T-vK/MobilePassThrough

Issue command not found.

ktod16 opened this issue · 12 comments

As you requested...

I tried to run your automatic script but I get some errors:
".......utils/Fedora/29/kernel-param-utils: No such file or directory
after this, it installed a lot of updates and stuff....and at the end errors again.
".........utils/Fedora/29/set-kernel-params: command not found"
".........utils/Fedora/29/nvidia-setup: command not found"

I copied all the script files in both utils and 29 folders to be sure they are everywhere and I get the same errors.

Fyi I added .sh extension (set-kernel-params.sh)and run it separately. this is what I get..

set-kernel-params.sh: line 9: .//home/cris/Downloads/MobilePassThrough-master/utils/../utils/Fedora/29/kernel-param-utils: No such file or directory
Adding kernel parameters...
Adding kernel parameters to enable IOMMU on Intel/AMD CPUs...
set-kernel-params.sh: line 16: addKernelParam: command not found
set-kernel-params.sh: line 17: addKernelParam: command not found
set-kernel-params.sh: line 18: addKernelParam: command not found
Adding a kernel parameter to prevent bluescreens when a VM does MSR reads / writes directly...
set-kernel-params.sh: line 20: addKernelParam: command not found
Adding a kernel parameter to tell dracut to load vfio-pci first...
set-kernel-params.sh: line 22: addKernelParam: command not found
TODO: check if /etc/dracut.conf.d/vfio.conf is necessary / make sure it onyl happens once
(Re)building initramfs for the current kernel...
Applying the kernel parameter changes...
set-kernel-params.sh: line 39: applyKernelParamChanges: command not found

T-vK commented

You are talking about the setup.sh script right? Did you cd into the directory before executing the script?

If you do the following from a terminal it should work:

git clone https://github.com/T-vK/MobilePassThrough.git
cd MobilePassThrough
./setup.sh

You should not try to run the util scripts on their own.

I runed the scripts to see what happens....
Same result ... now..
I guess a new fedora install is coming..
root@unknowne470b8cd7e54 Downloads]# git clone https://github.com/T-vK/MobilePassThrough.git
Cloning into 'MobilePassThrough'...
remote: Enumerating objects: 58, done.
remote: Counting objects: 100% (58/58), done.
remote: Compressing objects: 100% (45/45), done.
remote: Total 58 (delta 21), reused 38 (delta 10), pack-reused 0
Unpacking objects: 100% (58/58), done.
[root@unknowne470b8cd7e54 Downloads]# cd MobilePassThrough
[root@unknowne470b8cd7e54 MobilePassThrough]# ./setup.sh
./setup.sh: line 9: .//home/cris/Downloads/MobilePassThrough/utils/Fedora/29/kernel-param-utils: No such file or directory
Updating software...
Failed to set locale, defaulting to C
Last metadata expiration check: 1:34:40 ago on Wed Mar 6 19:56:49 2019.
Dependencies resolved.
Nothing to do.
Complete!
Installing some useful tools...
Failed to set locale, defaulting to C
Last metadata expiration check: 1:34:42 ago on Wed Mar 6 19:56:49 2019.
Package wget-1.20.1-1.fc29.x86_64 is already installed.
Package curl-7.61.1-10.fc29.x86_64 is already installed.
Package vim-enhanced-2:8.1.994-1.fc29.x86_64 is already installed.
Package screen-4.6.2-6.fc29.x86_64 is already installed.
Package git-2.20.1-1.fc29.x86_64 is already installed.
Package crudini-0.9-3.fc28.noarch is already installed.
Package lshw-B.02.18-18.fc29.x86_64 is already installed.
Package msr-tools-1.3-10.fc29.x86_64 is already installed.
Package sysfsutils-2.1.0-25.fc29.x86_64 is already installed.
Package tunctl-1.5-19.fc29.x86_64 is already installed.
Package remmina-1.3.3-1.fc29.x86_64 is already installed.
Package samba-2:4.9.4-1.fc29.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Installing virtualization software...
Failed to set locale, defaulting to C
Last metadata expiration check: 1:34:44 ago on Wed Mar 6 19:56:49 2019.
Package qemu-2:3.0.0-3.fc29.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Installing the Windows VirtIO Repository...
--2019-03-06 21:31:34-- https://fedorapeople.org/groups/virt/virtio-win/virtio-win.repo
Resolving fedorapeople.org (fedorapeople.org)... 152.19.134.199, 2610:28:3090:3001:5054:ff:fea7:9474
Connecting to fedorapeople.org (fedorapeople.org)|152.19.134.199|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 609
Saving to: '/etc/yum.repos.d/virtio-win.repo'

/etc/yum.repos.d/virtio-win.rep 100%[=======================================================>] 609 --.-KB/s in 0s

2019-03-06 21:31:35 (13.8 MB/s) - '/etc/yum.repos.d/virtio-win.repo' saved [609/609]

Installing virtio-win...
Failed to set locale, defaulting to C
Last metadata expiration check: 1:34:47 ago on Wed Mar 6 19:56:49 2019.
Package virtio-win-0.1.164-1.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
Upgrading to latest virtio-win...
Failed to set locale, defaulting to C
Last metadata expiration check: 1:34:49 ago on Wed Mar 6 19:56:49 2019.
Dependencies resolved.
Nothing to do.
Complete!
Installing virt-viewer so you can connect to the VM for the windows installation
Failed to set locale, defaulting to C
Last metadata expiration check: 1:34:51 ago on Wed Mar 6 19:56:49 2019.
Package virt-viewer-7.0-1.fc29.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
sudo: /home/cris/Downloads/MobilePassThrough/utils/Fedora/29/set-kernel-params: command not found
sudo: /home/cris/Downloads/MobilePassThrough/utils/Fedora/29/nvidia-setup: command not found
./setup.sh: line 14: prepare-vm: command not found
You should probably reboot now!
But first make sure you didn't get any errors above.
After the reboot you might want to run the compatibility-check script.

T-vK commented

Can you create a new script in the MobilePassThrough/ folder put this code into it:

#!/usr/bin/env bash

SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd)
PROJECT_DIR="${SCRIPT_DIR}"
UTILS_DIR="${PROJECT_DIR}/utils"
DISTRO=$("${UTILS_DIR}/distro-info")
DISTRO_UTILS_DIR="${UTILS_DIR}/${DISTRO}"

echo "SCRIPT_DIR: $SCRIPT_DIR"
echo "PROJECT_DIR: $PROJECT_DIR"
echo "UTILS_DIR: $UTILS_DIR"
echo "DISTRO: $DISTRO"
echo "DISTRO_UTILS_DIR: $DISTRO_UTILS_DIR"
echo "kernel-param-utils location: $(dirname "$0")/$DISTRO_UTILS_DIR/kernel-param-utils"

Save it as test.sh and then run the following from the MobilePassThrough/ folder:

chmod +x ./test.sh
./test.sh

Ok fist issue I'm not able to create or put any file in the folder MobilePassThrough (I did reboot already).
I downloaded again from github .zip file and the naming is different. Now test worked.

[root@unknowne470b8cd7e54 MobilePassThrough-master]# chmod +x ./test.sh
[root@unknowne470b8cd7e54 MobilePassThrough-master]# ./test.sh
SCRIPT_DIR: /home/cris/Downloads/MobilePassThrough-master
PROJECT_DIR: /home/cris/Downloads/MobilePassThrough-master
UTILS_DIR: /home/cris/Downloads/MobilePassThrough-master/utils
DISTRO: Fedora/29
DISTRO_UTILS_DIR: /home/cris/Downloads/MobilePassThrough-master/utils/Fedora/29
kernel-param-utils location: .//home/cris/Downloads/MobilePassThrough-master/utils/Fedora/29/kernel-param-utils

T-vK commented

I'd advise you against downloading the zip. You should instead download it by simply cloning the repository using git clone https://github.com/T-vK/MobilePassThrough.git.

Another thing I noticed is that you run all the commands as root. If you don't know exactly what you're doing this can cause all sorts of unwanted results. Can you instead use your normal user account? You may have to enable sudo by adding your user to the wheel group (there are instructions on how to do that on google) if you haven't already.

Then you should retry running these:

sudo rm -rf ./MobilePassThrough 
git clone https://github.com/T-vK/MobilePassThrough.git
cd ./MobilePassThrough
./setup.sh

This will delete the MobilePassThrough folder if it already exists.
If you actually have executed other commands as the root user without knowing exactly what you did, a reinstall would probably be a good idea, if it's not too much effort.

Edit:
I just saw your last post on the other issue where you mentioned that you are very new to Linux and you also said that you followed tutorials that are not meant for notebooks... So I think there could be all sorts of stuff that could prevent my script from operating properly on your system now.
On a fresh Fedora 29 install there should be absolutely no problem and the script should work flawlessly.
I'll get back to you tomorrow if it's still not working.

Ok fedora installed...... same problem as before. So I started "trying" things.
I created again test file you told me...and at a closer look at the results i saw something strange: there is a "./" in front of the path kernel-param-utils location. Is that ok?

CRIPT_DIR: /home/cris/Downloads/MobilePassThrough
PROJECT_DIR: /home/cris/Downloads/MobilePassThrough
UTILS_DIR: /home/cris/Downloads/MobilePassThrough/utils
DISTRO: Fedora/29
DISTRO_UTILS_DIR: /home/cris/Downloads/MobilePassThrough/utils/Fedora/29
kernel-param-utils location: .//home/cris/Downl

so I opened setup.sh an identified some issues and modified as bellow.
source "$DISTRO_UTILS_DIR/kernel-param-utils"

run again ..... one problem solved.

sudo: /home/cris/Downloads/MobilePassThrough/utils/Fedora/29/set-kernel-params: command not found

open again setup.sh sudo $UTILS_DIR/set-kernel-params

another one problem fixed -----> generating addKernelParam comand not found .

open set-kernel-param line 9 becomes source "$DISTRO_UTILS_DIR/kernel-param-utils"

next

sudo: /home/cris/Downloads/MobilePassThrough/utils/Fedora/29/nvidia-setup: command not found

open nvidia-setup
insert source "$DISTRO_UTILS_DIR/kernel-param-utils"
now when I run setup.sh i still get nvidia-setup: command not found.

but I runned nvidia-setup.sh and worked until bios extraction.

the script is again creating some strange paths..... at this point I had to go to sleep and gave up.

extract bios

ddKernelParam: No action required. "nouveau.modeset=0" already exists in GRUB_CMDLINE_LINUX of /etc/default/grub
/home/cris/Downloads/MobilePassThrough/utils/Fedora/29/../../../utils/extract-vbios: line 6: /home/cris/Downloads/MobilePassThrough/utils/utils/distro-info: No such file or directory
Attempting to extract the VBIOS ROM of the Nvidia GPU
This will probably fail. If you know how to fix it please open an issue and tell me.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 69713 0 69713 0 0 42275 0 --:--:-- 0:00:01 --:--:-- 42275
/home/cris/Downloads/MobilePassThrough/utils/utils/nvidia-nvflash.zip: No such file or directory
unzip: cannot find or open /home/cris/Downloads/MobilePassThrough/utils/utils/nvidia-nvflash.zip, /home/cris/Downloads/MobilePassThrough/utils/utils/nvidia-nvflash.zip.zip or /home/cris/Downloads/MobilePassThrough/utils/utils/nvidia-nvflash.zip.ZIP.
chmod: cannot access '/home/cris/Downloads/MobilePassThrough/utils/utils/nvflash_linux': No such file or directory
/usr/bin/vglrun: line 257: /home/cris/Downloads/MobilePassThrough/utils/utils/nvflash_linux: No such file or directory

./setup.sh: line 14: prepare-vm: command not found

So everithing worked until bios extraction ..

T-vK commented

Thanks, you actually found two bugs!

You are right about the setup.sh, it should be source "$DISTRO_UTILS_DIR/kernel-param-utils".
And you are also right about the nvidia-setup missing that line!

I think I have fixed the extract-vbios script now. You can try running it directly. But beware that the vbios extraction script doesn't work on all machines.

T-vK commented

You can alternatively extract the vBIOS using Windows. Either by using GPU-Z or by extracting it from the registry. There are good instructions on Google for that.

You can also try to extract it from a BIOS/UEFI update using VBiosFinder.

Here's how you get that going on Fedora 29:

git clone https://github.com/coderobe/VBiosFinder.git
cd VBiosFinder

sudo dnf install ruby rubygem-bundler ruby-devel p7zip innoextract upx -y

wget https://github.com/LongSoft/UEFITool/releases/download/A55/UEFIExtract_NE_A55_linux_x86_64.zip -O ./UEFIExtract.zip
unzip ./UEFIExtract.zip -d ./3rdparty/

git clone https://github.com/awilliam/rom-parser.git
cd rom-parser
make
cp ./rom-fixer ../3rdparty/
cp ./rom-parser ../3rdparty/
cd ..

bundle install --path=vendor/bundle

Then you get the BIOS/UEFI update from the website.
For instance I took the latest version from that site: https://pcsupport.lenovo.com/de/en/products/LAPTOPS-AND-NETBOOKS/THINKPAD-P-SERIES-LAPTOPS/THINKPAD-P71/downloads/DS121301
and I was able to extract like 6 vBIOS ROMs from it:

wget https://download.lenovo.com/pccbbs/mobiles/n1tuj19w.exe -O packed_bios
./vbiosfinder extract "$(pwd)/packed_bios"

These are the vBIOS ROMs I extracted: Lenovo_P71_VBIOS_ROMs.zip

I guess there are so many because you can buy the P71 with 6 different GPUs. But one of those should work.

Tested again

some things still to be done..

sudo: /home/cris/Downloads/MobilePassThrough/utils/Fedora/29/set-kernel-params: command not found

open again setup.sh ----> sudo $UTILS_DIR/set-kernel-params

another problem fixed -----> generating addKernelParam comand not found .

open set-kernel-param ----> line 9 becomes source "$DISTRO_UTILS_DIR/kernel-param-utils"

next

sudo: /home/cris/Downloads/MobilePassThrough/utils/Fedora/29/nvidia-setup: command not found

remove ".sh" extension from nvidia-setup file.

all works now...
Bios extraction code works. I receive the error that I have to remove Nvidia driver first.
this is not a problem as I extracted the VBIOS from GPU-Z.

NVIDIA Firmware Update Utility (Version 5.414.0)
Simplified Version For OEM Only
Device:01:00:00=10DE:1BB7:17AA:224C GPU
ERROR: In order to avoid the irreparable damage to your graphics
adapter it is necessary to unload the NVIDIA kernel driver first:

            rmmod nvidia

./setup.sh: line 14: prepare-vm: command not found
and there is this last command which is not found but I guess I can create the VM manually
Thaks for your work. It really simplifies the process.

T-vK commented

Sorry for all the inconveniences, I should spend more time on testing when I make code changes.
I'll update the repository when I get my current test notebook running. I still need to finish a bios mod before I can continue though.
I'm glad you managed to figure it out. The prepare-vm line should not have been there.

You don't have to create the VM manually, you can just run start-vm.sh and it will be created for you and from there on you can use run start-vm.sh to start your VM whenever you need it.

First you should change the settings in the beginning of start-vm.sh though. Like the disk size, path to the windows iso etc.

T-vK commented

I just updated the project, refactoring a lot of stuff and adding new features. I think all issues mentioned in here have been fixed by now.