Neil Brown wrote:
> This problem is very hard to solve inside the kernel.
> The partitions will not be visible until the array is opened *after*
> it has been created. Making the partitions visible before that would
> be possible, but would be very easy.
>
> I think the best solution is Mike's solution which is to simply
> open/close the array after it has been assembled. I will make sure
> this is in the next release of mdadm.
>
> Note that you can still access the partitions even though they do not
> appear in /proc/partitions. Any attempt to access and of them will
> make them all appear in /proc/partitions. But I understand there is
> sometimes value in seeing them before accessing them.
>
> NeilBrown
For anyone else who is in this boat and doesn't fancy finding somewhere in mdadm
to hack, here's a simple program that issues the BLKRRPART ioctl.
This re-reads the block device partition table and 'works for me'.
I think partx -a would do the same job but for some reason partx isn't in
utils-linux for Debian...
Neil, isn't it easy to just do this after an assemble?
David
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <fcntl.h>
#include <stdio.h>
#include <linux/raid/md_u.h>
#include <linux/major.h>
#include </usr/include/linux/fs.h>
int main(int argc, char *argv[])
{
int fd;
if (argc != 2)
fprintf(stderr, "Usage: %s <md device>\n", argv[0]);
if ((fd = open(argv[1], O_RDONLY)) == -1) {
fprintf(stderr, "Can't open md device %s\n", argv[1]);
return -1;
}
if (ioctl(fd, BLKRRPART, NULL) != 0) {
fprintf(stderr, "ioctl failed\n");
close (fd);
return -1;
}
close (fd);
return 0;
}