PCMCIA/USB drive removal (Was Re: [ltp] Re: Linux-Thinkpad digest,
Vol 1 #880 - 11 msgs)
FeRD
linux-thinkpad@linux-thinkpad.org
Wed, 04 May 2005 02:32:59 -0400
chris wrote:
>On Mon, 2005-05-02 at 12:01 +0200,
>linux-thinkpad-request@linux-thinkpad.org wrote:
>
>
>>Hi all,
>>
>>I'm having an issue with my T42 running Mandrake 10.2 which has
>>actually has existed for a few releases of MDK.
>>
>>I seem to be able to use my PCMCIA data cards only once in each
>>slot. If I put it in a slot a second time, it seems to insert
>>correct according to the syslog but when i try to mount it I get:
>>
>> mount: special device /dev/hde1 does not exist
>>
>>[...]
>>
>>
>I never had a PCMCIA before, but from my experience with my USB drive, I
>need to umount it before I unplug it from the computer otherwise when
>time I mount it again, I need to increment the number by 1.
>
>e.g, mount /dev/sda1 /mnt/usb
>
>unplug
>
>to mount it again, I need to
>
>mount /dev/sda2 /mnt/usb
>
>but if I umount before I unplug, I don't have to change the mount
>device.
>
>how about "fdisk -l" see what it says?
>
>Chris
>
>
>
Well, certainly, you need to unmount the filesystems before unplugging
the drive from the computer. Not only is that a good idea for keeping
the system happy, it should be considered a strict requirement. Unless
you're not attached to your data, of course. It sounds like the original
poster could be forgetting to do that, which would cause Wonkiness(tm).
You're also quite correct about the non-unmounting (...ow) causing drive
identifiers to be inctremented, but my guess is your memory is slightly
off on the details -- what you SHOULD have seen is that /dev/sda1 became
/dev/sdb1 (not /dev/sda2) when you re-plugged the drive... because,
without unmounting, the system is STILL holding /dev/sda1 as mounted, so
it doesn't recycle the /dev/sda* links; when the drive comes back and
identifies itself as a USB drive, ide-scsi assigns it the first
available device identifiers, /dev/sdb*. Unplug-without-unmounting and
replug again, and you'll get a /dev/sdc to add to your collection.
Doing this if you're running HAL also makes a mess of your /media
directory (I'm using FC3 standard setup as my model, as it's the only
distro I've been using my USB drive with), as your re-mounted
(/dev/sdb*) drive avoids its old /media/HOME, /media/WAREZ, ... monuts
and gets called stuff like /media/HOME1, /media/WAREZ1, etc. That should
be considered a further sign that you're doing something wrong/bad. :)
If you don't want to be an un-hoopy frood and have all of these icky
things to happen to you, always know where your filesystem is. As an
added bonus, you won't see your disk burst into metaphorical flames one
day when it's detached at an inopportune time -- trust me, I had it
happen by "accident" [read: my negligent idiocy] due to a loose power
cable running across the floor; a FAT32 partition can REALLY turn itself
into scrambled bits if someone decides to walk on the cable while the
drive is in the middle of updating the FATs... serves me right for using
FAT32 I suppose -- always unmount ALL the partitions on your
USB/PCMCIA/whatever drive before you detach it. The kernel hates
surprises, even on its birthday.
Unfortunately, USB was designed without any sort of hardware 'detach'
notification -- analogous to the eject button on a CD-ROM drive, or more
accurately the ejector-release switch on the UltraBay -- that would
allow the device to request that the operating system prepare for its
departure. So that notification has to be done in software. Windows
provides the system tray "Prepare for device removal" icon, and Mac OS X
clings to its oh-so-amusingly-bass-ackwards
toss-the-drive-icon-in-the-trash mnemonic to implement the unmount
functionality. Linux's present "standard" setups don't provide methods
as quick/automated (and only Windows' is appropriately
hardware-device-granular), but at least the latest gamin builds make
Linux MUCH less psychotic about holding on to filesystem mounts than
Windows is. If I have to REBOOT to get permission to disconnect my
external USB drive many more times, I'm going to end up booting straight
into Linux and mkfs'ing over the Win2000 partition on my T22 out of
sheer, blind rage.
If you're like me and there isn't a lot of variety to your external
filesystems (I have a single USB2 HDD, which HAL always mounts the same
way, and I always unmount the same), make a panel or desktop icon that
runs a script containing the necessary commands or something.
Hell, I'm so paranoid now I don't physically detach until I've done a
successful rmmod on usb-storage! :) (No, I'm not kidding.)
-Peril-Sensitive FeRD
P.S> Marvin was an optimist.