Talk:HOWTO Install on Software RAID
From Gentoo Linux Wiki
added /bin/bash to section 11 and indented as code block
chroot /mnt/gentoo /bin/bash
Contents |
[edit] swap on md
Could somebody please include some pros and cons of putting swap on md? Many other howtos/descriptions seem to suggest not to do this - thanks
Con added...
Adding your swap to md will most likely slow the system down. When the system needs to write to the swap, it will need to send the data for processing twice, once to the swap, then once to the software raid for processing. Linux can stripe swap space already.
Pro added...
Adding your swap to md will make you redundant to swap disk failure. Let's say that the hd where you have the swap dies, then your machine may die after. That won't happen to you if the swap is on raid. (This assumes that your hardware is capable of dealing with hardware failures without killing the entire machine)
| Code: edit /etc/fstab and add the following swap lines |
/dev/sda2 none swap sw,pri=1 0 0 /dev/sdb2 none swap sw,pri=1 0 0 |
See code listing 2.23 Gentoo Linux x86 with Software Raid and LVM2 Quick Install Guide
[edit] mdadm replaces mkraid
After struggling with the 2.6.12-r4 LiveCD installation on my AMD64, I discovered that the RAID install is much simpler with mdadm, rather than mkraid. The mkraid procedure is plagued with aborts (and no clues in the /var/log or the /proc/mdstat), even after doing modprobe md, MAKEDEV md, and anything else I could think of.
The procedure in http://www.gentoo.org/doc/en/gentoo-x86-tipsntricks.xml#software-raid, using mdadm, works like a charm. The operations are saved in /etc/mdadm.conf for future use. I'm not sure if I still need the laboriously created /etc/raidtab anymore...
On the section @Setting up the raid@, if I include --clean anywhere on those lines, all I get is an error, saying @mdadm: unrecognised option '--clean'@
[edit] From gentoo.org:
Software RAID
Note: If you are not familiar with software raid, please read the Software-RAID-HOWTO.
Once you are booted from the LiveCD, load the appropriate RAID modules. For instance, if you plan on using RAID-1:
Code Listing 2.1: Loading the RAID-1 module
- modprobe raid1
When you partition your disks, make sure that your partitions use fd (Linux raid autodetect) as Partition Type instead of 83 (Linux native). You can alter the partition type using the t command in fdisk.
Now before we start creating the RAID arrays, we need to create the metadevice nodes: (** although "MAKEDEV md" works fine instead **)
Code Listing 2.2: Creating metadevice nodes
- mknod /dev/md0 b 9 0
- mknod /dev/md1 b 9 1
- mknod /dev/md2 b 9 2
After partitioning, create the /etc/mdadm.conf file (yes, indeed, on the LiveCD environment) using mdadm, an advanced tool for RAID management. For instance, to have your boot, swap and root partition mirrored (RAID-1) covering /dev/sda and /dev/sdb, you can use:
Code Listing 2.3: mdadm command example
- mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
- mdadm --create --verbose /dev/md1 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2
- mdadm --create --verbose /dev/md2 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3
(Save information about the created devices in mdadm.conf)
- mdadm --detail --scan > /etc/mdadm.conf
The Linux Software RAID driver will start creating the metadevices. You can see its progress in /proc/mdstat. Wait until the metadevices are completely finished before proceeding.
From now onwards, use /dev/md0 for the boot partition, /dev/md1 for the swap partition and /dev/md2 for the root partition.
Now create filesystems on the /dev/md* devices (although mdadm seems to put ext2 on them as a default!?)
After mounting /dev/md2 on /mnt/gentoo, don't forget to copy over /etc/mdadm.conf to /mnt/gentoo/etc.
When you're configuring your kernel, make sure you have the appropriate RAID support in your kernel and not as module.
When installing extra tools, emerge mdadm as well. Note that this isn't available on all LiveCDs so you might not be able to install Gentoo on a Software RAID when using a networkless installation!
When configuring your bootloader, make sure it gets installed in the MBR of both disks if you use mirroring.
[edit] Raid 5 and /boot
Q. Is it advisable to have /boot under raid5? How would one address /boot if it was under raid5 from GRUB?
A. No, not if you are doing software raid. Grub will only pick up on raid 1 boot. Span a raid 1 across all your disks for /boot, and create a raid 5 for /
[edit] /boot on it's own raid device
Q. my command
grub> find /boot/grub/stage1
doesn't find anything
A. try
grub> find /grub/stage1
[edit] Bug with grub line?
Q. I'm implementing a RAID setup, and I'm looking at the instructions here to setup grub to boot from the first non-failed drive. The lines
grub>device (hd0) /dev/hda grub>root (hd0,0) grub>setup (hd0)
and similar for hdb look fishy to me. Shouldn't the 'device' line always have '(hd0)' and varying '/dev/hd[abcdefgh]'? Isn't the point to instruct grub to think that '/dev/hd?' is the first worknig hd, which is '(hd0)'? It does it that way here: http://lists.us.dell.com/pipermail/linux-poweredge/2003-July/008898.html
Follow on Q:
I've just been testing the instructions for installing grub onto the sdb mbr using: device (hd0) /dev/sdb
It appears that using "device (hd0) /dev/sdb; root (hd0,0); setup (hd0)" is identical to running "device (hd1) /dev/sdb; root (hd1,0); setup (hd1)"
[edit] Software RAID 5 and write hole
Does software RAID 5 have the same write hole as hardware RAID 5 or is it somehow fixed?
[edit] bootable flags?
Does the bootable flag have to be set for /boot on all drives in a RAID 1? What about other RAID configs?
- Neither GRUB nor LILO requires bootable flag to be set if they boot from MBR, so no (they require this is they boot from partition and in MBR is DOS-like loader). As far as I know there are no special RAID configuration in order to make the drives bootable. Btw. because it is RAID 1, bootable flag will be set on either all or none drives. --Sten 12:56, 25 December 2006 (UTC)
[edit] Write-intent bitmap
After creating a new raid-array mdadm -D /dev/md9 gave me this output:
# mdadm -D /dev/md9
/dev/md9:
Version : 00.90.03
Creation Time : Fri Jan 5 23:46:54 2007
Raid Level : raid5
Array Size : 32033408 (30.55 GiB 32.80 GB)
Device Size : 16016704 (15.27 GiB 16.40 GB)
Raid Devices : 3
Total Devices : 3
Preferred Minor : 9
Persistence : Superblock is persistent
Update Time : Fri Jan 5 23:52:11 2007
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 64K
UUID : 3ca5d26d:4d36a3eb:1ea9e1b8:87aa7e16
Events : 0.2
Number Major Minor RaidDevice State
0 8 9 0 active sync /dev/sda9
1 8 25 1 active sync /dev/sdb9
2 8 41 2 active sync /dev/sdc9
The article points out that before adding the bitmap there should read 'State : active' but 'State : clean' should be ok too.
After adding the bitmap, the state was 'State : active' .
[edit] Safe to mkfs but is it safe to write data?
Hi all. I read that "If an array is still syncing, you may still proceed to creating filesystems, because the sync operation is completely transparent to the file system". But is it safe to start writing to it while it's still syncing ? -- Xushi
Yes, you may read and write to the raid device while it is syncing. For the safest behavior, create the raid with an intent bitmap or enable the raid with an intent bitmap before adding a new drive. -Ahbritto 08:09, 17 September 2007 (UTC)
[edit] Use of sfdisk
Perhaps a it works under gentoo but i needed this to perform under ubuntu 7.10 and get an error. This one is from http://www.nikhef.nl/pub/projects/grid/gridwiki/index.php/RAID-1_configuration_and_management and worked.
sfdisk -d /dev/sdX | \ sed -e s/sdX/sdY/ | \ sdisk /dev/sdY
--T3kkn0kr4t 20:13, 20 November 2007 (UTC)
[edit] swap on raid0?
Why does this example use raid0 for the swap drive? Isn't this redundant and slow?
See this: http://forums.gentoo.org/viewtopic-t-688201-highlight-.html --69.31.133.16 00:12, 15 April 2008 (UTC)
A: RAID 0 is striping and contains no redundancy. Both reads and writes are split between the two devices. This means that neither reading nor writing must wait for a single disc to finish it's last read or write. This can be compared to RAID1 or RAID5 where read performance is fine because reads can be distributed across discs as in RAID1 while write performance takes a hit because each write touches more than one disc. In RAID1 the data must be written to both discs. In RAID2 the data must be written each disc.
