Thursday, July 28, 2011

Compiling Nvidia driver for Debian Squeeze 64bit.

Update (2) : It seems that the display driver fails to load with
dlopen: /usr/lib/xorg/modules/extensions//libglx.so: wrong ELF class: ELFCLASS64
----
----
dlopen: /usr/lib/xorg/modules/drivers//nvidia_drv.so: wrong ELF class: ELFCLASS64
After some googling, I found that the my system was installed with 32bit userland libraries (blame it on the DVD that came with my linux magazine), even though I have a amd64bit kernel.

So I re-installed the machine with the amd64 netinstall official CD downloaded from Debian, installed all necessary packages (list is given below), and re-run the installer again. Of-course, before running the installer, I have switched off GDM3 and added the black-list-configuration.
Packages
binutils
linux-headers-2.6.32-5-amd64
build-essential


cat /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
# generated by nvidia-installer
blacklist nouveau
options nouveau modeset=0
As expected every thing now compiles normally (appart from the CC error, which can be corrected by setting CC env variable to /usr/bin/gcc-4.3, but  I didn't do that), all libraries and drivers were installed correctly and my Xorg works great, no error in /var/log/Xorg.0.log

All my posts regarding Nvidia driver is now invalid. Learned a good lesson also, read, read, read the documentation, specially the Nvidia's.
___________________________________________________________________________________

Update (1) : no need for all the below mentioned changes, set the CC environment variable with "-m64"  and re-run the installer directly.
# export CC="/usr/bin/gcc-4.3 -m64"
# ./NVIDIA-Linux-x86_64-275.21.run
Finally I was able to compile the latest version of Nvidia 64bit driver (NVIDIA-Linux-x86_64-275.21) for my Debian Squeeze 64bit. I was getting errors like

/tmp/selfgz13934/NVIDIA-Linux-x86_64-275.21/kernel/conftest.h:38:2:
error: # error acpi_walk_namespace() conftest failed!
/tmp/selfgz13934/NVIDIA-Linux-x86_64-275.21/kernel/conftest.h:42:2:
error: # error pci_dma_mapping_error() conftest failed!
In file included from /tmp/selfgz13934/NVIDIA-Linux-x86_64-275.21/kernel/nv.c:13:
/tmp/selfgz13934/NVIDIA-Linux-x86_64-275.21/kernel/nv-linux.h:248:2:
error: #error "NV_PCI_DMA_MAPPING_ERROR() undefined!"
/tmp/selfgz13934/NVIDIA-Linux-x86_64-275.21/kernel/nv-linux.h:253:6:
warning: "NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT" is not defined
/tmp/selfgz13934/NVIDIA-Linux-x86_64-275.21/kernel/nv-linux.h:255:8:
warning: "NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT" is not defined
/tmp/selfgz13934/NVIDIA-Linux-x86_64-275.21/kernel/nv-linux.h:261:2:
error: #error "NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT value unrecognized!"

later I found out that the kernel/configtest.sh is failing to compile acpi_walk_namespace and acpi_walk_namespace and thus was unable to create object file configtest$$.o. 

So I tried an easy way by modifying the configtest.sh file. First I extracted the driver file using the command 

# ./NVIDIA-Linux-x86_64-275.21.run -x

This will create a folder named NVIDIA-Linux-x86_64-275.21 in the current folder. Change directory to ./NVIDIA-Linux-x86_64-275.21/kernel and modify the configtest.sh file. Below is the diff output for the same.

index 5b10bb1..eb5d192 100755
--- a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -955,7 +955,7 @@ compile_test() {
             $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
             rm -f conftest$$.c

-            if [ -f conftest$$.o ]; then
+            if [ ! -f conftest$$.o ]; then
                 rm -f conftest$$.o
                 echo "#define NV_ACPI_WALK_NAMESPACE_PRESENT" >> conftest.h
                 echo "#define NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT 6" >> conftest.h
@@ -1105,7 +1105,7 @@ compile_test() {
             $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
             rm -f conftest$$.c

-            if [ -f conftest$$.o ]; then
+            if [ ! -f conftest$$.o ]; then
                 echo "#define NV_PCI_DMA_MAPPING_ERROR_PRESENT" >> conftest.h
                 echo "#define NV_PCI_DMA_MAPPING_ERROR_ARGUMENT_COUNT 2" >> conftest.h
                 rm -f conftest$$.o

The idea is very simple, just added an ' ! ' to the " if " condition, where configtest.sh checks if the file configtest$$.o exists or not. Also please not that on Debian Squeeze the NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT takes only 6 arguments not 7. 

rerun ./nvidia-installer from the root folder where you extracted the Nvidia driver files.

Hope this would solve issues with Nvidia driver for some one.

Friday, July 22, 2011

Alsa Mixer - Unmute from command line.

Here are the commands that can be used to unmute audio on an Ubuntu system.

amixer set PCM  100% unmute
amixer set Headphone  100% unmute
amixer set Master  100% unmute

Found useful for alarm.

Sunday, July 10, 2011

How to reduce the size of a LVM2 loggical volume

For example to reduce the size of a logical volume /home to 10 GB, follow the commands listed below.

# umount /home
# resize2fs /dev/VolGroup00/homevol 10G
# lvreduce -L 10G /dev/VolGroup00/homevol
# fsck -f /dev/VolGroup00/homevol
# mount /home

Friday, July 8, 2011

Perl one liner for In-Place editing.

Three perl single liner for In-Place editing. In all of the cases, the command replaces all occurrence of word 'target' with 'replace'.

With backup.
$ perl -pe 's/target/replace/g' < input.txt > output.txt
$ perl -i.bak -pe 's/target/replace/g' inout.txt
With out backup. 
$ perl -i -pe 's/target/replace/g' input.txt