Saturday, March 20, 2010

Ubuntu 9.10: Mounting and Dismounting Blues

I was using a couple of external USB drives with Ubuntu 9.10 (Karmic Koala).  I found the easiest way to switch them between computers was to wait until they were inactive and then yank the USB cord from one machine and plug it into another.  This had worked pretty well, but then I got this error message:

Unable to unmount DAILY
umount:  /media/DAILY mount disagrees with the fstab
This seemed to have been related to some kind of bug.  I got this after a previous error message:
Could not display "/media/DAILY".
Error:  error stating file '/media/DAILY': Input/output error
Please select another viewer and try again
DAILY was a manually created folder in /media.  I couldn't figure out how to delete it either:  it wasn't visible in "sudo nautilus" and there wasn't an option to delete it in ordinary Nautilus.  Chris Jean fixed a similar problem with this kind of command:
sudo fuser -km /media/DAILY
This seemed like a reasonable command, given some basic information about the fuser command, so I closed down everything else and tried that.  I got this response:
Cannot stat /media/DAILY:  Input/output error
I looked that up.  It didn't seem to be a very common problem.  Several of the entries that came up in that search referred to GRUB, but I wasn't sure what to make of that.  Charles A said the input/output error usually means that a drive is going bad.  Going from something else he said, I did a search for how to mount an NTFS drive by using its UUID.  Ganesh suggested "sudo fdisk -l" to see if DAILY was connected.  It did not appear to be . . . because it wasn't.  I had just pulled out its USB cable a few minutes earlier and had neglected  to plug it back in.  I did that, but now I got this:
Unable to mount DAILY
Error mounting: mount exited with exit code 1: helper failed with:
mount: according to mtab, /dev/sdf5 is already mounted on /media/DAILY
mount failed
I typed "df" and saw that DAILY was mounted at /dev/sdf5.  I clicked on DAILY in Nautilus and got the "Could not display '/media/DAILY'" error shown above.  I got an indication that this was, again, a bug.  I decided to reboot.  That fixed everything for the time being.

Later, I took a different approach.  As advised in an Ubuntu community document, I installed pmount in Synaptic.  The recommended syntax was "pmount /dev/sdb5 DRIVE," where any available location could be used in lieu of sdb5 and where DRIVE is the name of the partition.  If just the drive name is used like this, it will be mounted by default at /media/DRIVE.  But, oops, I mounted it as root, when the whole purpose of pmount was to make it possible for a non-root user to mount a drive.  So I unmounted, typed "exit" to get out of the root prompt, and tried again:  "pmount /dev/sde5 WEEKLY."  Unfortunately, it hung.  I wondered if it was because I had already mounted and disconnected (without unmounting) a device at sde5.  Maybe I needed to use the largest previously unused letter.  I killed Terminal, unplugged and replugged the USB cable on the drive, and as a user in a new Terminal session I typed "df -h" to see what was available.  I already had something mounted as sdf5, so I tried "pmount /dev/sdg5 WEEKLY."  This gave me "device /dev/sdg5 does not exist."  It took me quite a while to discover that, actually, I had not plugged the drive back in after all.  Now it mounted as "WEEKLY_" with an underscore at the end; and when I tried "umount /media/WEEKLY," I got "/media/WEEKLY is not mounted (according to mtab)."  So, OK, I pulled the USB plug, typed "sudo nautilus," went into File System/media, right-clicked, and moved WEEKLY to trash.  I replugged the USB, killed sudo-Nautilus, and at a user prompt typed "df -h" and saw that WEEKLY had reclaimed its old post at /dev/sdd5.  Now it seemed to be working OK.  Later, when I tried using pmount another time, I got some errors, like this:
Error: directory /media/[directory name] is not empty
Error:  device /dev/sdf1 does not exist
I looked at a more detailed pmount documentation page and saw that /dev/sd?? had to be a "block device in /dev."  A forum post told me that I could identify my system's block devices by typing "sudo fdisk -l."  (That's an L, not a one.)  This sobered me up on the question of what my /dev options were.  I really had only one choice as to where to mount the drive, and when I tried pmount there, I got "Error: device /dev/sde5 is already mounted to /media/[partition name]."

(Having run out of time to fiddle with this, I left this post as a draft at that point.  I believe this problem ultimately got solved by a reinstallation.  No further comments on this issue here.)