Sunday, 5 September 2010

Adding Windows Vista to make Ubuntu dual boot with two, separate hard drives

If making a dual-boot Windows/Ubuntu system, most of the advice is to install Windows first. However, I already have a nice shiny Ubuntu set-up and wanted to add Windows (Vista). If you can install Ubuntu and Windows on two separate hard drives then it's a breeze. Here's what I did:
  • Install an extra hard drive for Windows and temporarily disconnect the Ubuntu drive
  • Install Windows to the new hard drive using an install CD/DVD (or however)
  • Reconnect the Ubuntu hard drive (and ensure it's the 1st hard drive in the BIOS boot list)
  • Boot to Ubuntu. Run the following
    sudo grub-mkconfig --output=/boot/grub/grub.cfg
    This will detect the Windows drive and add a grub entry. Note this applies to grub2 (i.e. the new grub and not legacy-grub) as used by Ubuntu Lucid Lynx (10.06) and later.
That's it. Reboot and you should see boot item entries for Windows and Ubuntu.

You might find that your grub boot menu is a bit cluttered with old rubbish. See the following post on how to tidy that up.

Wednesday, 4 August 2010

Asus HD 5750 Graphics Card on Ubuntu Lucid (10.04): Drivers & Blank Screen

I recently got a new Asus HD 5750 Formula 1GB video card (Model: EAH5750 FML/2DI/1GD5). The plan was to run this under Ubuntu Lucid Lynx (10.04) and to drive two HD Samsung monitors (SyncMaster P2450H 24" Monitor 1920x1080) from one card using the two digital outputs (1 HDMI and 1 DMI). The Asus card is based on the Radeon 5750 chipset and the heatsink looks like a formula 1 car. Sadly I thought that was quite cool.

I had already installed Ubuntu, stuck the card in and rebooted. Everything worked initially - the BIOS screen appeared and then the Ubuntu logo - very early in the boot up the screen went blank. The appeared to happen about when I would expect the video mode to change. I tried a Live-CD and got the same. What appears to be the problem is that the default drivers for the card that Ubuntu loads simply don't work. It seems to be a fairly common problem if you google it.

The solution is to get the "proper" drivers installed (I used the proprietary drivers). Of course if you have no working screen then that's tricky. I had the additional problem that holding down shift didn't show the grub2 menu at boot, which seems to be a known bug.

Getting the Grub2 Menu to Display

If you're lucky you should be able to get the grub2 menu to display at boot by holding down the shift key - I couldn't. Since my motherboard has a built graphics card I used the BIOS to enable this card (which works fine) and disabled the new card. This allowed me to boot up and log in. I guess I could have ssh'd in if I had set this up. Once logged in I:
  • Edited /etc/default/grub
    • Commented out the following line with a hash
      #GRUB_HIDDEN_TIMEOUT=0
    • Changed the time out to -1 to make it wait for a selection:
      GRUB_TIMEOUT=-1
  • Applied the above changes with:
    sudo update-grub
  • Rebooted the machine (and changed the BIOS back to use the new graphics card)

Installing Proprietary ATI Drivers to Prevent Blank Screen

The default Ubuntu proprietary drivers just don't work with this card. I found the Ubuntu X Team offer an excellent repository for a package of prop drivers rather than having to download them from Asus/ATI. I generally followed the instructions at the cchtml wiki.
  • At boot-up get the grub menu to display (hold down shift or do the above)
  • Select failsafeX from the grub menu and boot with this & log in
  • Add the following repository from Ubunutu X Team:
    sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
    sudo apt-get update
  • Install the driver package (a bit different from the cchtml wiki):
    sudo apt-get install fglrx
  • This last step was crucial for me:
    sudo aticonfig --initial -f
  • Reboot the machine
At this point I could boot with the Asus video card without having to go via failsafeX. To configure the card use the ATI control centre in the under the preferences menu. A little playing around gave me a single huge desktop of 3840x1080 over the two monitors. And it looks rather sweet.

Wednesday, 17 March 2010

Remote-desktops with NX. And how to delete old sessions.

I use NoMachine's (free) NX server on my Ubuntu server to allow me to remote-desktop to Ubunutu from my Windows laptop (where I use the NoMachine's (free) NX client). It's dead clever and well thought out technology, much quicker than VNC or using an X-server (e.g. Xming) and tunnelling through putty. The best feature, however, is that it allows you suspend sessions and resume them later (from a different machine even), it's kind of a GUI version GNU screen for your desktop. Google liked NX so much they wrote their own server!

Note that the free (as in beer) version of the NoMachine server only allows you to have two sessions running concurrently. That's fine for me, but if you want something unrestricted and free (as in speech) try Google's NeatNX or FreeNX. When I tried, neither was particularly simple to get going (though I'm sure this bound to improve, at least for NeatNX if not FreeNX).

That said, one downside of the NoMachine NX server is that if you don't cleanly shut down your server you can leave hanging sessions which can prevent you from logging in. If you get errors like this do the following:

NX> 596 NX> 596 ERROR: NXNODE Ver. 3.4.0-6 (Error id ...)
NX> 596 NX> 596 ERROR: resume session: make commands
NX> 596 NX> 596 ERROR: NXNODE: ERROR: cannot get property monitor.pid for session ...

Log in to your server and look at the /usr/NX/var/db/running directory. If there are files present, delete them, then try reconnecting with your client. That should do the trick!

Saturday, 13 March 2010

Reducing Memory Usage in Ubuntu (9.10 Karmic)

I run Ubuntu on a super-efficient (and thus pretty low spec) machine. I finally got round to installing Ubuntu 9.10 (Karmic Koala) over 8.10 (Intrepid Ibex). The install went smoothly but I straight away noticed the memory usage had gone up by about 15-20% (at a rough guess, and to be fair I only have 256MB to play with). This put me at near 100% memory usage (without even opening any apps) giving increased swapping and a huge decrease in performance.

My first thought was to get rid of any unwanted startups & daemons/services. I installed & started BootUp-Manager (named "bum" ho ho) with:
sudo aptitude install bum
sudo bum

This is what I deactivated:
  • apmd
  • speech-dispatcher
  • winbind
  • hotkey-setup
  • exim4
  • powernowd
  • nullmailer
  • kerneloops
  • bluetooth
  • cups
  • rsync
  • saned
  • pppd-dns
  • dns-clean
  • laptop-mode
  • acpi-support
Hit apply, and then rebooted the machine...

And wow - what a difference! Memory usage is down 25% and performance is better than with 8.10! Makes me think there was a issue with one of the items I removed, but for whatever reason it's done the trick.

Friday, 2 October 2009

Forwarding root & user email

Cron-jobs I run send email to the root user and my user (justin), and I'd like these forwarded to an external email account (like gmail). I tried hard to acheive this with sSMTP and nullmailer but just couldn't get either to work...
The solution was to install postfix (the default MTA in Ubuntu), e.g. sudo apt-get install postfix. The installer gives you various options: choose satellite installation and then give your ISP's smtp server as the relayhost.
If, like me, your chosen smtp server requires authentication (i.e. you have to log in) then there are a few additional steps:
  1. Add the following lines to /etc/postifix/main.cf:
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl/smtp-passwd
    # The following line should be blank after "=" to allow plaintext passwords
    smtp_sasl_security_options =
  2. Check, in the same file, that the relayhost line is now pointing to your isp mail server:
    relayhost = myserver.isp.com
  3. Create a file (e.g. /etc/postfix/sasl/smtp-passwd) containing the user and password like the following:
    myserver.isp.com username:passwd
  4. Turn this text file into a binary db file with:
    sudo postmap hash:/etc/postfix/sasl/smtp-passwd
Finally to forward your root and personal emails to an external email address add .forward files to /home/justin (in my case) and /root/. The root .forward should contain a non-root user name (i.e. justin in my case), and my .forward file should contain the external (gmail) address. Apparently there can be issues fowarding root email to non-local addresses; this way root gets fowarded locally which is then forwarded externally.
Then restart postfix with:/etc/init.d/postfix restart
See this page by David Grant for another view on similar set-up, and reasons why he doesn't like sSMTP.

Wednesday, 17 December 2008

Cygwin, Emacs, Unix on Windows

My new work-place is pretty much a windows-only shop, but I miss having a nice command-line, Perl and emacs to hand.
Though I could get most these things separately I've installed Cygwin and it's quite Joe-Lush. Just run the set-up from the website. Probably best to install some extra packages rather than just the basics; I went for:
  • emacs (for editing)
  • emacs-X11
  • nano (for basic editing)
  • perl (for everything)
  • xclock (for testing X)
If you can bear it, install in C:/cygwin as suggested, it makes things easier. Probably a good idea to copy the setup.exe to the same folder afterwards since you'll be wanting to install more packages at some point, and for this you need setup.exe.

X-server

A few things need tweaking out of the box. Firstly an X-server. If you want to use graphical apps you'll need one of these. Cygwin does come with an X-server but I always found it a bit fiddly; try Xming, it's ace. You need to install it and start it running. It won't do anything much itself, it'll just sit there in the background waiting to display any X applications.

Home Directory

Under Windows XP your default home dir will probably be in the "Documents and Settings" folder. Spaces in your home dir path will most likely cause problems, so change it. Start up cygwin, and create yourself a home directory (e.g. mkdir /home/justin), then edit your /etc/passwd file - you should be able to work out which part of the line to edit for your user (probably the last one), but be careful, if you screw this up there's no easy way to fix it. I'd suggest using the nano editor:
nano /etc/passwd

Setting DISPLAY

To use X you'll need to set your DISPLAY environment variable. Do it from the the command line:
export DISPLAY=localhost:0
It's probably easier to create a .bashrc file in your home dir and add this line to it. Which leads us to...

BASHRC

For some reason your .bashrc might not get read on start-up. Fix this by adding:
. ${HOME}/.bashrc
to your /etc/profile file (note the dot at the start of that line).

Terminal & Putty-for-Cygwin

The terminal emulator that comes with Cygwin is not that great; resizing is nasty, copying and pasting is worse. I use Putty when SSHing around from Windows and it turns out someone has patched Putty to work with Cygwin, god bless them. Take a look at PuttyCyg - download it and copy the 3 or 4 files in the zip file to C:/cygwin/puttycyg for example. Then run puttycyg and save a cygwin session or run directly by creating a Windows short-cut, and within properties set the Target to
C:\cygwin\puttycyg\putty.exe -cygterm -
Perfect.

Fonts

Finally you'll obviously be wanting to use 6x13 as your font, the acknowledged King of Fonts. Get it for Windows from http://www.ank.com.ar/fonts.

Monday, 13 October 2008

Ex Falso - MP3 Tag Editor

I've just discovered Ex Falso, a GUI-based audio-file tag editor (MP3s and everything else). You can manually add and edit tags, create tags based on file names, rename files based on tags, add sequential track numbers, all the general things you need. It's part of the Quod Libet media player, but if you're happy with your media player you can use the Ex Falso editor as stand-alone.

It's a GTK+ app, written in Python and is in the standard Ubuntu repositories:
sudo apt-get install exfalso