Skip to content

Instantly share code, notes, and snippets.

@knakayama
Created November 13, 2014 05:03
Show Gist options
  • Save knakayama/49ec7adce1fe21a269eb to your computer and use it in GitHub Desktop.
Save knakayama/49ec7adce1fe21a269eb to your computer and use it in GitHub Desktop.
#!/bin/sh -ex
if ! lsb_release --id --short | grep -qF 'Ubuntu'; then
echo "Ubuntu only"
exit 1
fi
if ! lsb_release --codename --short | grep -qF 'precise'; then
echo "12.04 precise only"
exit 1
fi
# system update
apt-get update -y
apt-get upgrade -y
# sysctl.conf
# todo: more tuning
cat << 'EOF' >> /etc/sysctl.conf
vm.swappiness = 0
vm.overcommit_memory = 2
vm.overcommit_ratio = 90
net.core.somaxconn = 1024
EOF
# apt-get install
apt-get install -y smartmontools
# zfs
apt-get install -y python-software-properties
apt-add-repository -y ppa:zfs-native/stable
apt-get install -y debootstrap ubuntu-zfs
for dev in $(ls "/sys/block" | grep -iE '^sd[a-z]$'); do
if [ "$(cat /sys/block/${dev}/removable)" -ne 1 -a "$(cat /sys/block/${dev}/size)" -ne 0 ]; then
INST_DEV="/dev/${dev}5"
break
fi
done
[ -b "$INST_DEV" ] && zpool create -f -m none tank "$INST_DEV"
zfs create -o atime=off -o compression=lzjb -o mountpoint=/backup -o snapdir=visible tank/backup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment