You are not logged in.

#1 2007-10-27 18:21:13

From: Nice, France
Registered: 2007-08-01
Posts: 15

Problem mkinitcpio.conf for RAID+LVM+Persistent_block_device_naming

Since the introduction of libata one has to use Persistent_block_device_naming to prevent unpleasant surprises. In my case RAID devices are used in combination with LVM. Because of that I can reference the MD-devices only by /dev/disk/by-id/<id> or /dev/disk/by-path/<path>. I cannot use /dev/disk/by-uuid/ nor /dev/disk/by-label/ because they reference the logical volumes. In order to boot I have to supply a kernel command line of the form "md=1,/dev/disk/by-id/<id1>,/dev/disk/by-id/<id2>".

For me there are now two problems.
1. Practically, because due to historical reasons I have to supply four md-devices on the command line to be able to boot and unfortunately the command line becomes too long voor mkinitcpio or kernel to handle. After 255 characters the command line gets truncated.
2. Essentially, I do not like to supply <id> or <path> because it hampers flexibility. I prefer automatic detection of RAID-devices at boot time.

I started to modify mkinitcpio.conf by adding BINARIES="/sbin/mdadm" and FILES="/etc/mdadm.conf". It appears that I cannot supply parameters to mdadm; I hoped that in that way the initial ramdisk would execute the command "/sbin/mdadm --assemble --scan" which would solve my problem. So now I have modified /lib/initcpio/hooks/raid by substituting "/bin/mdassemble ${CMDLINE}" by "/sbin/mdadm --assemble --scan". This works now: the machine boots and I do not have to supply kernel command line parameters for the MD-devices. Obviously this is not ideal because after an update of mkinitcpio I have to remember to modify /lib/initcpio/hooks/raid.

My questions are :
- Do I overlook something and is it possible to add user defined commands including parameters to mkinitcpio.conf?
- Is there a reason why automatic detection of RAID-devices is not activated in the RAID hook?

All tips and tricks are appreciated.


#2 2007-11-05 09:10:01

From: Poland
Registered: 2007-07-09
Posts: 11

Re: Problem mkinitcpio.conf for RAID+LVM+Persistent_block_device_naming

Well, I'll tell you how I'm doing similar things atm:

Leave original raid hook and use it as a template for let's say raid2 hook. This way you don't have to adjust everytime mkinitcpio is updated. Remember about both 'install' and 'hook'.

For instance for 'install' part I have:

install ()
    MODULES=" $(checked_modules "drivers/md/*" | grep -v "dm-") "
    #not really necessary:
    add_dir "/dev/md"

help ()
    no help for you ;)

and for actual hook:

    /sbin/modprobe -aq linear multipath raid0 raid1 raid456 raid10>/dev/null 2>&1
    /sbin/mdadm -As

Also, the part in rc.sysinit that is responsible for mdadm assembly in my case is simply:

if [ -f /etc/mdadm.conf -a "$(grep ^ARRAY /etc/mdadm.conf 2>/dev/null)" ]; then
        status "Activating RAID arrays" /sbin/mdadm -As

as nothing else is really needed.

Also with this approach, you don't need separate hooks for partitionable and non-partitionable arrays. All is so much simpler smile

The part that once gave me most problems were udev rules - as they are somewhat incompatible with what mdadm does by itself, and depending on your settings in mdadm.conf. Generally I use /dev/md/N and /dev/md/dNpM for raids assembled respectively as nonpartitionable and partitionable ones. This is one of so called 'standard' formats as per mdadm's man.

In this case mdadm will make symlinks from legacy names. Problem with udev is that its default rules don't work properly with this scheme (and partitionable arrays in paritcular) and make symlinks in the other direction.

So these days I block those rules early in udev chain with simple:

KERNEL=="md[_0-9]*", OPTIONS="ignore_device"

as mdadm takes care of all the nodes and symlinks beautifully. To make sure the permissions and owner are proper, I have in mdadm.conf:

CREATE group=disk mode=0660 owner=root auto=p2 symlinks=yes

Regarding your questions:

- Do I overlook something and is it possible to add user defined commands including parameters to mkinitcpio.conf?

Well, you would have to add functionality to mkinitcpio script (it's nice shell script, so modifying is easy). Or you could just write more complex your own 'install' & 'hook' parts to suit your needs.

- Is there a reason why automatic detection of RAID-devices is not activated in the RAID hook?

No idea. I proposed something similar some time ago, but noone replied smile I'll prooly retry with some diffs and rationale in not too distant future.


#3 2007-11-05 10:40:14

Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,838

Re: Problem mkinitcpio.conf for RAID+LVM+Persistent_block_device_naming

msoltyspl, Teld - you should submit a formal feature request via the bugtracker, detailing your requirements. This forum is a good place for discussion, but there is no guarantee that the right Arch dev will see it. Bugtracker requests, on the other hand, are always read and evaluated.


Board footer

Powered by FluxBB