User:Gervai/Raid and LVM hook
From FAIWiki
Contents |
[edit]
Raid + LVM
This is a code based on User:Svamberg/Software RAID which provides support for softraid but no LVM, so I added LVM. This approach works with recent FAI (unlike Setup harddisks 2).
[edit]
See also
Please read User:Svamberg/Software RAID first.
[edit]
Prerequisites
Apart from what already has been said I had some problems which should have been addressed:
- stock grub install doesn't really work under XFS, because grub-install code is still crappy (and seems that it is bound to stay that way). See Debian bugreport about it, and patch your grub-install, otherwise expect hung installs on xfs_freeze.
- install dmsetup, mdadm, lvm2 packages into nfsroot as well as into the clients
- install xfsprogs for xfs into client, if you want to use it (why not, it's nice)
- force loading modules raidX and dm-mod, probably in .../config/class/FAIBASE.var (or any class you prefer)
- You're not advised to put root filesystem on LVM because you may well end up with an unstartable system. (LVM is a userland system so it's not available at kernel startup time unless you're using a working initrd boot. Be prepared to fiddle with it and worry at every kernel upgrade.) Very few rescue CDs support it I belive, very few boot managers support it I believe. I've struggled with it for a while then decided not to do it. YMMW :-)
[edit]
The source
It is available here.
[edit]
Install
- Put the code into
$FAI/hooks/mountdisks.SW_RAID - Save this to
$FAI/hooks/mountdisks.SW_RAID.source(instead of what's on Michal Svamberg's page!)
#!/bin/sh . $LOGDIR/disk_var.sh
- add class SW_RAID to your
$FAI/class/configuration
[edit]
Configure
Raid is configured as Michal described.
LVM follows this syntax:
LVM_VG_CONFIG=vgname[[vgoptions]]=deviceA[,deviceB[,...]]
LVM_LV_CONFIG=vgname/lvname[[lvoption [lvoption ...]]]=size:mountpoint
:[filesystem]:[mountoptions]
[edit]
Full Example
# define raid array
SW_RAID_CONFIG="
md0[mirror]=/dev/sda1,/dev/sdb1:/:xfs:rw:boot
md1[mirror]=/dev/sda6,/dev/sdb6:/var:xfs::
"
# define volume groups
LVM_VG_CONFIG="
vol0[]=/dev/md1
"
# define logical volumes
LVM_LV_CONFIG="
vol0/var[-n var ]=2G:/var:xfs:
vol0/var-log[-n var-log]=5G:/var/log:xfs:
vol0/home[-n home ]=1G:/home:xfs:
vol0/tmp[-n tmp ]=2G:/tmp:xfs:
vol0/usr[-n usr ]=4G:/usr:xfs:
"
[edit]
TODO and FIXMEs
- Should handle 'disk1' instead of hardwired devices somehow
- Should verify user input (duplicate devices, duplicate vg/lv names, etc.)
- Should extend config with other options like boot, etc (I don't need them right now)
