[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to get consistent names for USB ports...



On Sat, Feb 27, 2016 at 06:43:44AM +1100, Andrew McGlashan wrote:
> 
> 
> On 27/02/2016 6:22 AM, Dan Ritter wrote:
> > On Sat, Feb 27, 2016 at 06:10:49AM +1100, Andrew McGlashan wrote:
> >>
> >> On 27/02/2016 5:46 AM, Christopher Swingley wrote:
> >>> udevadm info --query=name --name=/dev/ttyUSB0  --attribute-walk
> >>
> >> udevadm info --query=name --name=/dev/sdg  --attribute-walk
> >>
> >> Could you do something similar for mdadm RAID [external USB drives]
> >> devices?  Probably only need the serial number form the output.
> > 
> > That's more or less exactly what LABEL, UUID and ID are for:
> 
> Yes, but can you define RAID devices by UUID or Label?

Yes. Specifically, mdadm can, at boot time (or thereafter) scan
drives and partitions for the metadata block and retrieve the
UUID embedded within.

The effect is that you can, for example, create a RAID-10 from
six disks, shuffle the disks around to different controllers,
and expect that mdadm will be able to automatically re-assemble
the RAID-10. If you also use the (filesystem's) UUID as a
specification in /etc/fstab, you can even survive colliding
mdadm RAIDs that both claim to be /dev/md0.

(There is also a hostname limiter to prevent that, but in my
experience it causes problems more often than it solves them.
Your mileage may vary.)

> If I have a drive go out, I might unplug it and plug it in again and the
> drive goes from /dev/sdg to /dev/sdh -- the RAID device won't assemble
> because it isn't /dev/sdg.
> 
> > $ cat /proc/mdstat 
> > Personalities : [raid1] 
> > md0 : active raid1 sda3[0] sdb3[1]
> >       973827010 blocks super 1.2 [2/2] [UU]
> 
> Those drives are not showing via UUID or label here...

/proc/mdstat returns the current known values (i.e. /dev/sdX),
not the specified values, which, if they were shown, would lead
to this human-unfriendly display:

$ cat /proc/mdstat
Personalities : [raid1]
UUID=ff3424:aa93f4:123112:04451a : active raid1 \
UUID=deadbe:ef0134:342af1:4240fd \
UUID=cbdb13:ff441a:85736a:bcd337
                                   973827010 blocks super 1.2 [2/2] [UU]

which really wouldn't be as much help, most of the time.

-dsr-


Reply to: