#! /bin/sh . ./settings00.sh apt-get update #sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/g" /etc/ssh/sshd_config #service ssh restart modprobe zfs # If you are re-using a MDADM disk, clear it as necessary: # # If the disk was previously used in an MD array, zero the superblock: #apt install --yes mdadm #mdadm --zero-superblock --force /dev/disk/by-id/$DISK1 #mdadm --zero-superblock --force /dev/disk/by-id/$DISK2 #mdadm --zero-superblock --force /dev/disk/by-id/$DISK3 # Clear the partition table: sgdisk --zap-all /dev/disk/by-id/$DISK1 sgdisk --zap-all /dev/disk/by-id/$DISK2 sgdisk --zap-all /dev/disk/by-id/$DISK3 # 2.2 Partition your disk: # # We assume advanced format: 4096 bytes per sector, 8 multiple # # Legacy (BIOS) booting (part-1): sgdisk -a1 -n1:40:2047 -t1:EF02 /dev/disk/by-id/$DISK1 sgdisk -a1 -n1:40:2047 -t1:EF02 /dev/disk/by-id/$DISK2 sgdisk -a1 -n1:40:2047 -t1:EF02 /dev/disk/by-id/$DISK3 # ZFS partition: sgdisk -n2:0:0 -t2:BF01 /dev/disk/by-id/$DISK1 sgdisk -n2:0:0 -t2:BF01 /dev/disk/by-id/$DISK2 sgdisk -n2:0:0 -t2:BF01 /dev/disk/by-id/$DISK3 ## ## Create POOL ## zpool create -f -o ashift=12 -o autoexpand=on \ -O atime=off -O compression=off \ -O mountpoint=/ -R /mnt \ $POOL raidz2 \ /dev/disk/by-id/$DISK1-part2 \ /dev/disk/by-id/$DISK2-part2 \ /dev/disk/by-id/$DISK3-part2 zpool autoexpand=on $POOL zpool autoreplace=off $POOL zpool listsnapshots=off $POOL zfs set dedup=off $POOL zfs set compression=off $POOL zfs set atime=off $POOL zfs set mountpoint=none $POOL zfs set aclinherit=passthrough $POOL zfs set acltype=posixacl $POOL zfs set xattr=sa $POOL # Create Dataset System Root zfs create -o mountpoint=none $POOL/system zfs create -o mountpoint=/ $POOL/system/debian #zfs mount $POOL/system/debian zpool set bootfs=$POOL/system/debian $POOL zfs create -o compression=lz4 $POOL/system/debian/var # Create Datasets .. zfs create -o mountpoint=/home $POOL/users zfs create -o mountpoint=/root $POOL/users/root zfs create -o mountpoint=/backup -o compression=lz4 $POOL/backup zfs create -o mountpoint=/data $POOL/data zfs create -o mountpoint=/srv $POOL/services zfs create -o mountpoint=/usr/local/projects -o compression=lz4 $POOL/projects ## Export / Import ( '-d ..' also changes the dev names ) ##zpool export $POOL ##zpool import -d /dev/disk/by-id -R /mnt $POOL ## ## Prepare ROOT ## ## /mnt already must exist as the just created zfs fs ##mkdir -p /mnt (cd /mnt && \ tar --xattrs -xapf $STRAPBALL ) zfs set devices=off $POOL echo $MYHOSTNAME > /mnt/etc/hostname echo "127.0.1.1 $MYHOSTNAME" >> /mnt/etc/hosts #or if the system has a real name in DNS: #echo "127.0.1.1 $MYFQDN $MYHOSTNAME" >> /mnt/etc/hosts # Using NetworkManager should not require this #mv /mnt/etc/resolv.conf /mnt/etc/resolv.conf-orig #cat /etc/resolv.conf > /mnt/etc/resolv.conf echo You may want to adjust /mnt/etc/network/interfaces mkdir -p /mnt/root/debian-zfs-live cp -a ../* /mnt/root/debian-zfs-live mount --rbind /dev /mnt/dev mount --rbind /proc /mnt/proc mount --rbind /sys /mnt/sys mount --make-rslave /mnt/dev mount --make-rslave /mnt/proc mount --make-rslave /mnt/sys echo umount -R /mnt/dev echo umount -R /mnt/proc echo umount -R /mnt/sys echo "cat /proc/mounts | awk '{print $2}' | grep "/mnt" | sort -r | xargs umount" echo RUN chroot /mnt /bin/bash --login