Add a script to generate ZFS's vdev file for IBM

This commit is contained in:
Jeremy Gardais 2018-06-21 15:09:25 +02:00
parent d93818eb87
commit 0ed7d39b05
1 changed files with 25 additions and 0 deletions

25
zfs.set.ibm.vdev.id.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
# run me with a sudo
DISK_TYPE="scsi-3220"
NUMBER_DISK="$(find /dev/disk/by-id -name "${DISK_TYPE}*" | wc -l)"
ZFS_VDEV_FILE="/etc/zfs/vdev_id.conf"
rm -f -- "${ZFS_VDEV_FILE}"
mkdir -p -- "$(dirname "${ZFS_VDEV_FILE}")"
printf "%b" "# Tiroir ${NUMBER_DISK} disques IBM $(hostname)\\n" > "${ZFS_VDEV_FILE}"
printf "%b" "# by-vdev\\n" >> "${ZFS_VDEV_FILE}"
printf "%b" "# name fully qualified or base name of device link\\n\\n" >> "${ZFS_VDEV_FILE}"
# On veut un numéro de disque identique à la référence de l'étiquette du caddie
for disk_scsi_id in $(find /dev/disk/by-id -name "${DISK_TYPE}*" | cut -d"-" -f 3)
do
#printf "%b" "disk_scsi_id = ${disk_scsi_id}\\n";
printf "%b" "alias ${disk_scsi_id} /dev/disk/by-id/scsi-${disk_scsi_id}\\n" >> "${ZFS_VDEV_FILE}"
done
printf "%b" "\\nNow, please check the content of ${ZFS_VDEV_FILE}\\n\\n";
exit 0