LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 07-21-2010, 10:05 AM   #1
RWTH
LQ Newbie
 
Registered: Jul 2010
Posts: 22

Rep: Reputation: 0
HD labeling/device mapping


Hi,

I am a new comer to the Linux word. Therefor, please bear with me.

The device labeling (especially the HDs) confuses me all the time in linux. For example:

If I have two HDs, let's say (HDA and HDB), if they are mapped as:

HDA--> sda and HDB---> sdb for specific configuration. In case I go and change their SATA connectors' location on the main board (I basically plug out HDA and plug into a different slot and same with HDB), would that effect their labeling? Basically, might HDA become sdc and let's say HDB might become sda?

How does the linux in general decide to label those HDs?

Thanks
 
Old 07-21-2010, 10:20 AM   #2
alli_yas
Member
 
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
Hi RWTH

That is exactly what would happen. The OS detects your devices in a certain order in terms of the actual SATA channels; thus if you swop your drives between the 2 SATA channels - the OS will detect the channels in the same order (and not the drives).

In other words; if you have HDA/sda connected to SATA Channel 1 and HDB/sdb connected to SATA Channel 2; and then you swop the drives around physically; HDB will become sda and HDA will become sdb on an OS level.
 
Old 07-21-2010, 10:28 AM   #3
RWTH
LQ Newbie
 
Registered: Jul 2010
Posts: 22

Original Poster
Rep: Reputation: 0
Thanks Yas,

That means as long as I don't touch the physical location of a HD, then the labeling should remain the same?

My concern is that I try to setup RAID array and if I replace a bad HD with a new one (which is empty of course) and start rsync the HDs, then the empty one could accidently overwrite the good one, such that I would end up with two empty HDs . What you are saying that's not possible, because as long as I use the same slot, the numbering will be the same.

On the other hand, I tried to give fix and reasonable names via writing udev rules. Are you familar with udev?
 
Old 07-21-2010, 10:32 AM   #4
alli_yas
Member
 
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
Hi RWTH,

Yes the device identifier (sda/sdb) should stay the same. I am familiar with udev (not an expert) but I don't think you need to do this in your situation. If you had to lose one drive; the other drive would retain its device identifier allocation; based on the fact that its still on the same SATA channel.
 
Old 07-21-2010, 10:40 AM   #5
Bratmon
Member
 
Registered: Jul 2009
Location: 75.126.162.205:80
Distribution: Arch / Mint 17
Posts: 297
Blog Entries: 3

Rep: Reputation: 50
You could look at /dev/disk/by-uuid
 
Old 07-21-2010, 10:43 AM   #6
RWTH
LQ Newbie
 
Registered: Jul 2010
Posts: 22

Original Poster
Rep: Reputation: 0
Hi Yas,

Still I gave a try for fix labels, but it didn't work. Maybe you have a quick idea: Here is what I did:

In the "10-local-rules" file, I put the following line:

*********************************************************
SYSFS{size}=="156301488", SYSFS{model}=="ST380815AS", SYMLINK="swap_hd_ln"
*******************************************************

because when I run the command,
udevinfo -a -p /sys/block/sda/, then I get the following:

******************************************************
looking at class device '/sys/block/sda':
SYSFS{dev}="8:0"
SYSFS{range}="16"
SYSFS{removable}="0"
SYSFS{size}="156301488"
SYSFS{stat}=" 61 1386 2944 419 0 0 0 0 0 297 419"

follow the class device's "device"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:07.0/host0/target0:0:0/0:0:0:0':
BUS="scsi"
ID="0:0:0:0"
SYSFS{detach_state}="0"
SYSFS{device_blocked}="0"
SYSFS{model}="ST380815AS "
SYSFS{queue_depth}="31"
SYSFS{rev}="4.AA"
SYSFS{scsi_level}="6"
SYSFS{state}="running"
SYSFS{timeout}="30"
SYSFS{type}="0"
.
.
.
********************************************************************

My understanding from the udev, that I should a symbolink to the /dev/sda from the point /dev/"swap_hd_ln".

In general, will I have always the /dev/sda, because it is determined by the kernel, or can I get rid off it?
 
Old 07-21-2010, 10:52 AM   #7
RWTH
LQ Newbie
 
Registered: Jul 2010
Posts: 22

Original Poster
Rep: Reputation: 0
I made a quick test:

1) I had 2 HDs connected on the MB, one small and one big HD. The small one was labeled as /dev/sda1 and the big one was labeled as /dev/sdb3, /dev/sdb2 and /dev/sdb1.

2) I removed the small HD from the MB by disconnecting its SATA connector from the back of the HD.

3) I rebooted the system and I get the following: /dev/sda3, /dev/sda2 and /dev/sda1.

I thought in the step 3) everything should remain as /dev/sdb*, since I didn't change the SATA location for that HD.
 
Old 07-21-2010, 10:58 AM   #8
djsmiley2k
Member
 
Registered: Feb 2005
Location: Coventry, UK
Distribution: Home: Gentoo x86/amd64, Debian ppc. Work: Ubuntu, SuSe, CentOS
Posts: 343
Blog Entries: 1

Rep: Reputation: 72
RWTH - No, it has become sba because that is the FIRST drive it picked up

a = 1st
b = 2nd
n = nth

If you swapped the small disk for a CDRom for example, then the large hdd would still be showing up as sdb as the cdrom would become sda.

Hope this makes sense and helps

Last edited by djsmiley2k; 07-21-2010 at 11:01 AM.
 
Old 07-21-2010, 11:02 AM   #9
alli_yas
Member
 
Registered: Apr 2010
Location: Johannesburg
Distribution: Fedora 14, RHEL 5.5, CentOS 5.5, Ubuntu 10.04
Posts: 559

Rep: Reputation: 92
djsmiley2k is correct - you asked what would happen if you swopped the drives around in terms of your SATA channels.

Generally the OS detects a certain channel/device first (in my experience) so hence my explanation in post #2 and #4.

If you remove 1 drive altogether; the OS will only detect the one HDD and it should become sda instead of sdb.

Try swopping the drives and see what happens.
 
Old 07-21-2010, 11:07 AM   #10
RWTH
LQ Newbie
 
Registered: Jul 2010
Posts: 22

Original Poster
Rep: Reputation: 0
I need to leave the office right now. I will update you, once I came back on Monday.

But as summary, as long as I keep the numbers of the HDs constant and I don't change the location of the good HDs and replace a bad HD, then I shouldn't get any problem with a labeling in a RAID array?
 
Old 07-21-2010, 11:17 AM   #11
djsmiley2k
Member
 
Registered: Feb 2005
Location: Coventry, UK
Distribution: Home: Gentoo x86/amd64, Debian ppc. Work: Ubuntu, SuSe, CentOS
Posts: 343
Blog Entries: 1

Rep: Reputation: 72
Correct, as long as the number of drives is maintained, you should have no problems.

I'd hope (but I've never used one) that raid software would be able to identify which HDD has been removed and so can respond to you appropately - "Warning this HDD is empty" kind of thing.
 
Old 07-26-2010, 12:52 PM   #12
RWTH
LQ Newbie
 
Registered: Jul 2010
Posts: 22

Original Poster
Rep: Reputation: 0
Hi,

If everybody is on the same page , I swapped both HDs and the system didn't boot. Does it mean that the system couldn't find the boot section/program? In that case hardware should be able to scan the boot section/program in an order? Now this is more confusing!

Once I had both HDs I could boot, even the big HD contained the OS and it was mapped as sdb*. Once the big HD was connected standalone then it was moved down to sda, which we could explain and still we could boot.

After I swapped the HDs, then I would think that the hardware should scan all the HDs and would find out a boot able sector/program, but obviously it couldn't. Now, what is the mechanism?

Thanks
 
Old 07-26-2010, 12:54 PM   #13
RWTH
LQ Newbie
 
Registered: Jul 2010
Posts: 22

Original Poster
Rep: Reputation: 0
Hi,

If everybody is on the same page , I swapped both HDs and the system didn't boot. Does it mean that the system couldn't find the boot section/program? In that case hardware should be able to scan the boot section/program in an order? Now this is more confusing!

Once I had both HDs I could boot, even the big HD contained the OS and it was mapped as sdb*. Once the big HD was connected standalone then it was moved down to sda, which we could explain and still we could boot.

After I swapped the HDs, then I would think that the hardware should scan all the HDs and would find out a boot able sector/program, but obviously it couldn't. Now, what is the mechanism to select/map the HD and boot?

Thanks
 
Old 07-26-2010, 08:37 PM   #14
jay73
Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
A failsafe solution would involve putting your bootloader on the MBR of all the drives and using UUIDs to identify partitions. Then you could install your drives in any order and it would still work.

Last edited by jay73; 07-26-2010 at 08:38 PM.
 
  


Reply

Tags
hd


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
mapping usb device to device file scerenon Linux - Hardware 12 07-20-2006 05:13 PM
Linux device mapping npuetz Linux - General 1 05-26-2005 06:55 AM
LUN device mapping jdepaul Linux - Hardware 0 08-02-2004 03:42 PM
physical scsi channel mapping to scsiX device node mapping, how to configure manually drthornt Linux - Hardware 3 02-09-2003 12:50 PM
Memory mapping a device PLEASE HELP!!!! mpalmer Linux - Newbie 1 08-16-2001 04:09 PM


All times are GMT -5. The time now is 04:26 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration