How to umount when the device is busy

It happens all the time doesn’t it? You need to unmount a CD or you want to pack away the external drive but when you try to umount it you get the dreaded “device is busy” message. Wouldn’t it be great if Linux actually told you what was keeping the drive busy? Here we are in 2008, I’m using Ubuntu Gutsy, and that message hasn’t changed in all the years I’ve used Linux.

# umount /media/disk/
umount: /media/disk: device is busy
umount: /media/disk: device is busy

First thing you’ll do will probably be to close down all your terminals and xterms but here’s a better way. You can use the fuser command to find out which process was keeping the device busy:

# fuser -m /dev/sdc1
/dev/sdc1: 538
# ps auxw|grep 538
donncha 538 0.4 2.7 219212 56792 ? SLl Feb11 11:25 rhythmbox

Rhythmbox is the culprit! Close that down and umount the drive. Problem solved!

Ubuntu WiFi problems on the Dell D630 laptop

Wireless networking was always a bit patchy for me on my Dell Latitude D630 while running Ubuntu Gutsy version of Linux. It would work fine for ages and then freeze up suddenly, requiring a hard reboot to get things working (Apache would become unkillable, I guess because it was attached to the broken Wireless networking driver.) Problems always showed up when I transferred large amounts of data between Linux and my Macbook. Files copied fine for a few minutes and then the whole house of cards would collapse. Crash! Boom!

The first time I looked for a solution nothing turned up, but eventually I went searching again, and after digging into all sorts of forums and websites I found the simpe solution on the Dell Linux Wiki:

Create a file called /etc/modprobe.d/blacklist-ipw3945 and add:

blacklist ipw3945

Add to /etc/modules:

iwl3945

Reboot after doing that and all will be fine in the world again! I haven’t had any networking issues since replacing the ipw3945 driver with the iwl3945 one!

Ubuntu Gutsy on the Dell Latitude D630

I previously documented my problems with Ubuntu and the DVD in the D630 but the upgrade to Ubuntu 7.10 Gutsy From Feisty went almost painlessly.

ubuntu 710 upgrade

All the packages downloaded and installed through the nice GUI front end. I was able to work away while they downloaded and for most of the time during install too, but when I rebooted I found that sound wasn’t working! I found this solution but I didn’t want to compile a kernel again. That’s so 90’s and this is 2007! Instead I checked my grub menu.lst and found there was an older 2.6.20 kernel listed there. A quick reboot later and sound works again, and it’s even louder! WiFi never stopped working thankfully but if you’re having problems, the page above explains what you need to install to get it working.

I haven’t tried the eye candy features yet, but so far the system feels springier and lighter, even with the old kernel. Let’s hope it stays that way!

Bah. GIMP 2.4rc3 broke a lot of the Script-fu scripts I use. I read about this somewhere. Time to get my hands dirty in my lomo plugin for starters.

Nice! Gthumb supports RAW images although it takes ages to initially process them initially.

Ubuntu Linux on Dell D630: the DVD

Getting the DVD drive working in Ubuntu Feisty on my Dell D630 laptop was one of the tasks that eluded me until a few minutes ago when I went searching again and found the solution.

At first I tried this and used the ide-generic driver. Linux recognised the drive, but as the page above says, it doesn’t give you any DMA modes. I tried the Bourne Supremacy, just to see if anything would happen, but Totem just sat there and the system became sluggish while the CD made some whirring noises. That’s a sure sign that DMA isn’t working!

That wasn’t going to be satisfactory, so I kept searching. This page and some of the Ubuntu forums suggest loading the “piix” and “ata_piix” modules. I tried to modprobe them without luck, but when I added “piix” to my /etc/modules and rebooted my DVD drive was found!

DMA is now enabled and everything works ok. Even got the film to play in Mplayer and it was very smooth.

# hdparm -i /dev/hda

/dev/hda:

Model=TSSTcorp DVD+/-RW TS-L632D, FwRev=DE04, SerialNo=
Config={ Fixed Removeable DTR10Mbs nonMagnetic }
RawCHS=0/0/0, TrkSize=0, SectSize=0, ECCbytes=0
BuffType=unknown, BuffSize=0kB, MaxMultSect=0
(maybe): CurCHS=0/0/0, CurSects=0, LBA=yes, LBAsects=0
IORDY=on/off, tPIO={min:227,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 *udma2
AdvancedPM=no

# hdparm /dev/hda

/dev/hda:
IO_support = 1 (32-bit)
unmaskirq = 1 (on)
using_dma = 1 (on)
keepsettings = 1 (on)
readonly = 0 (off)
readahead = 256 (on)

How labels saved my life

Well, they made it easier. Saved might be a little strong. When using a Unix based system you use a file called /etc/fstab to designate all the hard drives and external storage like flash cards and where they will mount or live on your filesystem. It’s not quite like the Windows world where everything has a drive letter, although you can use SUBST to get a similar effect on that operating system.

/etc/fstab is easy to maintain when all your drives stay in one place, but since I’m using 3 external drives and a card reader, sometimes the device name /dev/sdX changes for each. It’s horribly frustrating changing entries in fstab just because the card reader wasn’t plugged in when the computer booted into Ubuntu Linux

That all changed when I assigned labels to each drive. Now fstab entries reference those labels instead of devices! The following line,

/dev/sdc1 /media/disk auto rw,user,noauto 0 0

becomes

LABEL=DATA /media/disk auto rw,user,noauto 0 0

So, even if the device changes from sdc1 to sdd1 /media/disk will always mount!

Here’s a great tutorial on how to assign labels to disks, and how to modify your /etc/fstab to support them. It might seem like a pain at first but it’s well worth it!

Open a new window here in Ubuntu Linux

cmdline.png

One of the things I missed a long time ago in Windows completely was the handy “start” command I could type from a command prompt to open a new Windows Explorer window in whatever directory I was in. Can you still do that? Does anyone use Windows from the command prompt any more?

nautilus.png

I have since discovered you can do the same thing in Ubuntu Linux (and any other Linux for that matter of course!). I’m a big fan of Gnome, which uses the Nautilus file manager. If you’re fond of navigating your computer using a terminal, it’s really easy to open a Nautilus window in the current directory. Simply run ‘nautilus .‘ and a new window will open in that directory.

Don’t tell me you’re a keyboard junkie, I am too. I use Vim! Nautilus is still very useful though. Besides it’s obvious use as a file manager It’s dead handy for copying files to a remote server using any number of transmission protocols from ssh and SMB through to plain old ftp. But more on that some other time eh?

Ubuntu's useful apt-get hints

Ubuntu 7.04, or Feisty Fawn as it’s known to it’s friends, has added a neat upgrade to the apt-get tool. For those who don’t know, apt-get is the tool Ubuntu uses to install and remove software. A small problem in the past has been trying to figure out what the name of the package required was.

In Feisty Fawn, if you try to run a command that isn’t installed a small message will be displayed telling you how to install it! The software has to be in your repository, so typing notepad and expecting it to tell you to apt-get install windows isn’t going to happen!

This morning I needed to update my local WPMU work area so …

$ svn update
The program 'svn' is currently not installed. You can install it by typing:
sudo apt-get install subversion

apt-get moo still works too! 🙂

Filter spam through Postfix and Spamassassin

It has been a long time since I used and configured Sendmail, and I don’t miss it one bit now that Postfix is on the scene, but the amount of spam I receive does bother me. My Junk folder had reached 160MB, mostly due to some idiots sending huge spam attachments, but also because spam still works and a majority of the email circulating is spam and not legitimate.

Spamassassin is how we fight back. Unfortunately it needs a reasonably powerful server, gobs of memory and CPU when there’s a lot of incoming email and time to configure. Using spamd/spamc makes things easier on your server but it’s still a hefty price to pay for being spam free.

Here are a few pages I found useful this morning when getting things up and running on my Ubuntu server:

I also recommend running Postgrey to stop some junk mail before it gets into your system at all.

Now, if only there was a Spamassassin for the junk mail and clothes collection leaflets we get to the front door. How’s about a Defense Tower that would fire pellets when it noticed someone with leaflets calling to the door?

Edit: Justin talks about one of Spamassassin’s honeypot traps and about goings on at Blacklist.ie

Shutdown Ubuntu with ctrl-alt-delete

Power cuts are becoming a way of life for many people and here in Blarney we get our fair share of them unfortunately. The second in as many weeks happened this morning and before I could rig up a network cable between my laptop and desktop the UPS powered down and my big noisy desktop died with it. Thankfully without filesystem corruption.

Normally when you press the magic combo of ctrl-alt-delete the machine reboots but in this case it would be much better if the machine did a shutdown. In previous versions of Linux I had to edit /etc/inittab to get the desired effect but that file doesn’t exist in Ubuntu Edgy. Instead you must look at /etc/event.d/control-alt-delete. That file is fairly self explanatory which is all well and good because there’s very little information if you don’t know what to look for.

According to a post here, “Ubuntu replaced init with upstart event daemon”. It’s simple to change it to shutodown. Replace “-r” with “-h” in the following line:
exec /sbin/shutdown/ -r now "Control-Alt-Delete pressed"
No need to run inittab, just hit the magic combo to halt the computer!

PS. thanks so much for all the comments yesterday and the day before. I was bowled over by the response to both posts, especially the Daffodil Day one which struck a chord with many people

That mouse presses all the right buttons

Having just installed Ubuntu Edgy on a squeaky clean partition I’m still migrating some of my settings and programmes from my last Ubuntu install. Why did I reinstall when an upgrade from Dapper already went well? Unfortunately in the course of configuring my Wacom graphics tablet I broke my sound and for the life of me I could not remember how to fix it. That and I was running out of space and there was a nice 28GB NTFS partition doing nothing but taking up space..

Your mouse is probably luckier than some but if some of the buttons on it don’t work then look for the following line in /etc/X11/xorg.conf:
Option "Protocol" "ExplorerPS/2"
and change it to this:
Option "Protocol" "ImPS/2"

I hate middle mouse button clicking on a scroll wheel and this Microsoft mouse is worse than others. The side button works much better for me! Finally, I can press the right button again! 🙂

Oh and good luck if you have a widescreen monitor. My Dell 2405 LCD barfed every time I tried the graphical install. I had to look for the “alternate” cd and do a text install, and then install the proprietary Nvidia drivers and add a suitable modeline to /etc/X11/xorg.conf. I haven’t done that since I don’t know how long ago. Definitely in the last century.