Skip to contentSkip to conversation

auto-assembling arrays without a configuration file

DISCUSSION Keld Jørn Simonsen 3 participants 6 messages Mar 8, 2008 – Mar 14, 2008 1 message not in the archive MD RAID

lore
Share & tools
lore
#0 lore raw

I want to assemble the root partition automatically, without having a configuration file. Is that possible?

mdadm -A --scan

does seem to require a configuration file.

On the other hand, I think all info needed is available in the super blocks, and a traversal of the partitions present on the system (ala fdisk -l) could give consistent naming - there seems to be no /dev/md association available in the superblock.

best regrds
keld

#1 lore raw
Quoted 11 lines · Keld Jørn Simonsen

I want to assemble the root partition automatically, without having a configuration file. Is that possible?

mdadm -A --scan

does seem to require a configuration file.

On the other hand, I think all info needed is available in the super blocks, and a traversal of the partitions present on the system (ala fdisk -l) could give consistent naming - there seems to be no /dev/md association available in the superblock.

I tried

mdadm -A --scan --config partitions

But it did not work, error message something like raid array not found.

Best regards
keld
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to Keld Jørn Simonsen
Quoted 11 lines · On Saturday March 8, [email protected] wrote:

I want to assemble the root partition automatically, without having a configuration file. Is that possible?

mdadm -A --scan

does seem to require a configuration file.

On the other hand, I think all info needed is available in the super blocks, and a traversal of the partitions present on the system (ala fdisk -l) could give consistent naming - there seems to be no /dev/md association available in the superblock.

The information that is not present in the super blocks is which array you want to assemble.
This becomes particularly important if you move some drives from one machine to another.
If the target machine and a "/dev/md0" and the drives that are moved are from a "/dev/md0" on the source machine, then any auto-assembly on the target machine has not obvious way to know which set of "/dev/md0" devices to assemble.

For that reason mdadm knows about a "homehost". You can tag each array with a hint about what host it expects to be assembled on. If you run

  mdadm -As --homehost=`hostname`

then it will auto-assemble any arrays for the current host. If you arrays haven't been tagged for at particular host, then

  mdadm -As --homehost=`hostname` --auto-update-homehost

will automatically tag everything that is found for the current host. This is not something that should be done automatically, but it OK to do one when you know you haven't done anything interesting with devices.

NeilBrown

#4 lore raw
In reply to a message not in the archive
Quoted 8 lines · Neil Brown
Quoted 7 lines · On Saturday March 8, [email protected] wrote:

I want to assemble the root partition automatically, without having a configuration file. Is that possible?

mdadm -A --scan

does seem to require a configuration file.

Quoted 7 lines
Quoted 4 lines

On the other hand, I think all info needed is available in the super blocks, and a traversal of the partitions present on the system (ala fdisk -l) could give consistent naming - there seems to be no /dev/md association available in the superblock.

The information that is not present in the super blocks is which array you want to assemble.

Yse, that is evident.

Quoted 2 lines

This becomes particularly important if you move some drives from one machine to another.

Moving a disk from one machine to another is not the common thing with raids. This is only done in special cases, and not prat of ordinary operations.

Quoted 4 lines

If the target machine and a "/dev/md0" and the drives that are moved are from a "/dev/md0" on the source machine, then any auto-assembly on the target machine has not obvious way to know which set of "/dev/md0" devices to assemble.

Moving a disk from one machine to another should be a special case, and done by hand.

Quoted 9 lines

For that reason mdadm knows about a "homehost". You can tag each array with a hint about what host it expects to be assembled on. If you run

  mdadm -As --homehost=`hostname`

then it will auto-assemble any arrays for the current host. If you arrays haven't been tagged for at particular host, then

Quoted 6 lines
  mdadm -As --homehost=`hostname` --auto-update-homehost

will automatically tag everything that is found for the current host. This is not something that should be done automatically, but it OK to do one when you know you haven't done anything interesting with devices.

Hmm, I am still looking for a way to boot a linúx raid as root.

mkinitrd does not seem to handle linux raids at all. Only hardware raids (doen by a controller).

best regards
keld
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 1 line · Keld Jørn Simonsen

Hmm, I am still looking for a way to boot a linúx raid as root.

Here's an init script that works for me on a server that has its root partition on a software raid5 on /dev/md1. It uses busybox for all commands except mdadm.

	#! /bin/sh
	export PATH=/bin:/sbin
	echo initramfs startup

	cat > /etc/fstab << EOF
	proc /proc proc defaults 0 0
	sysfs /sys sysfs rw 0 0
	EOF

	cat > /etc/mdev.conf << EOF
	null 0:0 666
	ptmx 0:0 666
	EOF

	mount /proc
	mount /sys
	mdev -s
	mknod /dev/md1 b 9 1
	echo 'DEVICE partitions' > /etc/mdadm/mdadm.conf
	mdadm -E --scan >> /etc/mdadm/mdadm.conf
	mdadm -A --scan || sh
	mount -oro /dev/md1 /mnt || sh
	mount --move /proc /mnt/proc
	mount --move /sys /mnt/sys
	cd /mnt
	mount --move . /
	exec chroot . /sbin/init 2 > /dev/console 2>/dev/console < /dev/console

Andre

Signature · 1 line
The only person who always got his work done by Friday was Robinson Crusoe
#6 lore raw
In reply to Keld Jørn Simonsen
Quoted 17 lines · On Monday March 10, [email protected] wrote:
Quoted 8 lines · Neil Brown
Quoted 7 lines · On Saturday March 8, [email protected] wrote:

I want to assemble the root partition automatically, without having a configuration file. Is that possible?

mdadm -A --scan

does seem to require a configuration file.

Quoted 7 lines
Quoted 4 lines

On the other hand, I think all info needed is available in the super blocks, and a traversal of the partitions present on the system (ala fdisk -l) could give consistent naming - there seems to be no /dev/md association available in the superblock.

The information that is not present in the super blocks is which array you want to assemble.

Quoted 8 lines

Yse, that is evident.

Quoted 2 lines

This becomes particularly important if you move some drives from one machine to another.

Moving a disk from one machine to another is not the common thing with raids. This is only done in special cases, and not prat of ordinary operations.

I absolutely agree. However the time when you do it you are quite possibly trying to get something that was broken working again. And so you don't want any surprises.

So I encourage configurations where moving devices around will not cause unpleasant surprises. Tagging all arrays with the host name helps remove these surprises.

Quoted 10 lines
Quoted 10 lines

For that reason mdadm knows about a "homehost". You can tag each array with a hint about what host it expects to be assembled on. If you run

  mdadm -As --homehost=`hostname`

then it will auto-assemble any arrays for the current host. If you arrays haven't been tagged for at particular host, then

Quoted 8 lines
Quoted 6 lines
  mdadm -As --homehost=`hostname` --auto-update-homehost

will automatically tag everything that is found for the current host. This is not something that should be done automatically, but it OK to do one when you know you haven't done anything interesting with devices.

Hmm, I am still looking for a way to boot a linúx raid as root.

Look at README.initramfs in the mdadm release.
It might not answer all your questions, but I describes in general how it should work, and provides a simple sample you could build on.

NeilBrown
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html