Page 1 of 10

[HOWTO] make a xzm module driver for NVIDIA video card

Posted: 23 Dec 2018, 23:51
by Rava
(Article originally posted in Russian by Blaze here Porteus и NVIDIA. Собираем актуальный драйвер для видеокарты )
This article is a joint translation effort by Blaze and Rava.
_____________________________

1. Go to the site http://nvidia.com in section ' Drivers > ALL NVIDIA DRIVERS '
Annotation: when you set the default language to be used for a website to something different than English (US), you might get a different menu. In my case I got redirected to https://www.nvidia.com/de-de/ and the menu entry is called Treiber > Alle Nvidia Treiber. Same might happen to you, you might get the menu and language in French, Spanish, Italian, whatever default language you set in your browser.

2. Manually select your NVIDIA video card, as well as the architecture of the Linux - 32-bit (i586) or 64-bit (x86_64) operating system and click on the ' Search ' button

Image

Click the ' Download ' button

Image

4. Press the ' Download ' button

Image

5. Also download 05-devel.xzm and crippled_sources.xzm (Cave! The below URLs to the 2 files are for Porteus 4.0, when you run any other version of Porteus you need to download different versions of 05-devel.xzm and crippled_sources.xzm) Updated kernel version, including crippled_sources.xzm can be obtained according to the topic - How to update kernel in Porteus:

for the Porteus operating system and 32 Bit architecture :

- 05-devel.xzm (i586)
- crippled_sources.xzm (i586)

or 64 Bit architecture :

- 05-devel.xzm (x86_64)
- crippled_sources.xzm (x86_64)


5.1 Download nvidia.sh

Code: Select all

#!/bin/bash
# Build of Nvidia video driver, cleaning and compressing to xzm module for Porteus
# You can use this script for both architectures i586 or x86_64

# Version 2019-07-30

# Written by Blaze <admin at ublaze.ru>
# Modified by fulalas
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Root check
if [ `whoami` != "root" ]; then
	echo -e "\e[1m\e[31mOnly root can run this.\e[0m"
	exit 1
fi

# Creating installer variable and folder
MODULES_FOLDER=$(readlink -f /mnt/live/porteus/modules)
INSTALL_TEMP_FOLDER=/tmp/nvidia-$$
mkdir $INSTALL_TEMP_FOLDER

# Checking and extracting blacklist.xzm
if [ -f blacklist.xzm ]; then
	xzm2dir blacklist.xzm $INSTALL_TEMP_FOLDER &>/dev/null
elif [ -f "$PORTDIR/optional/blacklist.xzm" ]; then
	xzm2dir "$PORTDIR/optional/blacklist.xzm" $INSTALL_TEMP_FOLDER &>/dev/null
elif [ -f "$PORTDIR/base/blacklist.xzm" ]; then
	xzm2dir "$PORTDIR/base/blacklist.xzm" $INSTALL_TEMP_FOLDER &>/dev/null
else
    echo -e "\e[1m\e[31mblacklist.xzm couldn't be found.\e[0m"
	rm -rf $INSTALL_TEMP_FOLDER
    exit 1
fi

# Selective compression and extraction of memory changes
sync; echo 3 > /proc/sys/vm/drop_caches
echo -e '\n\033[1m\e[32m[*]\e[0m\033[1m Compression of memory changes to /tmp/nvidia.tar.gz...\033[0m'
tar czf /tmp/nvidia.tar.gz --exclude={"*/.*","*/.wh.*",".cache","dev","home","mnt","opt","root","run","tmp","var","etc/bootcmd.cfg","etc/ld.so.cache","etc/fstab","etc/random-seed","etc/cups","etc/udev","etc/profile.d","etc/porteus","etc/X11/xorg.conf.nvidia-xconfig-original","lib/firmware","lib/modules/*porteus/modules.*","usr/man","usr/src","usr/bin/gnome-keyring-daemon","usr/lib/gio","usr/lib/gtk-2.0","usr/lib/gtk-3.0","usr/lib/libXvMCgallium.so.1","usr/lib/libbrscandec2.so.1","usr/lib/libgsm.so.1","usr/lib/libudev.so.1","usr/lib/libunrar.so.5","usr/lib64/gio","usr/lib64/gtk-2.0","usr/lib64/gtk-3.0","usr/lib64/libXvMCgallium.so.1","usr/lib64/libbrscandec2.so.1","usr/lib64/libgsm.so.1","usr/lib64/libudev.so.1","usr/lib64/libunrar.so.5","usr/local","usr/share/glib-2.0","usr/share/mime","usr/share/pixmaps","usr/share/applications/mimeinfo.cache","usr/local/share/applications/mimeinfo.cache","usr/share/doc/NVIDIA_GLX-1.0/html","usr/share/doc/NVIDIA_GLX-1.0/sample","usr/share/doc/NVIDIA_GLX-1.0/LICENSE","usr/share/doc/NVIDIA_GLX-1.0/NVIDIA_Changelog","usr/share/doc/NVIDIA_GLX-1.0/README.txt"} -C /mnt/live/memory changes
echo -e "\n\033[1m\e[32m[*]\e[0m\033[1m Extraction of memory changes from /tmp/nvidia.tar.gz to $INSTALL_TEMP_FOLDER...\033[0m"
tar xf /tmp/nvidia.tar.gz --strip 1 -C $INSTALL_TEMP_FOLDER

