How to create persistent /dev/md1

I'm trying to set up software raid on CentOS 5.1 and having a hard time with md1. By default /dev/md0 exists but not md1 so I Googled the problem and found that I can use MAKEDEV to create it. All is well until I reboot when md1 disappears. I checked man MAKEDEV to see if I can make it persistent but didn't find any options that would do that.

Is there a way to set up md1 to be persistent like md0?

Any help is appreciated.

LEC

5 Replies

Is this on a linode or on your own machine?

Assuming your home machine

I had this problem when I first installed CentOS 5 on my server; some of the disks (those created by the installer) were coming up but the manually created raid disks weren't. That's when I learnt the type had to be set :-)

md arrays are auto-detected by the kernel and boot process as long as the partition type is set to "fd" ("Linux raid autodetect")

eg on my machine at home:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       60801   488384001   fd  Linux raid autodetect
/dev/sdb2   *           1       60801   488384001   fd  Linux raid autodetect
/dev/sdc3   *           1       60801   488384001   fd  Linux raid autodetect
/dev/sdd4   *           1       60801   488384001   fd  Linux raid autodetect

The /dev entries are maintained by udev, so you can't manually create them.

Thank you Stephen for your quick answer. Yes, this is on my home computer although I did check my Linode too and it too has only md0 by default.

I created the arrays on the disk level and therefore there are no partitions that fdisk would recognize. I did this because some of the drives are slightly different sizes and wanted Linux to figure out how to build the array instead of me trying to match the partition sizes. Here are the commands I used to create my arrays:

mdadm -C /dev/md0 -l1 -n2 /dev/hd[ij]
mdadm -C /dev/md1 -l5 -n4 /dev/hd[efgh]

And my mdadm.conf:

#/dev/md0 - Documents (RAID1 Mirror)
DEVICE /dev/hdi /dev/hdj
ARRAY /dev/md0 devices=/dev/hdi,/dev/hdj level=1

#/dev/md1 - Storage (RAID5)
DEVICE /dev/hde /dev/hdf /dev/hdg /dev/hdh
ARRAY /dev/md1 devices=/dev/hde,/dev/hdf,/dev/hdg,/dev/hdh level=5

They seem to be working fine:

[root@LECBackup dev]# mount /dev/md0 /shares/documents
[root@LECBackup dev]# mount /dev/md1 /shares/storage
[root@LECBackup documents]# ls -al /shares/documents/
total 28
drwxr-xr-x 3 lec smbusers  4096 Dec 27 15:27 .
drwxr-xr-x 4 lec smbusers  4096 Dec 27 11:14 ..
drwx------ 2 lec smbusers 16384 Dec 27 08:08 lost+found
[root@LECBackup documents]# ls -al /shares/storage/
total 28
drwxr-xr-x 3 lec smbusers  4096 Dec 27 11:49 .
drwxr-xr-x 4 lec smbusers  4096 Dec 27 11:14 ..
drwx------ 2 lec smbusers 16384 Dec 27 11:49 lost+found

But fdisk says:

Disk /dev/hde: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/hde doesn't contain a valid partition table

Disk /dev/hdf: 251.0 GB, 251000193024 bytes
255 heads, 63 sectors/track, 30515 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/hdf doesn't contain a valid partition table

Disk /dev/hdg: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/hdg doesn't contain a valid partition table

Disk /dev/hdh: 251.0 GB, 251000193024 bytes
255 heads, 63 sectors/track, 30515 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/hdh doesn't contain a valid partition table

Disk /dev/hdi: 122.9 GB, 122942324736 bytes
16 heads, 63 sectors/track, 238216 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Disk /dev/hdi doesn't contain a valid partition table

Disk /dev/hdj: 122.9 GB, 122942324736 bytes
16 heads, 63 sectors/track, 238216 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

Disk /dev/hdj doesn't contain a valid partition table

Disk /dev/md0: 122.9 GB, 122942259200 bytes
2 heads, 4 sectors/track, 30015200 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md0 doesn't contain a valid partition table

Disk /dev/md1: 750.1 GB, 750177681408 bytes
2 heads, 4 sectors/track, 183148848 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md1 doesn't contain a valid partition table

What I don't understand is what's so special about md0 that it works while the other ones don't. Also, not sure how to assign type if I have no partitions. :)

Ugh, you're using raw devices rather than partitions. I don't think the auto-build routines will work then (but I've never tried) and I guess that you'll probably need to mdadm –assemble at boot time to get the devices found.

I strongly recommend you partition each disk with a single partition of type 'fd' and use /dev/hd[efghi]1 as the devices.

I'm 95% sure that md will figure out how to match the partition sizes, just as is does the raw disks. So on each disk, create as large a partition as fdisk will allow, and let mdadm figure it out.

Why is /dev/md0 created automatically? Probably it happens when the md module loads.

Thank you guys for the response. I ended up switching the two arrays and left the 4 drives without partitions in RAID5 to be md0 since that already worked and then created partitions on the two 120GB drives. Everything works now. :) Thanks again.

LEC

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct