Created
October 11, 2015 08:27
-
-
Save jorjuato/790f21bc6aa6d6f25bd4 to your computer and use it in GitHub Desktop.
Create Debian 8 ZFS pool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from: http://bernaerts.dyndns.org/linux/75-debian/279-debian-wheezy-zfs-raidz-pool | |
#1. Install Packages | |
wget http://archive.zfsonlinux.org/debian/pool/main/z/zfsonlinux/zfsonlinux_4_all.deb | |
dpkg -i zfsonlinux_4_all.deb | |
wget http://zfsonlinux.org/4D5843EA.asc -O - | apt-key add - | |
apt-get update | |
apt-get install debian-zfs parted ntfs-3g mountall | |
#2. ZFS Partitioning | |
zpool status | |
ls -l /dev/disk/by-id/* | |
parted /dev/disk/by-id/ata-WDC_WD20EFRX-68AX9N0_WD-WMC301384865 mklabel gpt | |
parted /dev/disk/by-id/ata-WDC_WD20EFRX-68AX9N0_WD-WMC301555904 mklabel gpt | |
parted /dev/disk/by-id/ata-WDC_WD20EFRX-68AX9N0_WD-WMC301557680 mklabel gpt | |
parted /dev/disk/by-id/ata-WDC_WD20EFRX-68AX9N0_WD-WMC301571260 mklabel gpt | |
#3. Pool creation | |
zpool create -m none -o ashift=12 naspool raidz ata-WDC_WD20EFRX-68AX9N0_WD-WMC301384865 ata-WDC_WD20EFRX-68AX9N0_WD-WMC301555904 ata-WDC_WD20EFRX-68AX9N0_WD-WMC301557680 ata-WDC_WD20EFRX-68AX9N0_WD-WMC301571260 | |
zfs set atime=off naspool | |
zfs set dedup=off naspool | |
zpool list | |
#4. Mount Filesystem | |
mkdir /mnt/data | |
zfs create naspool/data | |
zfs set mountpoint=/mnt/data naspool/data | |
# Edit /etc/default/zfs to enable automount | |
#5. Setup Snapshots | |
#5.1. Install zfs-auto-snapshot | |
wget -O /usr/local/sbin/zfs-auto-snapshot.sh https://raw.github.com/zfsonlinux/zfs-auto-snapshot/master/src/zfs-auto-snapshot.sh | |
chmod +x /usr/local/sbin/zfs-auto-snapshot.sh | |
#5.2. Configure Snapshots | |
zfs set com.sun:auto-snapshot=true naspool/data | |
zfs get all naspool/data | grep auto-snapshot | |
zfs set snapdir=visible naspool/data | |
#5.3. Automatic Snapshots | |
wget -O /etc/cron.hourly/zfs-snapshot-hourly https://raw.githubusercontent.com/NicolasBernaerts/debian-scripts/master/zfs/zfs-snapshot-hourly | |
wget -O /etc/cron.daily/zfs-snapshot-daily https://raw.githubusercontent.com/NicolasBernaerts/debian-scripts/master/zfs/zfs-snapshot-daily | |
wget -O /etc/cron.weekly/zfs-snapshot-weekly https://raw.githubusercontent.com/NicolasBernaerts/debian-scripts/master/zfs/zfs-snapshot-weekly | |
chmod +x /etc/cron.hourly/zfs-snapshot-hourly | |
chmod +x /etc/cron.daily/zfs-snapshot-daily | |
chmod +x /etc/cron.weekly/zfs-snapshot-weekly | |
#6. Periodic Scrub | |
wget -O /etc/cron.weekly/zfs-scrub-weekly https://raw.githubusercontent.com/NicolasBernaerts/debian-scripts/master/zfs/zfs-scrub-weekly | |
chmod +x /etc/cron.weekly/zfs-scrub-weekly | |
#7. Useful commands | |
zfs list -t snapshot | |
zfs list | |
zpool list | |
zpool status | |
zpool iostat | |
#8 ZPool Types | |
#ZPool Stripe group: | |
zpool create vol0 /dev/sda /dev/sdb /dev/sdc | |
#ZPool mirror group: | |
zpool create vol0 mirror /dev/sda /dev/sdb | |
#ZPool raidz group: Similar to RAID5. | |
zpool create vol0 raidz /dev/sda /dev/sdb /dev/sdc | |
#ZPool raidz2 set: Similar to RAID5 with dual parity. | |
zpool create vol0 raidz2 /dev/sdb /dev/sdc1 /dev/sdd /dev/sde | |
#Adding a spare: | |
zpool add vol0 spare /dev/sde | |
#Add storage to a MIRROR, RAIDZ or RAIDZ2 ZPool (example): | |
zpool add vol0 raidz2 /dev/sde /dev/sdf /dev/sdg | |
#Deleting a zpool and deleting all data within the zpool: | |
zpool destroy nameofzpool | |
#Removing a Zpool | |
zpool export nameofzpool | |
#Adding a Zpool | |
zpool import nameofzpool |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment