LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How to swap USB flashdrives without conflict... (https://www.linuxquestions.org/questions/slackware-14/how-to-swap-usb-flashdrives-without-conflict-296159/)

erraticassassin 03-01-2005 02:43 AM

How to swap USB flashdrives without conflict...
 
Hi all,

I have a wee query for you. I have a number of USB flashdrives which I use for swapping files between my laptop and main PC. If I mount one at /dev/sda1, then remove it and try another, the next drive is recognised as /dev/sdb1, which isn't listed in my fstab and so can't be mounted.

Is it really necessary to add more lines to my fstab, considering I only have one USB port on my laptop and can't use more than one drive at once? Or is it possible to restart/flush out whichever subsystem deals with USB devices?

For reference I'm running a basic Slack 9.1 install with the stock 2.4.* kernel.

Any assistance greatly appreciated...

samac 03-01-2005 02:53 AM

Try unmounting the drive before swapping in a new one, either by right clicking on the icon and selecting unmount or running umount /mnt/removeable (or wherever it is mounted) as root from a terminal.

samac

erraticassassin 03-01-2005 04:37 PM

Right-click? Icon? Dude, I'm hardcore... I use Fluxbox. Well, firmcore maybe. :)

The command that gets run from the Fluxbox menu is umount /dev/sda1, which seems to be ok. Must I run it as root to completely flush out the system?

android1654 03-01-2005 11:30 PM

are you sure you need to place it in fstab at all with slack. im running 10.0 and i just made some shell scripts that do the following:

mount -t vfat /dev/sda1 /mnt/usb

and

umount /mnt/usb

nothing with sda is in my fstab, i do have hotplugs running although i really know nothing about hotplugs (or even if it deals with usb).

once you umount it double check if your directory you had it mounted on is now empty. if its not you obviously are having a umount problem.

greybeard01 03-02-2005 02:30 AM

I had a similar problem with my Sony memory sticks I have a 16 and 64 MB stick and the only way around it was to remove and reload the USB storage module by using
"modprobe -r usb-storage" and then adding it back again using "modprobe usb-storage"
This is on RH.
I don't know if it the correct method but it works for me.

erraticassassin 03-02-2005 02:47 AM

Android - when I first bought a USB flashdrive I trawled the forums here in order to find out how to use it, which is where the idea of making an entry in fstab came from. Are you using the stock kernel in 10.0, or a 2.6.* kernel?

Greybeard - your method sounds useful. If all else fails I could perhaps combine your idea with Android's and write a shell script to be called from the Fluxbox root menu which would unmount the flashdrive and reset the USB set at the same time.

Optimistic 03-02-2005 02:51 AM

You could just set up a few different mount directories in fstab like:

/dev/sda1 gets mounted to /mnt/sda1
/dev/sdb1 gets mounted to /mnt/sdb1

But, seriously, you really should unmount devices before you rip them out of the computer.

greybeard01 03-02-2005 03:58 AM

Just for interest I tested mounting the Sony Memory sticks with my Slackware server with 2.6.7 kernel and I can happily swap and exchange the the sticks and some usb drives without removing the module. I use android1654's method of mounting and unmounting the usb devices.

Darin 03-02-2005 04:15 AM

Quote:

Originally posted by android1654
are you sure you need to place it in fstab at all with slack...
For anything besides partitions needed for Linux to run, fstab entries are just a central repository of info and a way to save typing. Technically, it's a good idea to add entries but it's not necessary if you don't mind typing the whole mount command, or making seperate scripts if that's your cup of tea.

erraticassassin 03-02-2005 01:49 PM

Optomistic - I didn't make it clear, but I DO unmount the devices before removing them. I have put entries in my Fluxbox root menu specifically for mounting and unmounting media using the appropriate commands, which is why the behaviour of the USB system is puzzling.

Having the commands built into the menu also means that the same commands have to work to mount and unmount all the USB flashdrives. I'm only ever going to use one at once - and my laptop has only one USB port anyway - so there's no real reason for each drive to be recognised as a different device.

A number of other USB-related queries I have posted have brought out responses suggesting that the 2.6 kernel is the way to go. I've been quite happy sticking with the 2.4 until now, so it's only really the USB issue which is forcing the matter. Would an upgrade to a 2.6 kernel bring any real, tangible benefits?

android1654 03-02-2005 06:10 PM

yes i do use the 2.4 kernel to mount/ umount my drives.

Maybe talking us through the problem more might set off a lightbulb in someones head about how to fix it.
I have a very similar setup, fluxbox, slack 10, 2.4 kernel, laptop.

(sorry for any repeat questions here)

So you want to use your usb drives, first of all what brand/model are they?

1. First thing you do is plug it into the usb port, then what command exactly do you run to mount it?

2. can you now see the drive mounted

3. What command do you run to unmount it?

4. Can you still see the drive mounted? (YOU SHOULDNT)

5. You unplug the device and plug another in the same port, run the same command again, what happens?

6. Does this only occur when you use two different drives one after the other, or does it also happen when you unplug the drive and then try and plug it back in and remount it?

mcd 03-02-2005 06:28 PM

as a quick question to help clarify: you said that you added the mount and umount commands to your root menu in fluxbox (by which i assume you mean the ./fluxbox/menu that pops up when you right click. as far as i know, mount and umount must be run as root. if you're logged in as user, whatever command you try to run from the menu will be run as user. therefore, mounting and umounting from the menu shouldn't work.

but i can't quite make out whether those assumptions of mine are correct. so as the previous poster requested, please post the exact commands you use to mount/umount, a step-by-step list of things you have tried, error messages you have received, etc. if you have entries in /.fluxbox/menu please post them.

erraticassassin 03-03-2005 02:38 AM

Okay, here goes...

I have a 128Mb Discgo and a 512Mb device made by a company called PQI, whom I haven't heard of before. I use the Discgo more on a day to day basis for swapping files between computers (including files I download at work on the office broadband connection... heh).

So... I would normally insert the Discgo and either use the fluxbox menu entries or open up an xterm and type mount /dev/sda1 or mount /dev/flashdrive. ( Flashdrive is a link to /dev/sda1 ). I would issue the commands as a normal user, not root. The drive is then mounted and I can examine the contents, either by cd'ing to the directory in xterm or by opening up Rox.

When I've finished using the Discgo, I make sure the /mnt/flashdrive directory isn't in use by xterm or Rox, then issue the command umount /dev/sda1. Examining the /mnt/flashdrive directory will show the device as being unmounted.

If I then replug the Disgo and go through the same procedure again, it works as before. If however I try to plug in the PQI drive, it is recognised as /dev/sdb1, even though it is the only USB device in use.

The entries in the fluxbox menu, from memory, are:

[exec] (USB) {mount /dev/sda1}
or [exec] (USB) {umount /dev/sda1}

( I have the menu set up so that there is a main entry called Media..., which brings up submenus for mount and unmount, which bring up submenus for CD, DVD, floppy and flashdrive. )

Phew, I think that's everything. As you can see, I've not previously had to be root to mount or unmount...

Darin 03-03-2005 04:00 AM

My guess is that it's something in hotplug that recognizes that the two different drives are unique and assigns different /dev nodes to them. Since I only have one flash drive and I'm not near a Linux system I can plug one into now, I can't test this theory or recreate it.

If it's hotplug there should be a way to configure the hotplug system to give both drives the same /dev node or even a way to do a workaround in a shell script such as changing the /dev/flashdrive symlink based on something like lsmod prior to issuing a mount command.

Optimistic 03-03-2005 01:09 PM

Quote:

Originally posted by erraticassassin
If I then replug the Disgo and go through the same procedure again, it works as before. If however I try to plug in the PQI drive, it is recognised as /dev/sdb1, even though it is the only USB device in use.
Ahh, I see. This happens to me too on my Slackware Laptop which only has one USB. My Lexar Jumpdrive shows up as /dev/sda1 and my Archos MP3 Player shows up as /dev/sdb1. If the two drives show up consistently as sdb1 or sda1, then why not have two lines in fstab like I suggested before? USB ports can support something like 99 devices so it is a good thing that Slack is being smart and keeping track of different devices.

Maybe there is a way to tell Slack to always use the first available /dev node for sd devices, but I don't know what that would be.

erraticassassin 03-07-2005 02:45 AM

Hmm. Based on the responses so far, I think the best option would be a combination of:

1) Amend fstab to include /dev/sdb1 as well, so that mounting from the command line is easy.

2) Write a script which will unmount /dev/sda1, remove the USB module from the kernel and reload it... thus effectively 'rebooting' the USB storage system and ensuring that any USB memory mounted subsequently is /dev/sda1 again. That will ensure that I can still mount from the Fluxbox menu, if I'm too lazy to open an xterm. Heh. :)

Not necessarily the most elegant solution, but if it works without breaking anything, that's good enough for me.

Many thanks for all responses.


All times are GMT -5. The time now is 02:01 AM.