#!/bin/bash DIR="/home/ravioli/newdisk-automator" PROGRAM_NAME="$0" . "${DIR}/error.sh" . "${DIR}/parse-arguments.sh" . "${DIR}/utils.sh" . "${DIR}/check-device.sh" LVM_SUPPRESS_FD_WARNINGS=1 parse_arguments $@ # removing lvm and other filesystem signatures if [ $LVM == 1 ]; then echo "Erasing disk signatures..." >${SCRIPT_OUTPUT} vgchange -an $(vgs --noheadings --select pv_name=~"${DEVICE}" -o vg_name) >${PROGRAM_OUTPUT} 2>&1 fi wipefs -a ${DEVICE}[[:digit:]]* >${PROGRAM_OUTPUT} 2>&1 wipefs -a ${DEVICE} >${PROGRAM_OUTPUT} 2>&1 echo "Partitioning the disk..." >${SCRIPT_OUTPUT} # partitioning the disk sfdisk "${DEVICE}" <<-sfdisk-script-end >${PROGRAM_OUTPUT} 2>&1 # Create a new partition table on the specified disk, and create a new Linux LVM partition # # partition table info label: gpt # # partitions info #start size type bootable , ,31 , sfdisk-script-end # LVM echo "Creating physical volume ${DEVICE}1..." >${SCRIPT_OUTPUT} pvcreate "${DEVICE}1" >${PROGRAM_OUTPUT} 2>&1 echo "Creating volume group localDisk..." >${SCRIPT_OUTPUT} vgcreate localDisk "${DEVICE}1" >${PROGRAM_OUTPUT} 2>&1 if [ "${SWAP_SIZE}" != 0 ] ; then echo "Creating logical volume swap..." >${SCRIPT_OUTPUT} lvcreate -W n -C y -L "${SWAP_SIZE}B" localDisk -n swap >${PROGRAM_OUTPUT} 2>&1 echo "Formatting swap lv..." >${SCRIPT_OUTPUT} mkswap /dev/localDisk/swap >${PROGRAM_OUTPUT} 2>&1 fi if [ "${CONDOR_SIZE}" != 0 ] ; then echo "Creating logical volume swap..." >${SCRIPT_OUTPUT} lvcreate -W n -L "${CONDOR_SIZE}B" localDisk -n condor >${PROGRAM_OUTPUT} 2>&1 echo "Formatting condor lv..." >${SCRIPT_OUTPUT} mkfs.ext4 /dev/localDisk/condor >${PROGRAM_OUTPUT} 2>&1 fi if [ "${TEMP_SIZE}" != 0 ] ; then echo "Creating logical volume tempdir..." >${SCRIPT_OUTPUT} lvcreate -W n -L "${TEMP_SIZE}B" localDisk -n tempdir >${PROGRAM_OUTPUT} 2>&1 echo "Formatting tempdir lv..." >${SCRIPT_OUTPUT} mkfs.ext4 /dev/localDisk/tempdir >${PROGRAM_OUTPUT} 2>&1 fi if [ "${VM_SIZE}" != 0 ] ; then echo "Creating logical volume calcolo..." >${SCRIPT_OUTPUT} lvcreate -W n -L "${VM_SIZE}B" localDisk -n calcolo >${PROGRAM_OUTPUT} 2>&1 fi