Friday 27 May 2011

Testing Natty on Nvidia Hardware

The BIG THING about the Natty version of Ubuntu is that it comes with a prettified GUI. It has a pop out panel on the left hand side of the screen containing your launcher icons. This is absolutely NOT the same as Windows 7's task bar icons OR OSX's panel'o'icons because both of them are on the BOTTOM of the screen. Ahem.

Want to see what this looks like with the live cd? Have nvidia hardware? Tough shit. The nvidia driver installed on the live cd is a) open source (yay!) and b) does not support all the bells and whistles that this flashy new panel needs (boo!). So you will have to install the proper nvidia drivers. Which means rebooting. Which is pointless on a live cd.

Oh dear. This is going to be a pain in the fucking arse isn't it? Yes, yes it is.

For a start a couple of useful commands for this kind of fiddling are:

sudo service gdm stop

This stops dead the GUI leaving you to happily fiddle with graphics driver settings.

To restart the GUI you would just restart the gdm service yes? Yes.

sudo service gdm start

OK. So we have shut down the GUI. Now we want to download the nvidia drivers. I am presuming you have internet access from the LiveCD. If not, see my earlier posts on that hilarious situation. Download the drivers with this command:

wget http://uk.download.nvidia.com/XFree86/Linux-x86/270.41.19/NVIDIA-Linux-x86-270.41.19.run

Make the driver file executable:

sudo chmod +x NVIDIA-Linux-x86-270.41.19.run

And run it:

./NVIDIA-Linux-x86-270.41.19.run

You will now get some whining messages about nouveau bollicksing up the whole plan. This is the open source nvidia software we are trying to replace. So lets just [r]e[m]ove the nouveau [mod]ule:

rmmod nouveau

Doesn't fucking work.

sudo rmmod nouveau

Still doesn't fucking work. Google.

sudo rmmod --force nouveau

Oh for fucks sake. It still doesn't fucking work. It turns out the nouveau driver is deeply embedded in the OS. It ain't possible to just remove it. It has taken over something called the framebuffer. Without getting horrendously technical (shorthand for I have no fucking clue) this is the thing that gives you the text command line that you are using. So ubuntu is trying to stop you doing the I.T. equivalent of sawing off the branch you are standing on. If you turn off the framebuffer you will get a blank screen. Which is not great as far as user interfaces go, but still probably a better experience than Windows ME.

At this point you have two choices. First you can disable the in-depth use of nouveau, which will then allow you to remove it without fucking up the framebuffer. This needs to be done at boot time, each and every time you boot the LiveCD. Secondly, you can write a script that forces ubuntu to remove nouveau (fucking up the framebuffer in the process) and then immediately installs the nvidia drivers with the least input necessary.

The benefit with the first option is that you never get left with a blank screen, but it is a pain. The benefit with the second option is that it can all be scripted, but leaves you with a blank screen for several minutes while it installs the drivers. If it fails for any reason during the blank screen period, you're fucked.

So, option one first. Copy your downloaded driver file somewhere safe (USB Key). Or just download it again next time, what do I care. If you are using a LiveCD, reboot your LiveCD. When it starts back up it flashes up a symbol of a keyboard and a hand. Hit any key at that stage and you will get a boot menu. You want to chose to Test Ubuntu. You then want to hit F6 for other boot options.

If you are using the LiveCD image from a USB Key via UNetbootin, then just highlight the "Test..." option and hit the tab key to edit the boot command.

You should now be able to edit the boot command (it is a long string of options. See the joys of grub elsewhere in this blog for info on what this does). At the end of the boot command type in:

nomodeset

Now complete the boot as normal. Copy back, or re-download the nvidia driver to the home directory. Now, hit CTRL+ALT+F1 to get to a text interface, and make sure the driver file is executable:

sudo chmod +x NVIDIA-Linux-x86-270.41.19.run

:and shut down the GUI:

sudo service gdm stop

:and run:

sudo rmmod nouveau

It should now work. You can now install the driver:

sudo ./NVIDIA-Linux-x86-270.41.19.run

And it should eventually install happily. Answer the questions sensibly, ignoring any errors. Then just run this command to restart the GUI:

sudo service gdm start

Bask in the awe of the flashy bar.

Option 2 is handled like this. Boot as normal - no need for any fancy boot commands. Copy back, or re-download the nvidia driver to the home directory. Open a terminal window and paste this code into it to set up your script:

sudo cat > inst_nv.sh << "EOF"
echo 0 > /sys/class/vtconsole/vtcon1/bind
rmmod nouveau
/etc/init.d/consolefont restart
rmmod ttm
rmmod drm_kms_helper
rmmod drm
chmod +x ./NVIDIA-Linux-x86-270.41.19.run
./NVIDIA-Linux-x86-270.41.19.run --accept-license --no-questions --no-nouveau-check --run-nvidia-xconfig --ui=none
service gdm start
EOF
chmod +x ./inst_nv.sh

(What does this script do? Well, the first line is a command which disconnects the frame buffer from the graphics driver. I think. The second command removes the graphics driver. The third command attempts, but I think fails, to restore some sort of text interface. The next three commands remove more unneeded modules connected with the graphics driver. The [chmod] command makes sure that the nvidia file is executable, and the command after that executes it. All the options added onto the execution of the driver package are designed so that it should just install without asking any stupid questions which you will be unable to read. The last command restarts the GUI.)

You now shut down gdm as before from the CTRL+ALT+F1 text interface:

sudo service gdm stop

:and run the script from the text command prompt:

sudo ./inst_nv.sh

Your screen will go blank. Your cd/dvd drive will hopefully spin up and down. After 5 minutes or so, hopefully, you will get a GUI. If it doesn't work, reboot and try option 1.

And hey fucking presto, there is the snazzy new bar.

Admittedly, after all that, it may be a touch underwhelming.

4 comments:

  1. Why all instructions say to firstly stop graphical environment and then download&install drivers? Wouldn't it be more practical to download it first? Even having second computer next to you just for reading rest of the manual, you would still need to manually retype link for the driver to download - not even mentioning checking out nvidia for newer drivers.

    ReplyDelete
  2. Good point. The way I work through these instructions on a regular basis is to pop them in a script. This makes it easy to run often, and it removes the possibility of errors. I have the driver file on by USB Key anyway, so I don't need to download each time.

    You absolutely need to shut down the GUI at some point though, and at that stage you need to start typing in commands. So why not just turn off the GUI to start with and then do everything in the terminal?

    If you have only one machine, and do not want to script, then you would be best to copy all the commands into a text file. That way you can have the text file open on one terminal, while you try desperately to get the sodding thing working on the other terminal.

    For the very brave you could of course [sudo apt-get install lynx] to get a browser that works on the command line!

    ReplyDelete
  3. i wish this was easier to get to, it is retarded what canonical has done. i guess they need more $

    ReplyDelete
  4. Baby, I think the problem is with the open source drivers for nvidia hardware. They work fine in 2D, but not for the flashy bar stuff. In days of yore (2009) you couldn't even get Ubuntu to work properly in 2D without this kind of palaver. So if you used a live CD you would be bereft of stuff like working with your monitor's native resolution unless you farted around with inserting the nvidia drivers into the live environment.

    Still a long way to go though before it is boot and forget.

    ReplyDelete