3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
7
# not use this file except in compliance with the License. You may obtain #
8
# a copy of the License at #
10
# http://www.apache.org/licenses/LICENSE-2.0 #
12
# Unless required by applicable law or agreed to in writing, software #
13
# distributed under the License is distributed on an "AS IS" BASIS, #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15
# See the License for the specific language governing permissions and #
16
# limitations under the License. #
17
#--------------------------------------------------------------------------- #
19
###############################################################################
20
# This script is used to create a VM image (SRC) of size (SIZE) and formatted
22
###############################################################################
24
# ------------ Set up the environment to source common tools ------------
26
if [ -z "${ONE_LOCATION}" ]; then
27
LIB_LOCATION=/usr/lib/one
29
LIB_LOCATION=$ONE_LOCATION/lib
32
. $LIB_LOCATION/sh/scripts_common.sh
33
source $(dirname $0)/fsrc
35
# ------------ Create the image to the repository ------------
41
DST=`generate_image_path`
43
MKFS_CMD=`mkfs_command $DST $FSTYPE`
45
exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \
46
"Could not create image $DST"
47
exec_and_log "$MKFS_CMD" \
48
"Unable to create filesystem $FSTYPE in $DST"
49
exec_and_log "chmod 0660 $DST"
51
# ---------------- Get the size of the image ------------