Changes between Initial Version and Version 1 of linux/centos7-root-on-zfs


Ignore:
Timestamp:
2016-05-15T07:33:14Z (8 years ago)
Author:
root
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • linux/centos7-root-on-zfs

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