pax_global_header 0000666 0000000 0000000 00000000064 13720567017 0014522 g ustar 00root root 0000000 0000000 52 comment=b658663aecc06fb11e466e102b078312f7a0ee33
zfs-format-disk-master/ 0000775 0000000 0000000 00000000000 13720567017 0015377 5 ustar 00root root 0000000 0000000 zfs-format-disk-master/.gitignore 0000664 0000000 0000000 00000000012 13720567017 0017360 0 ustar 00root root 0000000 0000000 /.project
zfs-format-disk-master/LICENSE.md 0000664 0000000 0000000 00000001157 13720567017 0017007 0 ustar 00root root 0000000 0000000 This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . zfs-format-disk-master/README.md 0000664 0000000 0000000 00000001043 13720567017 0016654 0 ustar 00root root 0000000 0000000 # zfs-format-disk
This script is responsible to properly create the partitions table required for a ZFS disk to be used on Proxmox VE server.
## Installation
As root:
```
curl http://git.patrikdufresne.com/pdsl/zfs-format-disk/raw/master/zfs-format-disk > /usr/local/sbin/zfs-format-disk
chmod +x /usr/local/sbin/zfs-format-disk
```
# Usage
To create the partition and instal grub on the disk:
```
zfs-format-disk /dev/sdf
```
# Changelog
## Aug 23, 2020
* Adding support for EFI layout in addition of legacy layout
zfs-format-disk-master/zfs-format-disk 0000664 0000000 0000000 00000004247 13720567017 0020351 0 ustar 00root root 0000000 0000000 #!/bin/bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# This script should format the given disk for ZFS partition
#
# Taken from https://github.com/proxmox/pve-installer/blob/master/proxinstall
#
# Legacy Layout
# 1 - GRUB boot partition: 1M
# 2 - OS/Data partition
# 9 - ZFS reserved partition
#
# EFI Layout
# 1 - GRUB boot partition: 1M
# 2 - EFI ESP: 128M
# 3 - OS/Data partition
TARGET_DEV="$1"
if [ ! -b "$TARGET_DEV" -o -z "$TARGET_DEV" ]; then
echo "Usage:"
echo " zfs-format-disk "
echo " zfs-format-disk /dev/sda"
exit 1
fi
# Since Proxmox v6, EFI layout might be in used even if efi is not used for booting.
# For this reason, we need to check if EFI layout is in used for other disk.
EFI=0
if fdisk -l | grep 'EFI System' > /dev/null; then
EFI=1
fi
CMD="/sbin/sgdisk -a1"
if [ $EFI -eq 1 ]; then
# GRUB boot partition
CMD="$CMD -n1:34:2047 -t1:EF02"
# EFI Boot
CMD="$CMD -n2:2048:1050623 -t2:ef00"
# OS/DATA partition
CMD="$CMD -n3:1050624:0 -t3:BF01 -c 3:zfs"
else
# GRUB boot partition: 1M
CMD="$CMD -n1:34:2047 -t1:EF02"
# ZFS reserved partition
CMD="$CMD -n3:-8M:0 -t3:BF07"
# OS/Data partition
CMD="$CMD -n2:2048:0 -t2:BF01 -c 2:zfs"
fi
CMD="$CMD $TARGET_DEV"
# Zap-all partition tale
/sbin/sgdisk -Z "$TARGET_DEV"
# Execute the command line.
$CMD
# Install grub on it
/usr/sbin/grub-install "$TARGET_DEV"
# Install EFI if required
if [ $EFI -eq 1 ]; then
partprobe "${TARGET_DEV}"
while [ ! -e "${TARGET_DEV}2" ]; do
sleep 1
echo "."
done
pve-efiboot-tool format ${TARGET_DEV}2 --force
pve-efiboot-tool init ${TARGET_DEV}2
fi