| 61 | |
| 62 | == конфигурирование |
| 63 | {{{ |
| 64 | #!bash |
| 65 | d0=/dev/sda; d1=/dev/sdb |
| 66 | vg=vg_md; r=lv_r; s=lv_swp |
| 67 | r0=/dev/md10; r1=/dev/md11 |
| 68 | yum install -y dump |
| 69 | cd /boot |
| 70 | tar --create --file /root/boot.tar . |
| 71 | cd |
| 72 | umount /boot |
| 73 | dd if=/dev/zero of=${d0} bs=1048576 count=128 |
| 74 | sfdisk ${d0} << EOF |
| 75 | unit: sectors |
| 76 | 0:start=63, size=1076292, Id=fd, bootable |
| 77 | 0:start=1076355, size=65111445, Id=fd |
| 78 | EOF |
| 79 | mdadm --create ${r0} \ |
| 80 | --force \ |
| 81 | --level=1 \ |
| 82 | --metadata=0.90 \ |
| 83 | --raid-devices=1 \ |
| 84 | ${d0}1 |
| 85 | mdadm --create ${r1} \ |
| 86 | --force \ |
| 87 | --level=1 \ |
| 88 | --metadata=0.90 \ |
| 89 | --raid-devices=1 \ |
| 90 | ${d0}2 |
| 91 | printf "MAILADDR root\n" >/etc/mdadm.conf |
| 92 | mdadm --examine --scan >>/etc/mdadm.conf |
| 93 | mke2fs -t ext4 -m 1 -L boot ${r0} |
| 94 | sed -ri "s#.+/boot#LABEL=boot /boot#" /etc/fstab |
| 95 | mount /boot |
| 96 | cd /boot |
| 97 | tar xpf /root/boot.tar |
| 98 | pvcreate ${r1} |
| 99 | vgcreate ${vg} ${r1} |
| 100 | lvcreate -L 16G -n ${s} ${vg} |
| 101 | lvcreate -l 100%FREE -n ${r} ${vg} |
| 102 | mkswap /dev/${vg}/${s} |
| 103 | mke2fs -t ext4 -m 1 /dev/${vg}/${r} |
| 104 | mount /dev/${vg}/${r} /mnt |
| 105 | cd /mnt |
| 106 | dump -a0f - / | restore -rf - |
| 107 | sed -i " |
| 108 | s#/dev/mapper/vg_main-lv_root#/dev/mapper/${vg}-${r}#; |
| 109 | s#vg_main/lv_root #${vg}/${r}#; |
| 110 | s# rd_LVM_LV=vg_main/lv_swap##; |
| 111 | s#rd_NO_MD ## |
| 112 | " \ |
| 113 | /boot/grub/grub.conf |
| 114 | sed -i " |
| 115 | s#/dev/mapper/vg_main-lv_root#/dev/mapper/${vg}-${r}#; |
| 116 | s#/dev/mapper/vg_main-lv_swap#/dev/mapper/${vg}-${s}# |
| 117 | " \ |
| 118 | /mnt/etc/fstab |
| 119 | printf "(hd0) ${d0}\n(hd1) ${d1}\n" >/boot/grub/device.map |
| 120 | grub-install --root-directory=/ ${d0} |
| 121 | grub-install --root-directory=/ ${d0}1 |
| 122 | dracut -f |
| 123 | reboot |
| 124 | |
| 125 | lvremove -f vg_main |
| 126 | vgremove vg_main |
| 127 | pvremove ${d1}1 |
| 128 | dd if=/dev/zero of=${d1} bs=1048576 count=128 |
| 129 | sfdisk ${d1} << EOF |
| 130 | unit: sectors |
| 131 | 0:start=63, size=1076292, Id=fd, bootable |
| 132 | 0:start=1076355, size=65111445, Id=fd |
| 133 | EOF |
| 134 | mdadm --grow ${r0} \ |
| 135 | --raid-devices=2 \ |
| 136 | --add ${d1}1 |
| 137 | mdadm --grow ${r1} \ |
| 138 | --raid-devices=2 \ |
| 139 | --add ${d1}2 |
| 140 | grub-install --root-directory=/ ${d1} |
| 141 | grub-install --root-directory=/ ${d1}1 |
| 142 | }}} |
| 143 | |
| 144 | == обсуждение |
| 145 | почесать языком можно [blog:about здесь]. |