#!/bin/bash DIR="/home/ravioli/newdisk-automator" PROGRAM_NAME="$0" . "${DIR}/error.sh" . "${DIR}/parse-arguments.sh" . "${DIR}/utils.sh" . "${DIR}/check-device.sh" parse_arguments $@ # removing lvm and other filesystem signatures if [ $LVM == 1 ]; then echo "Erasing disk signatures..." vgchange -an $(vgs --noheadings --select pv_name=~"${DEVICE}" -o vg_name) fi wipefs -a ${DEVICE}[[:digit:]]* wipefs -a ${DEVICE} echo "Partitioning the disk..." # partitioning the disk sfdisk "${DEVICE}" <<-sfdisk-script-end # 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..." pvcreate "${DEVICE}1" echo "Creating volume group localDisk..." vgcreate localDisk "${DEVICE}1" if [ "${SWAP_SIZE}" != 0 ] ; then echo "Creating logical volume swap..." lvcreate -W n -C y -L "${SWAP_SIZE}B" localDisk -n swap echo "Formatting swap lv..." mkswap /dev/localDisk/swap fi if [ "${CONDOR_SIZE}" != 0 ] ; then echo "Creating logical volume swap..." lvcreate -W n -L "${CONDOR_SIZE}B" localDisk -n condor echo "Formatting condor lv..." mkfs.ext4 /dev/localDisk/condor fi if [ "${TEMP_SIZE}" != 0 ] ; then echo "Creating logical volume tempdir..." lvcreate -W n -L "${TEMP_SIZE}B" localDisk -n tempdir echo "Formatting tempdir lv..." mkfs.ext4 /dev/localDisk/tempdir fi if [ "${VM_SIZE}" != 0 ] ; then echo "Creating logical volume calcolo..." lvcreate -W n -L "${VM_SIZE}B" localDisk -n calcolo fi