1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Bug #1002: move mkfs-dependant option "-F" from tm_mkimage.sh to fs/mkfs-script

This commit is contained in:
Jaime Melis 2011-12-22 15:18:24 +01:00
parent cda3e9dc3e
commit 40a654411e
5 changed files with 42 additions and 26 deletions

View File

@ -21,7 +21,7 @@
# as (FS)
###############################################################################
# ------------ Set up the environment to source common tools ------------
# ------------ Set up the environment to source common tools ------------
if [ -z "${ONE_LOCATION}" ]; then
LIB_LOCATION=/usr/lib/one
@ -32,37 +32,20 @@ fi
. $LIB_LOCATION/sh/scripts_common.sh
source $(dirname $0)/fsrc
# ------------ Create the image to the repository ------------
# ------------ Create the image to the repository ------------
FSTYPE=$1
SIZE=$2
ID=$3
# Specific options for different FS
case "$FSTYPE" in
"ext2"|"ext3"|"ext4"|"ntfs")
OPTS="-F"
;;
"reiserfs")
OPTS="-f -q"
;;
"jfs")
OPTS="-q"
;;
*)
OPTS=""
;;
esac
DST=`generate_image_path`
MKFS_CMD=`mkfs_command $DST $FSTYPE`
exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \
"Could not create image $DST"
exec_and_log "$MKFS -t $FSTYPE $OPTS $DST" \
exec_and_log "$MKFS_CMD" \
"Unable to create filesystem $FSTYPE in $DST"
exec_and_log "chmod 0660 $DST"
# ---------------- Get the size of the image ------------

View File

@ -148,3 +148,30 @@ function timeout_exec_and_log
exit $CMD_CODE
fi
}
# This function will return a command that upon execution will format a
# filesystem with its proper parameters based on the filesystem type
function mkfs_command {
DST=$1
FSTYPE=${2:-ext3}
# Specific options for different FS
case "$FSTYPE" in
"ext2"|"ext3"|"ext4"|"ntfs")
OPTS="-F"
;;
"reiserfs")
OPTS="-f -q"
;;
"jfs")
OPTS="-q"
;;
*)
OPTS=""
;;
esac
echo "$MKFS -t $FSTYPE $OPTS $DST"
}

View File

@ -32,7 +32,9 @@ DST_PATH=`arg_path $DST`
DST_HOST=`arg_host $DST`
DST_DIR=`dirname $DST_PATH`
MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE`
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR"
exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M"
exec_and_log "$SSH $DST_HOST $MKFS -t $FSTYPE -F $DST_PATH"
exec_and_log "$SSH $DST_HOST $MKFS_CMD"
exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH"

View File

@ -36,11 +36,13 @@ fix_dst_path
DST_DIR=`dirname $DST_PATH`
MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE`
exec_and_log "mkdir -p $DST_DIR" \
"Error creating directory $DST_DIR"
exec_and_log "$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \
"Could not create image $DST_PATH"
exec_and_log "$MKFS -t $FSTYPE -F $DST_PATH" \
exec_and_log "$MKFS_CMD" \
"Unable to create filesystem $FSTYPE in $DST_PATH"
exec_and_log "chmod a+rw $DST_PATH"

View File

@ -32,10 +32,12 @@ DST_PATH=`arg_path $DST`
DST_HOST=`arg_host $DST`
DST_DIR=`dirname $DST_PATH`
MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE`
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" \
"Error creating directory $DST_DIR"
exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \
"Could not create image $DST_PATH"
exec_and_log "$SSH $DST_HOST $MKFS -t $FSTYPE -F $DST_PATH" \
exec_and_log "$SSH $DST_HOST $MKFS_CMD" \
"Unable to create filesystem $FSTYPE in $DST_PATH"
exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH"
exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH"