-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer
executable file
·74 lines (55 loc) · 2.02 KB
/
installer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
block_device=/dev/sda
pool_name=tnewman
release=disco
country=tw
apt update
apt install -y zfsutils-linux debootstrap
modprobe zfs
lsmod | grep zfs
# no substitution needed here
cat > /etc/udev/rules.d/90-zfs.rules << 'EOF'
KERNEL=="sd*[!0-9]", IMPORT{parent}=="ID_*", SYMLINK+="$env{ID_BUS}-$env{ID_SERIAL}"
KERNEL=="sd*[0-9]", IMPORT{parent}=="ID_*", SYMLINK+="$env{ID_BUS}-$env{ID_SERIAL}-part%n"
EOF
udevadm trigger
wipefs -a $block_device
sgdisk -Z -n9:-8M:0 -t9:bf07 -c9:Reserved -n2:-8M:0 -t2:ef02 -c2:GRUB -n1:0:0 -t1:bf01 -c1:ZFS $block_device
sgdisk -p $block_device
zpool create -f -m none -o ashift=12 -O compression=lz4 $pool_name ${block_device}1
zpool status -v
zfs create -o mountpoint=/ $pool_name/root
zfs create -o mountpoint=/home $pool_name/home
zfs list
zpool export $pool_name
zpool import -d /dev/disk/by-id -R /mnt $pool_name
debootstrap $release /mnt
cp {,/mnt}/etc/udev/rules.d/90-zfs.rules
cat > /mnt/etc/apt/sources.list << EOF
###### Ubuntu Main Repos
deb http://${country}.archive.ubuntu.com/ubuntu/ disco main restricted universe multiverse
###### Ubuntu Update Repos
deb http://${country}.archive.ubuntu.com/ubuntu/ ${release}-security main restricted universe multiverse
deb http://${country}.archive.ubuntu.com/ubuntu/ ${release}-updates main restricted universe multiverse
deb http://${country}.archive.ubuntu.com/ubuntu/ ${release}-proposed main restricted universe multiverse
deb http://${country}.archive.ubuntu.com/ubuntu/ ${release}-backports main restricted universe multiverse
EOF
mount --rbind {,/mnt}/dev
mount --rbind {,/mnt}/proc
mount --rbind {,/mnt}/sys
cat > /mnt/chrootscript << EOF
apt update
locale-gen en_US.UTF-8
apt install -y zfsutils-linux zfs-initramfs zfs-dkms zfs-zed \
linux-image-generic linux-headers-generic \
grub2-common grub-pc \
acpi-support neovim ifupdown
find /boot -iname '*zfs*'
passwd root
exit
EOF
chmod +x /mnt/chrootscript
chroot /mnt /chrootscript
grub-probe /mnt
grub-install --root-directory=/mnt $block_device
shutdown -rf now