Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

One of the HDDs in my server's RAID config failed, so I took it out of the array and had the data center hot-swap it. They've done that, but now the new drive is /dev/sdc rather than /dev/sda. I suspect — correct me if I'm wrong — that if I reboot the server, it will be /dev/sda again, so I'm hesitant to add it back to the array as /dev/sdc because I don't want to lay a trap for myself to fall into on the next reboot. I'd just as soon not reboot the server if I don't need to (if I do need to, well, too bad for me).

Is there a way I can change the device name from /dev/sdc to /dev/sda without rebooting?

This is on Ubuntu 10.04 LTS. It's an md array ("Linux Software RAID"), where currently one of the devices (there are a couple of them) looks like this ("degraded" because I've removed the old /dev/sda from it):

# mdadm --detail /dev/md0
/dev/md0:
        Version : 00.90.03
  Creation Time : Sun Oct 11 21:07:54 2009
     Raid Level : raid1
     Array Size : 97536 (95.27 MiB 99.88 MB)
  Used Dev Size : 97536 (95.27 MiB 99.88 MB)
   Raid Devices : 2
  Total Devices : 1
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Thu Jun 30 09:31:16 2011
          State : clean, degraded
 Active Devices : 1
Working Devices : 1
 Failed Devices : 0
  Spare Devices : 0

           UUID : 496be7a5:ab9177ed:7792c71e:7dc17aa4
         Events : 0.112

    Number   Major   Minor   RaidDevice State
       0       8       17        0      active sync   /dev/sdb1
       1       0        0        1      removed

Thanks,


Update: Reading through the kernel md documentation, I suspect that if the name changes on reboot, it won't matter. (Good design, that.) Here's why:

Boot time autodetection of RAID arrays

When md is compiled into the kernel (not as module), partitions of type 0xfd are scanned and automatically assembled into RAID arrays. This autodetection may be suppressed with the kernel parameter "raid=noautodetect". As of kernel 2.6.9, only drives with a type 0 superblock can be autodetected and run at boot time.

The kernel parameter "raid=partitionable" (or "raid=part") means that all auto-detected arrays are assembled as partitionable.

I do have md compiled into the kernel I don't have md compiled into the kernel, but my setup will do the same thing as the above because it's auto-loading mdadm and the mdadm.conf is set up to scan all partitions for a superblock just like the kernel would:

# by default, scan all partitions (/proc/partitions) for MD superblocks.
# alternatively, specify devices to scan, using wildcards if desired.
DEVICE partitions

(And yes, I've checked, I'm using a superblock — md can run without one, but I'm not doing that.) So I'm rebuilding the array now and will do the reboot to see what happens, but I'm fairly confident the array won't care.


Update: Yup, worked a treat. Because my mdadm.conf was set to scan partitions (as the kernel would, if I had md compiled in) rather than to use specific device names, there was no problem. I added /dev/sdc's partitions to the arrays, resynced, and then rebooted the server (just to know the answer — I didn't have to do it, I just wanted to be sure it would be okay at next boot). When it came back up, the arrays were perfectly happy, and the new device's name was /dev/sda.

I would delete the question because while the above solves my problem, it doesn't answer the question as asked (if it did, I'd post it as an answer and accept it). But there's an answer (which is really a comment) below, so I can't delete it. Perhaps someone will come and answer the question I actually asked (about renaming the device without rebooting), which would be interesting. :-)

share|improve this question

2 Answers 2

What array? If it's scanning UIDs it doesn't matter if it's sda or sdc

share|improve this answer
    
It's an md array ("Linux Software RAID"). All the device addition/removal and such refers to device names, but I don't know that that means it actually relies on them or... I've added the output of mdadm --detail on it to the question. –  T.J. Crowder Jun 30 '11 at 14:54
    
for md arrays mdadm scans all the disks (as defined in /etc/mdadm.conf) so it doesn't matter where are they, because it writes an ID into the header of the disk so it can reassemble the arrays. –  Jure1873 Jul 4 '11 at 14:38
    
Yes, thanks, check out the update on the question, I described that behavior and double-checked it worked. –  T.J. Crowder Jul 4 '11 at 14:50

Well...if I remember correctly for scsi drives you could send "scsi remove-single-device" to /proc/scsi/scsi and then readd the device with "scsi add-single-device", but I've never tried it and don't know the exact syntax for that.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.