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// wrong ELF class: ELFCLASS64
dlopen: /usr/lib/xorg/modules/drivers// 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.

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"
# ./
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

error: # error acpi_walk_namespace() conftest failed!
error: # error pci_dma_mapping_error() conftest failed!
In file included from /tmp/selfgz13934/NVIDIA-Linux-x86_64-275.21/kernel/nv.c:13:
error: #error "NV_PCI_DMA_MAPPING_ERROR() undefined!"
error: #error "NV_ACPI_WALK_NAMESPACE_ARGUMENT_COUNT value unrecognized!"

later I found out that the kernel/ 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 file. First I extracted the driver file using the command 

# ./ -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 file. Below is the diff output for the same.

index 5b10bb1..eb5d192 100755
--- a/kernel/
+++ b/kernel/
@@ -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 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