0

I've created two block devices under /dev using mknod, and when I try to create two RAID devices using those two devices I get this error:

mdadm: cannot open /dev/test_dev: No such device or address

I've created the devices test_dev and test_dev_1 like this:

mknod /dev/test_dev b 500 1
mknod /dev/test_dev_1 b 400 2

The RAID command used was:

mdadm --create --verbose /dev/md0 --level=stripe --raid-devices=2 /dev/test_dev /dev/test_dev_1

1 Answers1

2

The files, "device nodes", in /dev are just "pointers" or "links" (to abuse the words) to some kernel device drivers. Like a symbolic link has a name and contains another name you get when you open the link, a device node has a name(*) and it contains a device identifier in the form of the major and minor numbers.

So, when we say something like /dev/sda represents the first hard drive, we actually mean that it's the common name for a device node that has major-minor numbers (8, 0), which happens to be the fixed number used by the hard drive driver for the first hard drive.

While we could create another node that also points to (8, 0), creating a node to just some random device number doesn't work. If the number is unused, there's no driver to handle the access request; and worse, if it is used by something completely unrelated, the results could be interesting or outright problematic.

Given that the kernel documentation mentions the range 384 to 511 only as dynamically alloced for character devices, it seems unlikely you'd find a block device driver there.

If you want to create a RAID array, you'll have to instead point it to use some existing device. Either a drive, partition or similar (see LVM), or a loop device that is eventually backed up by a file. See:

ilkkachu
  • 138,973