Add a script to give the zpool creation command
This commit is contained in:
parent
0ed7d39b05
commit
9a57c64941
|
@ -0,0 +1,57 @@
|
|||
#!/bin/sh
|
||||
|
||||
POOL_NAME="r2-d2"
|
||||
GROUP_NUMBER="4"
|
||||
DISK_BY_GROUP="11"
|
||||
|
||||
ZPOOL_CREATION_CMD="sudo zpool create -f ${POOL_NAME} -m /mnt/${POOL_NAME} "
|
||||
ZPOOL_SPARE_CMD="sudo zpool add ${POOL_NAME} spare"
|
||||
|
||||
DISK_TEMP_LIST="/tmp/zfs.disks"
|
||||
|
||||
# Store disks list in a temp file
|
||||
find /dev/disk/by-vdev -maxdepth 1 -type l -printf "%f\\n" > "${DISK_TEMP_LIST}"
|
||||
|
||||
# Pool creation {{{
|
||||
## Initialize loop vars
|
||||
group=1
|
||||
start_disk_group=1
|
||||
end_disk_group=11
|
||||
|
||||
while [ "${group}" -le "${GROUP_NUMBER}" ]
|
||||
do
|
||||
## Get the next $DISK_BY_GROUP number of disks for this group
|
||||
GROUP_DISK="$(sed -n ${start_disk_group},${end_disk_group}p -- ${DISK_TEMP_LIST} | tr '\n' ' ')"
|
||||
|
||||
## Display information
|
||||
#printf "%b" "Group ${group} (disk ${start_disk_group} to ${end_disk_group}): ${GROUP_DISK}\\n"
|
||||
|
||||
## Update the creation command
|
||||
ZPOOL_CREATION_CMD="${ZPOOL_CREATION_CMD}\\
|
||||
raidz3 ${GROUP_DISK}"
|
||||
|
||||
## Increment variables
|
||||
group=$((group+1))
|
||||
start_disk_group=$((end_disk_group+1))
|
||||
end_disk_group=$((end_disk_group+DISK_BY_GROUP))
|
||||
done
|
||||
|
||||
printf "%b\\n" "++++++ You can use this command to create your ZSH pool +++++++++"
|
||||
printf "%b\\n" "${ZPOOL_CREATION_CMD}"
|
||||
printf "%b\\n" "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||
# }}}
|
||||
# Pool spare {{{
|
||||
## Get the last disks for the spare command
|
||||
SPARE_DISK="$(tail -n +${start_disk_group} -- ${DISK_TEMP_LIST} | tr '\n' ' ')"
|
||||
|
||||
ZPOOL_SPARE_CMD="${ZPOOL_SPARE_CMD} ${SPARE_DISK}"
|
||||
|
||||
printf "%b\\n" "++++ You can use this command to add spare disks to the pool ++++"
|
||||
printf "%b\\n" "${ZPOOL_SPARE_CMD}"
|
||||
printf "%b\\n" "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
|
||||
# }}}
|
||||
|
||||
# Delete the temp list file
|
||||
rm -f -- "${DISK_TEMP_LIST}"
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue