LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 11-30-2012, 05:11 AM   #1
cilbuper
LQ Newbie
 
Registered: Mar 2008
Posts: 29

Rep: Reputation: 0
Question Persistent drive naming/ID for hot swappable SATA drives


I almost had a catastrophe after pulling some SATA drives, rebooting and using my FSTAB that auto mounts sba, sbc, sbd and sbe. In my samba setup sbe is always "TB4" but when I rebooted the drive order got messed up and changed around so I almost overwrote a TB of data that I could not loose.

So, I want to identify the drive with either a folder or a specific /dev location. Is this possible?

To make things easy, I created folders sba1, sbc1, sbd1, sdd1, sde1, etc in the /media folder and then I just mount the corresponding drive to that folder. They are then shared with samba with full R/W access on my windows machines.

Now, I often pull drives to hook up to other machines because I can transfer 1TB of data much faster on an internal connection than on a network connection.

So does anyone have any suggestions on what I should do here?

Thanks for any suggestions on this!
 
Old 11-30-2012, 09:28 AM   #2
Vincent_Vega
Member
 
Registered: Nov 2003
Location: Jacksonville, FL
Distribution: Slackware & Arch
Posts: 825

Rep: Reputation: 31
Have you tried writing udev rules?

http://www.reactivated.net/writing_udev_rules.html
 
Old 12-01-2012, 10:09 AM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,619
Blog Entries: 2

Rep: Reputation: 4076Reputation: 4076Reputation: 4076Reputation: 4076Reputation: 4076Reputation: 4076Reputation: 4076Reputation: 4076Reputation: 4076Reputation: 4076Reputation: 4076
Quote:
Originally Posted by cilbuper View Post
I almost overwrote a TB of data that I could not loose.
If you don't want to loose that data make backups. Otherwise you will be doomed when the disk malfunctions (or you accidentally overwrite it).

Quote:
To make things easy, I created folders sba1, sbc1, sbd1, sdd1, sde1, etc in the /media folder and then I just mount the corresponding drive to that folder. They are then shared with samba with full R/W access on my windows machines.
Use UUIDs instead of device files (/dev/sdXX) in your fstab and you will be fine. No need to tinker with udev rules or something like that.
 
Old 12-01-2012, 04:38 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,445

Rep: Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068Reputation: 1068
Quote:
Originally Posted by TobiSGD View Post
If you don't want to loose that data make backups.
Absolutely. IMHO backups are never optional.
Quote:
Use UUIDs instead of device files (/dev/sdXX) in your fstab and you will be fine. No need to tinker with udev rules or something like that.
Unfortunately UUIDs aren't necessarily unique despite the name, especially if imaging tools are used for backup. You can't predict which will mount if both copies are plugged in. Also makes recovery difficult if you can't mount both concurrently.
Look in /dev/disk for other options.

Only works if you know in advance which/how many drives - which appears to be the case here. Else you're up for some udev rule writing.
 
Old 12-01-2012, 05:14 PM   #5
descendant_command
Member
 
Registered: Mar 2012
Posts: 846

Rep: Reputation: 187Reputation: 187
You can also use labels in fstab.
The same caveat with duplicated labels applies, as with UUID's, but with the advantage that they are human readable and can have meaning.
 
Old 12-03-2012, 04:44 PM   #6
Vincent_Vega
Member
 
Registered: Nov 2003
Location: Jacksonville, FL
Distribution: Slackware & Arch
Posts: 825

Rep: Reputation: 31
But udev rules let you identify the hardware in advance and ensure what mount point it will be assigned to every time it's plugged in. Do fstab labels or UUIDs allow for that?
 
Old 12-04-2012, 12:51 AM   #7
descendant_command
Member
 
Registered: Mar 2012
Posts: 846

Rep: Reputation: 187Reputation: 187
Yes, because you set the mount point in the fstab.
And the label or UUID is unique to that device (provided you set it so).

For devices connected at boot anyway, it seems to achieve the same result, just in a more cryptic fashion.
Or am I missing something magical about udev rules?

I use a udev rule to automount my backup drive to it's proper mountpoint on plug in, and I don't think that can be done via just fstab without some other automount tool.
 
Old 12-05-2012, 07:35 AM   #8
Vincent_Vega
Member
 
Registered: Nov 2003
Location: Jacksonville, FL
Distribution: Slackware & Arch
Posts: 825

Rep: Reputation: 31
I'm not really sure. I need to learn about the UUID method though. I use udev for all of my USB drives, etc. and it works great.
 
  


Reply


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
[SOLVED] Hot Swapping SATA Drives Woodsman Slackware 32 10-10-2011 04:24 PM
eSata-- hot-swappable?? colbert Linux - Hardware 7 10-30-2008 01:47 PM
hot swappable esata drives cygnus-x1 Linux - Hardware 2 01-29-2008 12:41 PM
Hot-swappable SATA Drives in RAID 5 on Linux? Synesthesia Linux - Hardware 11 01-06-2006 07:14 PM
Hot Swappable USB devices vanwas Linux - Hardware 1 08-27-2004 11:50 PM


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

Main Menu
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