| 1 | = установка centos 7 с / на zfs |
| 2 | |
| 3 | [[PageOutline(2-3,содержание)]] |
| 4 | |
| 5 | {{{ |
| 6 | #!bash |
| 7 | yum install zfs-dracut |
| 8 | sed -i 's#ZFS=${rpool}${bootfs}##' /etc/grub.d/10_linux |
| 9 | sed -i 's#ZPOOL_IMPORT_OPTS=""#ZPOOL_IMPORT_OPTS="-d /dev/disk/by-partlabel"#' /usr/lib/dracut/modules.d/90zfs/zfs-lib.sh |
| 10 | |
| 11 | for i in b c d; do |
| 12 | sgdisk -g \ |
| 13 | -n 1:2048:2099199 /dev/sd${i} \ |
| 14 | -t 1:ef02 /dev/sd${i} \ |
| 15 | -c 1:boot-${i} \ |
| 16 | -n 2:2099200:18876415 /dev/sd${i} \ |
| 17 | -t 2:fd00 /dev/sd${i} \ |
| 18 | -c 2:swap-${i} \ |
| 19 | -n 3:18876416:1629487070 /dev/sd${i} \ |
| 20 | -t 3:bf00 /dev/sd${i} \ |
| 21 | -c 3:main-${i} |
| 22 | done |
| 23 | |
| 24 | mdadm --create /dev/md22 \ |
| 25 | --level=1 --raid-devices=3 \ |
| 26 | /dev/sdb2 \ |
| 27 | /dev/sdc2 \ |
| 28 | /dev/sdd2 |
| 29 | mkswap -L swap-m /dev/md22 |
| 30 | |
| 31 | zpool create \ |
| 32 | -o ashift=12 \ |
| 33 | -O compression=lz4 \ |
| 34 | zroot \ |
| 35 | raidz2 /dev/disk/by-partlabel/main-[b-d] |
| 36 | zfs create zroot/centos7-01 |
| 37 | |
| 38 | mkdir /mnt/tmp |
| 39 | mount --bind / /mnt/tmp |
| 40 | rsync -avPX /mnt/tmp/. /zroot/centos7-01/. |
| 41 | umount /mnt/tmp |
| 42 | |
| 43 | cat <<EOF >/zroot/centos7-01/fstab |
| 44 | LABEL=boot-m /boot ext4 defaults 0 0 |
| 45 | LABEL=boot-m swap swap defaults 0 0 |
| 46 | EOF |
| 47 | |
| 48 | mdadm --create /dev/md11 \ |
| 49 | --level=1 --raid-devices=3 \ |
| 50 | /dev/sdb1 \ |
| 51 | /dev/sdc1 \ |
| 52 | /dev/sdd1 |
| 53 | mkfs.ext4 -L boot-m /dev/md22 |
| 54 | mount /dev/md11 /zroot/centos7-01/boot |
| 55 | |
| 56 | mount --bind /boot /mnt/tmp |
| 57 | rsync -avPX /mnt/tmp/. /zroot/centos7-01/boot/. |
| 58 | umount /mnt/tmp |
| 59 | |
| 60 | for dir in proc sys dev; do |
| 61 | mount --bind /$dir /zroot/centos7-01/$dir |
| 62 | done |
| 63 | |
| 64 | for dir in proc sys dev; do |
| 65 | mount --bind /$dir /mnt/$dir |
| 66 | done |
| 67 | |
| 68 | vi /etc/default/grub |
| 69 | GRUB_CMDLINE_LINUX="crashkernel=auto root=zfs:zroot/centos7-01" |
| 70 | |
| 71 | mdadm --examine --scan | |
| 72 | sed 's# /dev/md/# /dev/md#g' >/etc/mdadm.conf |
| 73 | ln -s /dev/disk/by-partlabel/* /dev |
| 74 | dracut -f -v /boot/initramfs-$(uname -r).img $(uname -r) |
| 75 | grub2-mkconfig -o /boot/grub2/grub.cfg |
| 76 | grep root /boot/grub2/grub.cfg |
| 77 | for d in /dev/sd[b-d]; do |
| 78 | grub2-install --boot-directory=/boot ${d} |
| 79 | done |
| 80 | |
| 81 | exit |
| 82 | }}} |