LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-17-2013, 01:07 AM   #1
hanul
LQ Newbie
 
Registered: Aug 2013
Posts: 5

Rep: Reputation: Disabled
Unhappy About the detection USB as sda or sdb


I wonder what decide usb as sda or adb.
Linux shows the usb as sda at first.
But it shows the usb as sdb at second time after I reinsert the same usb.

Please help me, I can't understand what happen to this.

Last edited by hanul; 08-17-2013 at 02:45 AM.
 
Old 08-17-2013, 02:09 AM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
Hey there!

Welcome to the forum, and, wow, you set the tone with an interesitng one.
So, the first disk detected is likely the one the system booted from.
Now...

Quote:
I wonder what decide usb as sda or adb.
This, you dont decide, the system does that for you...

Quote:
Linux shows the usb as sda at first
Possibly because that's the boot device...

Quote:
But it shows the usb as sdb at second time after I reinsert the usb.
Obviously...that's a disk that came in later on...

Quote:
I can't understand what happen to this.
...the first step to wisdom is understanding...that you dont understand everything...
(same with me, I still learn everyday, such wonder is Life...)

Thor

Last edited by ButterflyMelissa; 08-17-2013 at 02:11 AM.
 
Old 08-17-2013, 02:09 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by hanul View Post
I wonder what decide usb as sda or adb.
Linux shows the usb as sda at first.
But it shows the usb as sdb at second time after I reinsert the usb.

Please help me, I can't understand what happen to this.
This is normal behaviour for modern Linux systems. The order if which device names are assigned is not guaranteed.

Have a look at this: Persistent block device naming
 
Old 08-17-2013, 02:36 AM   #4
hanul
LQ Newbie
 
Registered: Aug 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Add more information

I think I didn't explain it enough.

1. I inserted usb A, and Linux detected it as sda.
2. I extract usb A.
3. I did "umount -l" after extract the usb.
Because "umount" did not work after the extration like below.
Quote:
# mount
...
/dev/sda1 on /mnt/usb type ext3 (rw,data=ordered)
# umount /mnt/usb
umount: Couldn't umount /mnt/usb: No such device or address
4. And I reinserted the same usb A.
But, Linux detect it as sdb. Even the system has only one usb.

I think something did not cleaned perfectly.
Because, Linux is writing on the usb when I extract it from the system.

Last edited by hanul; 08-19-2013 at 08:23 AM.
 
Old 08-17-2013, 03:00 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by hanul
Because, Linux is writing on the usb when I extract it from the system.
This is a really bad idea! Never unplug a device that is being used. You need to umnount it before removing it, not doing so will have strange possible side effects:

- data might become corrupted,
- the system still thinks the device is still present (which explains it showing up as sdb).

Again: _Never_ unplug a device that is still mounted. Unmount it and then remove it.
 
Old 08-17-2013, 03:08 AM   #6
hanul
LQ Newbie
 
Registered: Aug 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thank you druuna.
Is there any way to make the linux thinks the usb removed?
 
Old 08-17-2013, 03:21 AM   #7
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by hanul View Post
Thank you druuna.
Is there any way to make the linux thinks the usb removed?
Bit of an ambiguous question...

- Are you talking about removing the entry after wrongfully removing the device (sda in your case)? If so:
There's no real need to do this manually. The system will pick up on it eventually and do some housecleaning itself.

- Or are you asking how to unmount a device? If that is the case:
If you use a GUI the right click on the device an umount option should be present, if you use the terminal then use the following command:
Code:
df -h  # <- to figure out the device name
umount /dev/sdXY
The X can be a, b, c etc and the Y is a number, which is shown by the df -h command.

An example of the umount command:
Code:
umount /dev/sda1
 
Old 08-18-2013, 05:52 PM   #8
hanul
LQ Newbie
 
Registered: Aug 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thank you Druuna.
I was talking about removing the entry after wrongfully removing the device.
Because my system detect the same usb as sdb after abnormal removing.
I thought the reason is that the linux thinks the usb still present.

But judging by the account of you,
If I want to detect it as sda again, the only thing I can do is just waiting for cleaning.
Am I right? It's too sad.
 
Old 08-19-2013, 03:00 AM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by hanul View Post
I was talking about removing the entry after wrongfully removing the device.
Because my system detect the same usb as sdb after abnormal removing.
I thought the reason is that the linux thinks the usb still present.
If you wrongfully remove the device then Linux _does_ think it is still present.

Quote:
But judging by the account of you,
If I want to detect it as sda again, the only thing I can do is just waiting for cleaning.
Am I right?
Yep (or reboot )

Quote:
It's too sad.
Well, you are to blame. As stated before: Always unmount a device before removing it.
 
Old 08-19-2013, 08:23 AM   #10
hanul
LQ Newbie
 
Registered: Aug 2013
Posts: 5

Original Poster
Rep: Reputation: Disabled
OK. Thank you druuna.
 
Old 08-19-2013, 08:27 AM   #11
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You're welcome

BTW: Can you put up the [SOLVED] tag (upper right corner or Thread Tools menu).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cant boot sdb2 (win7); sdb is usb 3.0 externel drive; grub is on sda; ununun Linux - General 11 01-02-2012 01:27 PM
[SOLVED] Grub: If exists sdb, then boot sdb, else sda defaultyeti Linux - Desktop 6 06-28-2011 02:38 AM
sda / sdb after boot anika.ella Linux - Newbie 1 04-29-2011 10:59 AM
How do I keep sda from changing its name to sdb? kinetic Linux - Hardware 3 06-22-2008 08:01 PM
sda or sdb? stevest SUSE / openSUSE 7 12-18-2007 11:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 03:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration