[CentOS] add on sata card relabeling drives, installation

Fri Sep 30 00:32:03 UTC 2011
David C. Miller <millerdc at fusion.gat.com>


----- Original Message -----
> From: "Les Mikesell" <lesmikesell at gmail.com>
> To: "CentOS mailing list" <centos at centos.org>
> Sent: Thursday, September 29, 2011 2:16:16 PM
> Subject: Re: [CentOS] add on sata card relabeling drives, installation
> 
> On Thu, Sep 29, 2011 at 4:09 PM, David C. Miller
> <millerdc at fusion.gat.com> wrote:
> >
> > This type of issue is why relying on /dev/sdX is bad. Mounting
> > based on uuid or label when available is best. Unfortunately,
> > there are controller cards that present all disks as the same
> > uuid. It makes using mdadm that can only see /dev/sdX a pain to
> > use.
> 
> So how do you propose getting a uuid or label on a disk in the first
> place if you can't identify which is which physically?  And how do
> you
> know which to move when you want the content in some other box?
> 
> --
>   Les Mikesell
>     lesmikesell at gmail.com

I just had to come up with a solution for this recently. Here is what I did.

I create a small 2 block partition on each disk and gave them labels that is the drives serial number when I format them as ext3/4. I dedicate the rest of the disk to Linux auto RAID. Something like this to create a label.

mkfs.ext3 -L $DRIVE_SN /dev/sd1

I then have a script that mounts the small partitions by label to a directory with the same name as the label.

mount LABEL=$DRIVE_SN /mnt/drive-check/$DRIVE_SN

So if you do a df it will show something like.

Filesystem            Size  Used Avail Use% Mounted on
/dev/md0               71G  3.9G   63G   6% /
tmpfs                  12G     0   12G   0% /dev/shm
/dev/sdc1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03208723
/dev/sdd1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03287844
/dev/sde1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03247298
/dev/sdf1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03247844
/dev/sdg1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03674888
/dev/sdh1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03678644
/dev/sdi1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03674814
/dev/sdj1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03675850
/dev/sdk1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03675194
/dev/sdl1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03288196
/dev/sdm1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03672314
/dev/sdn1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03287843
/dev/sdo1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03674460
/dev/sdp1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03585344
/dev/sdq1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03508896
/dev/sdr1              16M  1.2M   14M   8% /mnt/drive-check/WD-WMAY03209984

Now if I'm using mdadm to make a software RAID and it is complaining /dev/sdf2 is missing. I can run my script to mount all the small partitions and the one that complains it can't mount is easily identified by the serial number. Sure I can just let the hardware RAID card handle everything but I don't trust them from past experiences seeing failed cards and corrupted arrays. With the disks seen by linux as raw block devices I can put these disks on any JBOD controller and mount my raid using mdadm. I'm not tied to a particular controller if it fails. 

David.