LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Persistent drive naming/ID for hot swappable SATA drives (https://www.linuxquestions.org/questions/linux-hardware-18/persistent-drive-naming-id-for-hot-swappable-sata-drives-4175439421/)

cilbuper 11-30-2012 04:11 AM

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!

Vincent_Vega 11-30-2012 08:28 AM

Have you tried writing udev rules?

http://www.reactivated.net/writing_udev_rules.html

TobiSGD 12-01-2012 09:09 AM

Quote:

Originally Posted by cilbuper (Post 4840053)
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.

syg00 12-01-2012 03:38 PM

Quote:

Originally Posted by TobiSGD (Post 4840763)
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.

descendant_command 12-01-2012 04:14 PM

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.

Vincent_Vega 12-03-2012 03:44 PM

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?

descendant_command 12-03-2012 11:51 PM

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.

Vincent_Vega 12-05-2012 06:35 AM

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.


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