Quote:
Originally Posted by redcane
LVM can do mirroring. Otherwise you can use the Linux Software RAID system.
|
Wait, LVM can do mirroring? I have LVM running on Software RAID, is that what you mean? I created a mirror (md0) with mdadm, then made a physical volume on the md0 device. (from that PV, I created a volume group, and then logical volumes). If LVM can do mirroring itself, is it 'better' than lvm on RAID?
As for the OP, check out the software Raid, mdadm and all. For your reference, here are my notes from my last install. Some stuff won't apply (like umounting /pub my own nfs mount) or make sense, and I only wrote this, I haven't followed it yet to fix errors, but maybe it will help.
I was using IDE drives so the references to hda and hdb, but as you are using SCSI drives, they will probably be sda and sdb. The most annoying things are the old version of LILO in Slackware, which doesn't support degraded RAID-1, and the default init-rd is missing md entries in /dev.
This will cover creating a sofware RAID-1 environment to run Slackware on. The two devices are hda and hdb. They do not need to be identical, only the portions that will be mirrors.
- Install Slackware onto hda. Probably should apply patches, compile a new kernel, etc.
My custom compiled kernel was installed as /boot/vmlinuz-20060606-2.6.16.20 which included all the modules I needed to boot built-in (sata drivers, reiserfs, md-mod, dm-mod, raid1).
- Install the LVM2 tools from Disc2
- Probably need to modprobe dm-mod
- Create a three partitions on hdb: Probably have to reboot after creating the partitions
- hdb1 128MB type FD (for /boot mirror)
- hdb2 2048 type FD (for swap mirror)
- hdb3 Rest type FD (for LVM PV mirror)
- Create the degraded RAID-1 arrays
- mdadm --create --level=raid1 --raid-devices=2 /dev/md0 missing /dev/hdb1
- mdadm --create --level=raid1 --raid-devices=2 /dev/md1 missing /dev/hdb2
- mdadm --create --level=raid1 --raid-devices=2 /dev/md2 missing /dev/hdb3
- Probably could stand to change the partition type to FD to have the raid autobuild. There's notes about having to run raidstart --all otherwise
- Make filesystems on the RAID devices
- mkfs -t ext2 /dev/md0
- mkswap /dev/md1
- pvcreate /dev/md2
- vgcreate main /dev/md2
- lvcreate main --size 256M --name root
- lvcreate main --size 1024M --name opt
- lvcreate main --size 256M --name tmp
- lvcreate main --size 4096M --name usr
- lvcreate main --size 256M --name var
- lvcreate main --size 4096M --name home
- mkreiserfs -q /dev/main/root
- mkreiserfs -q /dev/main/opt
- mkreiserfs -q /dev/main/tmp
- mkreiserfs -q /dev/main/usr
- mkreiserfs -q /dev/main/var
- mkreiserfs -q /dev/main/home
- Mount all those partitions under /mnt/hd
- mount /dev/main/root /mnt/hd
- mkdir /mnt/hd/opt
- mkdir /mnt/hd/tmp
- mkdir /mnt/hd/usr
- mkdir /mnt/hd/var
- mkdir /mnt/hd/home
- mount /dev/main/opt /mnt/hd/opt
- mount /dev/main/tmp /mnt/hd/tmp
- mount /dev/main/usr /mnt/hd/usr
- mount /dev/main/var /mnt/hd/var
- mount /dev/main/home /mnt/hd/home
- Create a mountpoint for, and mount /boot
- mkdir /mnt/hd/boot
- mount /dev/md0 /mnt/hd/boot
Make an initrd
- If using a generic kernel
- mkinitrd -c -k 2.6.16.18 -m libata:reiserfs:sata_nv:sata_sil:md-mod:dm-mod:raid1
- Or with a custom Kernel
Edit the initrd
- cd /boot/initrd-tree
- rm dev/md[0-4]
- mknod --mode=0660 dev/md0 b 9 0
- mknod --mode=0660 dev/md1 b 9 1
- mknod --mode=0660 dev/md2 b 9 2
- mknod --mode=0660 dev/md3 b 9 3
- mknod --mode=0660 dev/md4 b 9 4
- mkdir sbin
- cp /sbin/lvm.static sbin
Code:
( cd sbin ; rm -rf lvs )
( cd sbin ; ln -sf lvm lvs )
( cd sbin ; rm -rf pvs )
( cd sbin ; ln -sf lvm pvs )
( cd sbin ; rm -rf vgs )
( cd sbin ; ln -sf lvm vgs )
( cd sbin ; rm -rf vgck )
( cd sbin ; ln -sf lvm vgck )
( cd sbin ; rm -rf lvdisplay )
( cd sbin ; ln -sf lvm lvdisplay )
( cd sbin ; rm -rf pvchange )
( cd sbin ; ln -sf lvm pvchange )
( cd sbin ; rm -rf pvcreate )
( cd sbin ; ln -sf lvm pvcreate )
( cd sbin ; rm -rf vgmknodes )
( cd sbin ; ln -sf lvm vgmknodes )
( cd sbin ; rm -rf pvremove )
( cd sbin ; ln -sf lvm pvremove )
( cd sbin ; rm -rf pvresize )
( cd sbin ; ln -sf lvm pvresize )
( cd sbin ; rm -rf lvmchange )
( cd sbin ; ln -sf lvm lvmchange )
( cd sbin ; rm -rf lvmsadc )
( cd sbin ; ln -sf lvm lvmsadc )
( cd sbin ; rm -rf vgcfgrestore )
( cd sbin ; ln -sf lvm vgcfgrestore )
( cd sbin ; rm -rf lvmdiskscan )
( cd sbin ; ln -sf lvm lvmdiskscan )
( cd sbin ; rm -rf pvdisplay )
( cd sbin ; ln -sf lvm pvdisplay )
( cd sbin ; rm -rf lvmsar )
( cd sbin ; ln -sf lvm lvmsar )
( cd sbin ; rm -rf lvscan )
( cd sbin ; ln -sf lvm lvscan )
( cd sbin ; rm -rf vgchange )
( cd sbin ; ln -sf lvm vgchange )
( cd sbin ; rm -rf vgcreate )
( cd sbin ; ln -sf lvm vgcreate )
( cd sbin ; rm -rf pvmove )
( cd sbin ; ln -sf lvm pvmove )
( cd sbin ; rm -rf pvscan )
( cd sbin ; ln -sf lvm pvscan )
( cd sbin ; rm -rf vgexport )
( cd sbin ; ln -sf lvm vgexport )
( cd sbin ; rm -rf vgextend )
( cd sbin ; ln -sf lvm vgextend )
( cd sbin ; rm -rf vgimport )
( cd sbin ; ln -sf lvm vgimport )
( cd sbin ; rm -rf vgscan )
( cd sbin ; ln -sf lvm vgscan )
( cd sbin ; rm -rf vgmerge )
( cd sbin ; ln -sf lvm vgmerge )
( cd sbin ; rm -rf vgsplit )
( cd sbin ; ln -sf lvm vgsplit )
( cd sbin ; rm -rf lvchange )
( cd sbin ; ln -sf lvm lvchange )
( cd sbin ; rm -rf lvcreate )
( cd sbin ; ln -sf lvm lvcreate )
( cd sbin ; rm -rf lvextend )
( cd sbin ; ln -sf lvm lvextend )
( cd sbin ; rm -rf vgreduce )
( cd sbin ; ln -sf lvm vgreduce )
( cd sbin ; rm -rf vgrename )
( cd sbin ; ln -sf lvm vgrename )
( cd sbin ; rm -rf vgremove )
( cd sbin ; ln -sf lvm vgremove )
( cd sbin ; rm -rf vgconvert )
( cd sbin ; ln -sf lvm vgconvert )
( cd sbin ; rm -rf vgcfgbackup )
( cd sbin ; ln -sf lvm vgcfgbackup )
( cd sbin ; rm -rf lvreduce )
( cd sbin ; ln -sf lvm lvreduce )
( cd sbin ; rm -rf lvrename )
( cd sbin ; ln -sf lvm lvrename )
( cd sbin ; rm -rf lvremove )
( cd sbin ; ln -sf lvm lvremove )
( cd sbin ; rm -rf lvresize )
( cd sbin ; ln -sf lvm lvresize )
( cd sbin ; rm -rf vgdisplay )
( cd sbin ; ln -sf lvm vgdisplay )
Update the initrd.gz
- cd /boot
- mkinitrd
Edit lilo.conf, add a new entry to bootstrap the RAID devices
- Don't change the boot= at this time, wait until booted off the mirror
Code:
vi /etc/lilo.conf
image = /boot/vmlinuz-20060606-2.6.16.20
root = /dev/main/root
initrd = /boot/initrd.gz
label = nRAID-2.6.16.18
read-only
Copy everything over to the new home
- umount /pub
- rsync -av --exclude /mnt/hd --exclude /proc --exclude /sys / /mnt/hd/
- or cp -avx / /mnt/hd
- cp -avx /boot /mnt/hd/
Edit new fstab
- vi /mnt/hd/etc/fstab
Code:
/dev/md1 swap swap defaults 0 0
/dev/main/root / reiserfs defaults 0 0
/dev/md0 /boot ext2 defaults 1 1
/dev/cdrom /mnt/cdrom auto noauto,owner,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
proc /proc proc defaults 0 0
/dev/main/var /var reiserfs defaults 0 0
/dev/main/opt /opt reiserfs defaults 0 0
/dev/main/tmp /tmp reiserfs defaults 0 0
/dev/main/usr /usr reiserfs defaults 0 0
/dev/main/var /var reiserfs defaults 0 0
/dev/main/home /home reiserfs defaults 0 0
scrambled:/home/brian /pub nfs defaults 0 0
Reboot and see if it boots off the raid!
If it boots, update the boot= line in lilo.conf
- vi /etc/lilo.conf
- boot=/dev/md0
- raid-extra-boot=mbr
- delete stuff from /boot that is no longer relevant (old kernels, old initrds, etc.)
Hard work, LILO 22.5.9 (with Slackware 10.2 and -current as of 2006-06-06) can't handle the degraded RAID-1. Download, compile and install Lilo 22.7.1 (atleast).
Run lilo
- lilo
- reboot and try to boot off the second disk.
Create mirror partitions
- Wipe out the partition table (and some) on the old drive
- dd if=/dev/zero of=/dev/sda bs=512 count=2000 # BE VERY CAREFUL!
- Reboot
- Duplicate the partition table from the second drive to the first drive
- sfdisk -d /dev/sdb | sfdisk /dev/sda # BE VERY CAREFUL!
- Reboot
- Add the new partitions to the correct RAID array
- mdadm --detail /dev/md0
- mdadm /dev/md0 --add /dev/sda1
- mdadm --detail /dev/md1
- mdadm /dev/md1 --add /dev/sda2
- mdadm --detail /dev/md2
- mdadm /dev/md2 --add /dev/sda3
- run lilo and see that both mbr's get updated (SDA and SDB)
HTH.