This repository has been archived by the owner on Oct 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
zfs_prerequisites.sh
executable file
·102 lines (78 loc) · 2.37 KB
/
zfs_prerequisites.sh
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
set -e
# Add ZFS repo
APT_GET_INSTALL='apt-get install -y --no-install-suggests'
os_codename=$(lsb_release -s -c)
case "$os_codename" in
wheezy|jessie) debian=1 ;;
trusty) ubuntu=1 ;;
*)
echo "Error: Unsupported OS codename ${os_codename}" >&2
exit 1
esac
mirror="$1"
export DEBIAN_FRONTEND=noninteractive
apt-get update
$APT_GET_INSTALL wget
if (( debian )); then
if [[ -z "$mirror" ]]; then
mirror='http://cdn.debian.net/debian'
fi
zfs_url=\
"http://archive.zfsonlinux.org/debian/pool/main/z/zfsonlinux/zfsonlinux_2~${os_codename}_all.deb"
wget "$zfs_url" -O /tmp/zfsonlinux.deb
dpkg -i /tmp/zfsonlinux.deb
# Add backports for udev to fix /dev/disk/by-partuuid
if [[ "$os_codename" == "wheezy" ]]; then
backports_list="/etc/apt/sources.list.d/wheezy-backports.list"
if ! [ -f "$backports_list" ]; then
cat > "$backports_list" <<EOF
deb ${mirror} wheezy-backports main contrib non-free
deb-src ${mirror} wheezy-backports main contrib non-free
EOF
fi
apt-get update
$APT_GET_INSTALL -t wheezy-backports udev
udevadm trigger
udevadm settle
fi
elif (( ubuntu )); then
# We need the grub and zfs-initramfs packages from Wheezy, at least for now.
# But pin everything we don't need away so it doesn't interfere with the
# Ubuntu packages.
zfs_url=\
'http://archive.zfsonlinux.org/debian/pool/main/z/zfsonlinux/zfsonlinux_2~wheezy_all.deb'
wget "$zfs_url" -O /tmp/zfsonlinux.deb
dpkg -i /tmp/zfsonlinux.deb
cat > /etc/apt/preferences.d/pin-zfsonlinux <<EOF
Package: *
Pin: release o=archive.zfsonlinux.org
Pin-Priority: 450
Package: *grub* zfs-initramfs
Pin: release o=archive.zfsonlinux.org
Pin-Priority: 1002
EOF
apt-get update
$APT_GET_INSTALL software-properties-common
apt-add-repository -y ppa:zfs-native/stable
apt-get update
fi
# Install tools
$APT_GET_INSTALL mdadm gdisk dosfstools e2fsprogs
# Install kernel and ZFS
if (( debian )); then
$APT_GET_INSTALL linux-{image,headers}-amd64
$APT_GET_INSTALL debian-zfs
elif (( ubuntu )); then
$APT_GET_INSTALL linux-{image,headers}-generic
$APT_GET_INSTALL ubuntu-zfs
fi
# Check ZFS
if ! lsmod | grep -q '^zfs'; then
modprobe zfs
if ! dmesg | grep -q 'ZFS:'; then
echo 'ZFS module not running, check errors.' >&2
exit 1
fi
fi
echo 'ZFS OK.'