feat: Log creation info (#250)
This commit is contained in:
parent
40a944ec39
commit
5620ba80c0
1 changed files with 7 additions and 4 deletions
11
src/disk.sh
11
src/disk.sh
|
@ -77,7 +77,7 @@ createDisk() {
|
||||||
local DISK_SPACE=$2
|
local DISK_SPACE=$2
|
||||||
local DISK_DESC=$3
|
local DISK_DESC=$3
|
||||||
local DISK_FMT=$4
|
local DISK_FMT=$4
|
||||||
local DIR SPACE DATA_SIZE
|
local DATA_SIZE DIR SPACE
|
||||||
|
|
||||||
DATA_SIZE=$(numfmt --from=iec "$DISK_SPACE")
|
DATA_SIZE=$(numfmt --from=iec "$DISK_SPACE")
|
||||||
|
|
||||||
|
@ -94,7 +94,8 @@ createDisk() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local FAIL="Could not create a $DISK_SPACE $DISK_FMT file for $DISK_DESC ($DISK_FILE)"
|
info "Creating a $DISK_TYPE $DISK_DESC image in $DISK_FMT format with a size of $DISK_SPACE..."
|
||||||
|
local FAIL="Could not create a $DISK_TYPE $DISK_FMT $DISK_DESC image of $DISK_SPACE ($DISK_FILE)"
|
||||||
|
|
||||||
case "${DISK_FMT,,}" in
|
case "${DISK_FMT,,}" in
|
||||||
raw)
|
raw)
|
||||||
|
@ -158,7 +159,7 @@ resizeDisk() {
|
||||||
|
|
||||||
local GB=$(( (CUR_SIZE + 1073741823)/1073741824 ))
|
local GB=$(( (CUR_SIZE + 1073741823)/1073741824 ))
|
||||||
info "Resizing $DISK_DESC from ${GB}G to $DISK_SPACE..."
|
info "Resizing $DISK_DESC from ${GB}G to $DISK_SPACE..."
|
||||||
local FAIL="Could not resize $DISK_FMT file of $DISK_DESC ($DISK_FILE) from ${GB}G to $DISK_SPACE .."
|
local FAIL="Could not resize the $DISK_TYPE $DISK_FMT $DISK_DESC image from ${GB}G to $DISK_SPACE ($DISK_FILE)"
|
||||||
|
|
||||||
case "${DISK_FMT,,}" in
|
case "${DISK_FMT,,}" in
|
||||||
raw)
|
raw)
|
||||||
|
@ -233,7 +234,7 @@ convertDisk() {
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
if ! qemu-img convert -f "$SOURCE_FMT" $CONV_FLAGS -o "$DISK_OPTS" -O "$DST_FMT" -- "$SOURCE_FILE" "$TMP_FILE"; then
|
if ! qemu-img convert -f "$SOURCE_FMT" $CONV_FLAGS -o "$DISK_OPTS" -O "$DST_FMT" -- "$SOURCE_FILE" "$TMP_FILE"; then
|
||||||
rm -f "$TMP_FILE"
|
rm -f "$TMP_FILE"
|
||||||
error "Failed to convert $DISK_DESC to $DST_FMT format in $DIR, is there enough space available?" && exit 79
|
error "Failed to convert $DISK_TYPE $DISK_DESC image to $DST_FMT format in $DIR, is there enough space available?" && exit 79
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$DST_FMT" == "raw" ]]; then
|
if [[ "$DST_FMT" == "raw" ]]; then
|
||||||
|
@ -340,8 +341,10 @@ fi
|
||||||
DISK_EXT="$(fmt2ext "$DISK_FMT")" || exit $?
|
DISK_EXT="$(fmt2ext "$DISK_FMT")" || exit $?
|
||||||
|
|
||||||
if [[ "$ALLOCATE" == [Nn]* ]]; then
|
if [[ "$ALLOCATE" == [Nn]* ]]; then
|
||||||
|
DISK_TYPE="growable"
|
||||||
DISK_ALLOC="preallocation=off"
|
DISK_ALLOC="preallocation=off"
|
||||||
else
|
else
|
||||||
|
DISK_TYPE="preallocated"
|
||||||
DISK_ALLOC="preallocation=falloc"
|
DISK_ALLOC="preallocation=falloc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue