Hvordan sette opp, og drifte et Skolelinux nettverk.: Hvordan bruke mindre tid på å drifte, og mer på opplæring av elevene. | ||
---|---|---|
Forrige | Neste |
![]() | Dette kan lett gå galt, med tap av alt du har på diskene! Du er advart! DETTE VIKER IKKE HELT OPTIMALT. |
Dette er en kjap og "upolert" oppskrift for software raid i Skolelinux
Trenger å installere denne pakken
apt-get install mdadm
For å kunne partisjonere den ledige disken, så må smartsuit først stoppes
/etc/init.d/smartsuite stop
Hvis du tidligere har hatt software raid på diskene, så kan du fjerne superblock med mdadm --zero-superblock /dev/hd{a,c}{1,5,6}
sfdisk -d /dev/hda | sed 's/Id=83/Id=fd/g ; s/Id=8e/Id=fd/g' | sfdisk /dev/hdc
echo 'DEV /dev/sd* /dev/hd*' > /etc/mdadm/mdadm.conf
mdadm --create /dev/md/1 --level=1 --raid-disks=2 missing /dev/hdc1
mdadm --create /dev/md/5 --level=1 --raid-disks=2 missing /dev/hdc5
mdadm --create /dev/md/6 --level=1 --raid-disks=2 missing /dev/hdc6
mdadm -E -s | grep ARRAY >> /etc/mdadm/mdadm.conf
pvcreate /dev/md5 -ff
vgscan
pvcreate /dev/md6 -ff
vgscan
vgcreate vg_md_system /dev/md/6
vgcreate vg_md_data /dev/md/5
Ta maskinen ned i runlevel 1, men behold ssh så vi kan gjøre dette remote
for ALL in $(ls /etc/rc1.d/K* | grep -v ssh) ; do $ALL stop ; done
for ALL in $(ls /etc/rc2.d/S* | grep -v ssh) ; do $ALL stop ; done
mkfs.ext3 /dev/md/1 ; mount /dev/md/1 /mnt ; cp -ax / /mnt
vgdisplay -v | grep -E "^LV Name|^LV Size"
vgdisplay -v | grep -E "^LV Name|^LV Size" LV Name /dev/vg_data/lv_home0 LV Size 416 MB LV Name /dev/vg_data/lv_backup LV Size 512 MB LV Name /dev/vg_system/lv_swap LV Size 96 MB LV Name /dev/vg_system/lv_var LV Size 160 MB LV Name /dev/vg_system/lv_usr LV Size 448 MBPass her på at størrelsene stemmer overens med det vgdisplay -v gir og det du bruker med lvcreate
lvcreate vg_md_data -n lv_home0 -L 416M
lvcreate vg_md_data -n lv_backup -L 512M
lvcreate vg_md_system -n lv_swap -L 96M
lvcreate vg_md_system -n lv_var -L 160M
lvcreate vg_md_system -n lv_usr -L 448M
umount /mnt ; mkfs.ext3 /dev/md/1 ; mount /dev/md/1 /mnt ; cp -ax / /mnt
for ALL in /dev/vg_md*/lv_* ; do mkfs.ext3 $ALL; done
mkswap /dev/vg_md_system/lv_swap
sed s/vg_/vg_md_/ /etc/fstab | sed s/[hs]da1/md1/ > /mnt/etc/fstab
cp /mnt/etc/fstab /root
mount | grep "^/dev/vg_" | sed s/vg_/vg_md_/ | while read DEV NULL MOUNT NULL ; do mount $DEV /mnt$MOUNT ; done
cp -a /usr /var /skole /mnt
cd /mnt/dev ; /sbin/MAKEDEV std sda sdb hda hdb hdc hdd hde hdf hdg hdh md console
sed s:DELAY=0:DELAY=5: /etc/mkinitrd/mkinitrd.conf > /mnt/etc/mkinitrd/mkinitrd.conf
mkinitrd -o /mnt/boot/initrd.img-$(uname -r) -r /dev/md1
rm /mnt/vmlinuz* /mnt/initrd.img*
cd /mnt/boot ; ln -s vmlinuz-$(uname -r) vmlinuz ; ln -s initrd.img-$(uname -r) initrd.img
echo -e "\ntitle Raid\nroot (hd1,0)\nkernel /boot/vmlinuz root=/dev/md1 ro\ninitrd /boot/initrd.img\nboot" >> /boot/grub/menu.lst
Husk å velge "Raid" i GRUB menyen når du booter, eller du kan sette at "Raid" skal være Default boot-opsjon.
REBOOT
fdisk -l /dev/hdc
Partisjoner /dev/hda akkurat slik som /dev/hdc er partisjonert.tjener:~# fdisk /dev/hda The number of cylinders for this disk is set to 4092. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): t Partition number (1-6): 1 Hex code (type L to list codes): fd Changed system type of partition 1 to fd (Linux raid autodetect) Command (m for help): t Partition number (1-6): 5 Hex code (type L to list codes): fd Changed system type of partition 5 to fd (Linux raid autodetect) Command (m for help): t Partition number (1-6): 6 Hex code (type L to list codes): fd Changed system type of partition 6 to fd (Linux raid autodetect) Command (m for help): p Disk /dev/hda: 16 heads, 63 sectors, 4092 cylinders Units = cylinders of 1008 * 512 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 271 136552+ fd Linux raid autodetect /dev/hda2 272 4092 1925784 f Win95 Ext'd (LBA) /dev/hda5 272 2497 1121872+ fd Linux raid autodetect /dev/hda6 2498 4009 762016+ fd Linux raid autodetect Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Enheten eller ressursen opptatt. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. tjener:~#
mdadm /dev/md/1 --add /dev/hda1
cat /proc/mdstat
mkinitrd -o /boot/initrd.img-$(uname -r) -r /dev/md1
REBOOT
mdadm /dev/md/5 --add /dev/hda5
mdadm /dev/md/6 --add /dev/hda6
fikse /boot/grub/menu.lst title Skolelinux/Woody root (hd0,0) kernel /boot/vmlinuz root=/dev/md1 ro initrd /boot/initrd.img savedefault boot [husk grub ser diskene i rekkefølge, med 0 som første]
echo -e 'root (hd1,0)\nsetup (hd0)' | grub --batch
echo -e 'root (hd0,0)\nsetup (hd0)' | grub --batch
vgrename vg_md_data vg_data
vgrename vg_md_system vg_system
sed s/vg_md_/vg_/ /etc/fstab > /etc/fstab2 && mv /etc/fstab2 /etc/fstab
Nå kan du nappe ut en av diskene og se hva som skjer.