LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   why does a pluggable device change from sdb1 to sdc1 when I re-plug it? (http://www.linuxquestions.org/questions/linux-general-1/why-does-a-pluggable-device-change-from-sdb1-to-sdc1-when-i-re-plug-it-4175451942/)

newbiesforever 02-27-2013 12:51 PM

why does a pluggable device change from sdb1 to sdc1 when I re-plug it?
 
I notice that if I unplug my MP3 player or USB drive from a USB port and then plug it back in later, it will reappear with a different sd[x] letter (sorry, I can't remember what we call those names). It's sdb1 the first time I plug it in, and when I plug it in the second time, it reappears as sdc1 (or something else, depending on what else I have plugged in). Why is that? Because it's not sdb1 anymore, I can't simply refresh the window displaying the device's contents (if I left it open). I didn't plug in or remove anything else, so it can't be because something else became sdb1, can it?

suicidaleggroll 02-27-2013 06:00 PM

device names are volatile, you can't rely on them to stay static, especially not for removable devices.

What window is this that displays drive contents based on device names rather than mount points?

rknichols 02-27-2013 06:32 PM

Probably the program in the window that was displaying the device's contents still has some reference to that device open, making that name unavailable for reuse. Did you unmount or, preferably, "Safely remove" the drive before yanking it out?

bloody 02-27-2013 07:20 PM

Yes, if you leave that window open and just pull out the device, the mountpoint might be still locked when you re-insert it, because that window still has the device/mountpoint "in use". Always unmount the device before pulling it out, so any pending writes can be committed before the device is disconnected. The window will then probably notice the unmount and release it's grip also.

Device names can sometimes change. Some BIOSes even swap local harddisk device names at boot time, so "sda" may become "sdb" and vice versa. So if you can avoid using these hard device names, i'd suggest to do so. You can give every partition a certain disk label and then address it by label, e.g., instead of "/dev/sdc1" you could use "/dev/disk/by-label/MY_USTICK_WORK2", or in the /etc/fstab (if you are creating entries there), instead of "/dev/sdc1" you might use "LABEL=MY_USTICK_WORK2" to address that particular partition. Similar in the GRUB config, and so on.

It's even possible to label swap partitions or NTFS (Windows) partitions. See man e2label/swaplabel/ntfslabel. If you do, use no more than 16 characters for compatibility reasons. At least that'll work on any partition type i know of.


All times are GMT -5. The time now is 11:52 PM.