123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #!/bin/bash
- DIR="/home/ravioli/newdisk-automator"
- . "${DIR}/error.sh"
- . "${DIR}/parse-arguments.sh"
- . "${DIR}/utils.sh"
- . "${DIR}/check-device.sh"
- PROGRAM_NAME="$0"
- parse_arguments $@
- # removing lvm and other filesystem signatures)
- if [ $LVM == 1]
- echo "Erasing disk signatures..."
- vgchange -an $(vgs --noheadings --select pv_name=~"${DEVICE}" -o vg_name)
- fi
- wipefs -a ${DEVICE}[[:digit:]]*
- wipefs -a ${DEVICE}
- echo "SFDISK ----------------------------------------------------"
- # 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 "PVCREATE --------------------------------------------------"
- pvcreate "${DEVICE}1"
- echo "VGCREATE --------------------------------------------------"
- vgcreate localDisk "${DEVICE}1"
- if [ "${SWAP_SIZE}" != 0 ] ; then
- echo "LVCREATE SWAP --------------------------------------------------"
- lvcreate -W n -C y -L "${SWAP_SIZE}B" localDisk -n swap
- echo "MKSWAP --------------------------------------------------"
- mkswap /dev/localDisk/swap
- fi
- if [ "${CONDOR_SIZE}" != 0 ] ; then
- echo "LVCREATE CONDOR --------------------------------------------------"
- lvcreate -W n -L "${CONDOR_SIZE}B" localDisk -n condor
- echo "MKFS CONDOR --------------------------------------------------"
- mkfs.ext4 /dev/localDisk/condor
- fi
- if [ "${TEMP_SIZE}" != 0 ] ; then
- echo "LVCREATE TEMP --------------------------------------------------"
- lvcreate -W n -L "${TEMP_SIZE}B" localDisk -n tempdir
- echo "MKFS TEMP --------------------------------------------------"
- mkfs.ext4 /dev/localDisk/tempdir
- fi
- if [ "${VM_SIZE}" != 0 ] ; then
- echo "LVCREATE CALCOLO --------------------------------------------------"
- lvcreate -W n -L "${VM_SIZE}B" localDisk -n calcolo
- fi
|