Statistics
| Branch: | Tag: | Revision:

one / src / image_mad / remotes / fs / mkfs @ f2c04245

History | View | Annotate | Download (2 KB)

1
#!/bin/bash
2

    
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2011, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
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                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
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
#--------------------------------------------------------------------------- #
18

    
19
###############################################################################
20
# This script is used to create a VM image (SRC) of size (SIZE) and formatted
21
# as (FS)
22
###############################################################################
23

    
24
# ------------ Set up the environment to source common tools ------------ 
25

    
26
if [ -z "${ONE_LOCATION}" ]; then
27
    LIB_LOCATION=/usr/lib/one
28
else
29
    LIB_LOCATION=$ONE_LOCATION/lib
30
fi
31

    
32
. $LIB_LOCATION/sh/scripts_common.sh
33
source $(dirname $0)/fsrc
34

    
35
# ------------ Create the image to the repository ------------ 
36

    
37
FSTYPE=$1
38
SIZE=$2
39
ID=$3
40

    
41
DST=`generate_image_path`
42

    
43
exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \
44
    "Could not create image $DST"
45
exec_and_log "$MKFS -t $FSTYPE -F $DST" \
46
    "Unable to create filesystem $FSTYPE in $DST"
47
exec_and_log "chmod 0660 $DST"
48

    
49
echo "$DST"