Browse Source

Added way to specify sizes in sectors

root 5 years ago
parent
commit
2c7acf48ca
3 changed files with 8 additions and 3 deletions
  1. 7 1
      conversion.sh
  2. 0 1
      newdisk-automator
  3. 1 1
      parse-arguments.sh

+ 7 - 1
conversion.sh

@@ -26,6 +26,7 @@ to_bytes()
 	K) kibibytes_to_bytes "${1:0: -1}" ;;
 	M) mebibytes_to_bytes "${1:0: -1}" ;;
 	G) gibibytes_to_bytes "${1:0: -1}" ;;
+    S) sectors_to_bytes "${1:0: -1}" ;;
 	*) fatal UNIT_E "${1:-1} is not a valid unit" ;;
 	esac
 }
@@ -42,5 +43,10 @@ to_sectors()
 
 sectors_to_gibibytes()
 {
-	echo $(bytes_to_gibibytes $(( 512 * "${1}" )) )
+	echo $(bytes_to_gibibytes $(sectors_to_bytes "${1}"))
+}
+
+sectors_to_bytes()
+{
+	echo $(( 512 * "${1}" ))
 }

+ 0 - 1
newdisk-automator

@@ -43,7 +43,6 @@ vgcreate localDisk "${DEVICE}1" >${PROGRAM_OUTPUT} 2>&1 || fatal ${PROG_E} "vgcr
 
 # Create local volumes and partition them.
 # If the specified size is 0, it means that the volume must not be created
-echo ${SWAP_SIZE}
 if [ "${SWAP_SIZE}" != 0 ] ; then
 	echo "Creating logical volume swap..." >${SCRIPT_OUTPUT}
 	lvcreate -W n -C y --size "${SWAP_SIZE}S" localDisk -n swap >${PROGRAM_OUTPUT} 2>&1 || fatal ${PROG_E} "lvcreate returned $? for swap lv"

+ 1 - 1
parse-arguments.sh

@@ -97,7 +97,7 @@ help()
 
 		Manual:
 		newdisk-automator [-qv] device temp_size condor_size swap_size vm_size
-		The partitions are assigned the size passed on the command line. b, K, M, G can be appended to the sizes for bytes, kibibytes, mebibytes and gibibytes. The default is bytes.
+		The partitions are assigned the size passed on the command line. S, b, K, M, G can be appended to the sizes for 512-byte-sectors, bytes, kibibytes, mebibytes and gibibytes. The default is bytes.
 		If the total passed with the command line is greater than the size of the disk, the program stops.
 	help-end
 	if [ "$PROGRAM_OUTPUT" = "/proc/self/fd/1" ]; then