# Сleaning driver
echo -e "\n\033[1m\e[32m[*]\e[0m\033[1m Cleaning of driver directory...\033[0m"
rm -rf $INSTALL_TEMP_FOLDER/{.cache,dev,home,mnt,opt,root,run,tmp,var}
find $INSTALL_TEMP_FOLDER -type f -maxdepth 1 -delete
find $INSTALL_TEMP_FOLDER -type l -maxdepth 1 -delete
find $INSTALL_TEMP_FOLDER/etc/ -type f -maxdepth 1 -delete
find $INSTALL_TEMP_FOLDER/etc/ -type d ! -iname 'modprobe.d' ! -iname 'OpenCL' ! -iname 'vulkan' ! -iname 'X11' ! -iname 'etc' -maxdepth 1 -exec rm -rf '{}' '+'
rm -f $INSTALL_TEMP_FOLDER/etc/X11/xorg.conf.nvidia-xconfig-original
rm -rf $INSTALL_TEMP_FOLDER/lib/firmware
rm -f $INSTALL_TEMP_FOLDER/lib/modules/*porteus/modules.*
rm -rf $INSTALL_TEMP_FOLDER/usr/{man,src}
rm -f $INSTALL_TEMP_FOLDER/usr/bin/gnome-keyring-daemon
rm -rf $INSTALL_TEMP_FOLDER/usr/lib/{gio,gtk-2.0,gtk-3.0}
rm -f $INSTALL_TEMP_FOLDER/usr/lib/{libXvMCgallium.so.1,libbrscandec2.so.1,libgsm.so.1,libudev.so.1,libunrar.so.5}
rm -rf $INSTALL_TEMP_FOLDER/usr/lib64/{gio,gtk-2.0,gtk-3.0}
rm -f $INSTALL_TEMP_FOLDER/usr/lib64/{libXvMCgallium.so.1,libbrscandec2.so.1,libgsm.so.1,libudev.so.1,libunrar.so.5}
rm -rf $INSTALL_TEMP_FOLDER/usr/local
rm -rf $INSTALL_TEMP_FOLDER/usr/share/{glib-2.0,mime,pixmaps}
rm -f $INSTALL_TEMP_FOLDER/usr/{,local/}share/applications/mimeinfo.cache
rm -rf $INSTALL_TEMP_FOLDER/usr/share/doc/NVIDIA_GLX-1.0/{html,sample,LICENSE,NVIDIA_Changelog,README.txt}

# Adding vdpau hardware video decode rule
if [ -f /etc/profile.d/vdpau.sh ]; then
	mkdir -p $INSTALL_TEMP_FOLDER/etc/profile.d
	cp -a /etc/profile.d/vdpau.sh $INSTALL_TEMP_FOLDER/etc/profile.d
	sed -i 's|#export VDPAU_DRIVER="nvidia"|export VDPAU_DRIVER="nvidia"|' $INSTALL_TEMP_FOLDER/etc/profile.d/vdpau.sh
	sed -i 's|export VDPAU_DRIVER="va_gl"|#export VDPAU_DRIVER="va_gl"|' $INSTALL_TEMP_FOLDER/etc/profile.d/vdpau.sh
else
	echo -e "\n\e[1m\e[31mvdpau.sh couldn't be found. Hardware video decode won't work properly.\e[0m"
fi

# Getting driver version
case $(arch) in
	i486)	LIBDIR="/usr/lib"
			;;
	x86_64)	LIBDIR="/usr/lib64"
			;;
	*)		LIBDIRSUFFIX="/usr/lib"
			;;
esac
DRIVER_FILE=$(find $LIBDIR/libEGL_nvidia.so* \! -type l)
DRIVER_VERSION=${DRIVER_FILE: -6}

# Creating final module
MODULE_FILENAME=08-nvidia-$DRIVER_VERSION-k.$(uname -r)-$(cat /etc/porteus-version | cut -d '-' -f2)-$(arch).xzm
dir2xzm $INSTALL_TEMP_FOLDER/ /tmp/$MODULE_FILENAME 2>/dev/null
mv /tmp/$MODULE_FILENAME $MODULES_FOLDER

# Removing temporary files
rm -f /tmp/nvidia.tar.gz
rm -f /tmp/nvidia.xzm
rm -rf $INSTALL_TEMP_FOLDER

# Reboot
echo -e "\n\e[1m\e[32m[DONE]\e[0m \e[1mYou can find your Nvidia driver module in \e[96m$MODULES_FOLDER\e[0m"
echo -e "\e[1m>>> Now you can reboot Porteus via \e[92mreboot\e[0m \e[1mcommand <<<\e[0m\n"
5.2 Download blacklist.xzm to block loading nouveau
/etc/modprobe.d/nvidia-installer-disable-nouveau.conf

Code: Select all

# generated by nvidia-installer
blacklist nouveau
options nouveau modeset=0
6. Copy 05-devel.xzm, crippled_sources.xzm, blacklist.xzm to /porteus/base/

7. Restart Porteus in ' Text mode '
Image

8. Login as root - type in terminal these data from root account by default:

Code: Select all

root
toor
Image

9. Copy NVIDIA-Linux-x86-340.96.run (current version at the time of this writing, or a differnt version needed for your card), nvidia.sh to the /tmp directory.
Note. Nvidia driver and nvidia.sh can to be located not only at /tmp.
If your PC has a small amount of memory (RAM) - recommendation to put these stuff on the Linux partition (e.g. ext2, ext3, ext4, etc...), for example /mnt/partition-of-your-hard-drive
Warning! This file system are must to support Unix / Linux File Permissions.
For convenience, you can use the Midnight Commander. Enter the command

Code: Select all

mc
  • in the right column of Midnight Commander, open the directory /tmp
  • in the left column of the Midnight Commander, find the files NVIDIA-Linux-x86-340.96.run and vdpau.sh
  • copy these files from the left column to the right column with an open /tmp directory and press F10
Or start mc with the known paths e.g. like so (put your actual source folder name in here instead of my example)

Code: Select all

mc /mnt/path/to/nvidia-files /tmp
Image

10. Then enter the commands:

Code: Select all

cd /tmp
chmod +x NVIDIA-Linux-x86-340.96.run 
chmod +x nvidia.sh 
./NVIDIA-NVIDIA-Linux-x86-340.96.run
11. A message will appear.

Code: Select all

Please read the following LICENSE and then select either "Accept" to accept the license and continue with the installation, or select "Do Not Accept" to abort the installation.
Image

After reading, select and confirm the message by clicking ' Accept '. Now the driver will compile.

Image

12. If you compile the driver for the x86_64 architecture, then you will get the message:

Code: Select all

Install NVIDIA's 32-bit compatibility libraries?
  • if you want to play Windows games via Wine or Steam, you will need to answer 'Yes'.
    Note. If you answered 'Yes', then you need to install Wine and 0050-compat32-multilib-lite-x86_64 (if you have a 64-bit operating system)
    link for x86 | link for x86_64
  • if you don't want to play Windows games via Wine or Steam, you will need to disagree and choose 'No'.
13. Confirm the following message

Code: Select all

Please read the following LICENSE and then select either "Accept" to accept the license and continue with the installation, or select "Do Not Accept" to abort the installation.
Image

We answer positively by choosing ' Yes '

14. A message will appear.

Code: Select all

Your X configuration file has been successfully updated. Installation of the NVIDIA Accelerated Graphics Driver for Linux-x86 (version: 340.96) is now comleted.
Image

depending on the architecture it may be

Code: Select all

Your X configuration file has been successfully updated. Installation of the NVIDIA Accelerated Graphics Driver for Linux-x86_64 (version: 340.96) is now comleted.
Click ' OK '

15. In the terminal, enter the command to build the xzm module, the subsequent cleaning of unnecessary trash and its reassembly.

Code: Select all

./nvidia.sh
The nvidia-390.87-k.4.18.5-porteus-v4.0-x86_64.xzm module (you will have a different module name) will be copied to /mnt/sdXx/porteus/modules (where Xx, the letter and partition number of your Porteus folder)

Other examples of module names:
  • nVidia-340.96-porteus-v3.2rc2-i586.xzm
  • nVidia-340.96-porteus-v3.2rc2-x86_64.xzm
16. After which Porteus will be rebooted. For it run this command:
Note. If need you can remove blacklist.xzm from /porteus/base/ or move it to another place.

Code: Select all

reboot
That's all - download Porteus in the usual ' Graphics mode ' mode and use all the charms of the NVIDIA driver.

Screenshots :
Image

Image

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 24 Dec 2018, 01:00
by Ed_P
:victory: Wow!!

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 24 Dec 2018, 08:36
by Rava
Ed_P wrote:
24 Dec 2018, 01:00
:victory: Wow!!
Indeed, Blaze did a good work. I just added the info that you need to get the correct versions when downloading 05-devel.xzm and crippled_sources.xzm. (#5 of the list)
So, kudos to him. :celebrate3:

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 24 Dec 2018, 17:20
by Blaze
All credits for the English translation to Rava
I just fixed some things..

I updated step 16 (English version too) and in my Russian version I tweak step 5:
5. Also download 05-devel.xzm and crippled_sources.xzm (Note: The links below are for Porteus 4.0, when you run any other version of Porteus, you need to download different versions 05-devel.xzm and crippled_sources.xzm. Updated kernel version, including crippled_sources.xzm can be obtained according to the topic - How to update kernel in Porteus:

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 24 Dec 2018, 17:46
by Rava
Blaze wrote:
24 Dec 2018, 17:20
I updated step 16 (English version too) and in my Russian version I tweak step 5:
I was thinking in a more general way when writing the additional text for step 5. But I like your approach adding info about updated kernel.

I added this :
Updated kernel version, including crippled_sources.xzm can be obtained according to the topic - How to update kernel in Porteus:
Now me thinks both the Russian and English version should be quite similar again, right?

(And, at least in my book, that should be like so, sinve the only difference is All credits for the English translation to Rava
I just fixed some things..

a different language, and that should not change the details of any HOWTO, at least change details only superficially.)

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 24 Dec 2018, 17:52
by Blaze
Rava wrote:
24 Dec 2018, 17:46

I added this :
Updated kernel version, including crippled_sources.xzm can be obtained according to the topic - How to update kernel in Porteus:
Now me thinks both the Russian and English version should be quite similar again, right?
Right, but this topic How to update kernel in Porteus in Russian too :)

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 29 Dec 2018, 14:36
by Rava
Update

I added the following annotation in a smaller font size to #1 to clarify, in case a different language setup from the user's browser setup might throw a user off the track:
Rava wrote:
23 Dec 2018, 23:51
1. Go to the site http://nvidia.com in section ' Drivers > ALL NVIDIA DRIVERS '
Annotation: when you set the default language to be used for a website to something different than English (US), you might get a different menu. In my case I got redirected to https://www.nvidia.com/de-de/ and the menu entry is called Treiber > Alle Nvidia Treiber. Same might happen to you, you might get the menu and language in French, Spanish, Italian, whatever default language you set in your browser.

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 10 Jan 2019, 07:34
by Rava
There are some issues to be solved with Blaze's script nvidia.sh

It keeps all recent files and folders unrelated to the nvidia driver files and needed libraries including softlinks, which, in my case, is a lot of softlinks that I use on all of my personalized Porteus versions, e.g. the softlink /x always pointing to the boot media of the current running Porteus system, e.g. to /mnt/sda1 or /mnt/sdb1, and all these files and folders are not deleted in the resulting nvidia driver module.

Also, it keeps the version of the compiled driver wrong. E.g. compiled driver for two kernels, both using the NVIDIA-Linux-x86_64-340.107.run file, and I presume instead of the * in the file name

Code: Select all

nvidia-*-k.4.19.8-porteus-v●●●-x86_64.xzm
nvidia-*-k.4.20.0-porteus-v●●●-x86_64.xzm
it should e.g. be "nvidia-340.107-k.4.20.0-porteus-v●●●-x86_64.xzm" instead.

For now, my lazy butt solution is to xzm2dir the just created module once again and delete all files and folders that are not part of the nvidia driver, kernel module or needed libraries, and then create a new fixed version including the correct driver version number, e.g. resulting in 010-nvidia-340.107-for-k4.20.0-Porteus-v●●●-x86_64_rav.xzm

"●●●" is the correct identified Porteus version, e.g. "4.0" or "3.1".

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 10 Jan 2019, 15:45
by Blaze
If you use additional modules, then it is acceptable that their data may be included in the nvidia module.
Can you write the wrong folder(s) and file(s) from additional modules (I need the full correct path to each folders and files)?
Can you share your nvidia xzm module with the trash of additional folders and files.
Thanks.

What's wrong in the name nvidia-390.87-k.4.18.5-porteus-v4.0-x86_64.xzm?

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 10 Jan 2019, 15:55
by Rava
Blaze wrote:
10 Jan 2019, 15:45
If you use additional modules, then it is acceptable that their data may be included in the nvidia module.
Can you write the wrong folder(s) and file(s) from additional modules (I need the full correct path to each folders and files)?
Can you share your nvidia xzm module with the trash of additional folders and files.
Thanks.
I PM you a list. When I still got the original modules, I might have deleted these already. But I plan on making one for 4.20.1 so then I can PM you the list.
Blaze wrote:
10 Jan 2019, 15:45
What's wrong in the name nvidia-390.87-k.4.18.5-porteus-v4.0-x86_64.xzm?
Nothing would have been wrong with that name. Seems I was not very precise with my above post. The actual module name would have been
nvidia-*-k.4.18.5-porteus-v4.0-x86_64.xzm


Yes, an actual literal * instead of the nvidia driver version!

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 10 Jan 2019, 16:06
by Blaze
Rava wrote:
10 Jan 2019, 15:55
Nothing would have been wrong with that name. Seems I was not very precise with my above post. The actual module name would have been
nvidia-*-k.4.18.5-porteus-v4.0-x86_64.xzm


Yes, an actual literal * instead of the nvidia driver version!
I downloaded NVIDIA-Linux-x86_64-410.93.run and cheked it:

Code: Select all

guest@porteus:/tmp$ ls -l | grep -i nvidia | awk '{print $9}'
NVIDIA-Linux-x86_64-410.93.run
guest@porteus:/tmp$ echo /tmp/nvidia-$(ls /tmp/*.run | basename -s .run *.run | cut -d '-' -f4)-k.$(uname -r)-$(cat /etc/porteus-version | cut -d '-' -f2)-$(arch).xzm
/tmp/nvidia-410.93-k.4.20.0-porteus-v5.0-x86_64.xzm
guest@porteus:/tmp$
:)

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 10 Jan 2019, 16:15
by Rava
Well, I not used your code above but used the nvidia.sh

Using the above code indeed creates the correct filename:

Code: Select all

root@porteus:/tmp# ls -l NVIDIA-Linux-x86_64-340.107.run 
-rwxr--r-- 1 root root 70233686 Dec 29 18:50 NVIDIA-Linux-x86_64-340.107.run
root@porteus:/tmp# echo /tmp/nvidia-$(ls /tmp/*.run | basename -s .run *.run | cut -d '-' -f4)-k.$(uname -r)-$(cat /etc/porteus-versiomakesn | cut -d '-' -f2)-$(arch).xzm
/tmp/nvidia-340.107-k.4.20.0-porteus-v●●●-x86_64.xzm
●●● is the correct Porteus version. ;)

But as quoted above, using nvidia.sh as quoted from this thread did not:

Code: Select all

nvidia-*-k.4.19.8-porteus-v●●●-x86_64.xzm
nvidia-*-k.4.20.0-porteus-v●●●-x86_64.xzm

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 10 Jan 2019, 16:55
by Ed_P
Rava wrote:
10 Jan 2019, 15:55
Seems I was not very precise with my above post. The actual module name would have been
nvidia-*-k.4.18.5-porteus-v4.0-x86_64.xzm
:%)
Rava wrote:
10 Jan 2019, 07:34
then create a new fixed version including the correct driver version number, e.g. resulting in 010-nvidia-340.107-for-k4.20.0-Porteus-v●●●-x86_64_rav.xzm
brokenman's (?) existing naming convention shown here: http://ponce.cc/porteus/x86_64/current/drivers/

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 12 Jan 2019, 05:08
by Rava
^
What is "Hilighting" and why have you put it into someone others quote instead of putting it below the quote like so:
_________________________________________
Mister_Typo wrote:something someother somefurther
(highlighting by me)
_________________________________________

as it should be, since your post looks like that the author of the original quote, in this case yours truly, did wrote "Hilighting mine" in his original post.

Re: [HOWTO] make a xzm module driver for NVIDIA video card

Posted: 12 Jan 2019, 09:31
by Blaze
Ok. Script was updated.