1
|
#!/bin/bash
|
2
|
|
3
|
# -------------------------------------------------------------------------- #
|
4
|
# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
|
5
|
# Complutense de Madrid (dsa-research.org) #
|
6
|
# #
|
7
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
8
|
# not use this file except in compliance with the License. You may obtain #
|
9
|
# a copy of the License at #
|
10
|
# #
|
11
|
# http://www.apache.org/licenses/LICENSE-2.0 #
|
12
|
# #
|
13
|
# Unless required by applicable law or agreed to in writing, software #
|
14
|
# distributed under the License is distributed on an "AS IS" BASIS, #
|
15
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
16
|
# See the License for the specific language governing permissions and #
|
17
|
# limitations under the License. #
|
18
|
#--------------------------------------------------------------------------- #
|
19
|
|
20
|
SIZE=$1
|
21
|
DST=$2
|
22
|
|
23
|
if [ -z "${ONE_LOCATION}" ]; then
|
24
|
TMCOMMON=/usr/lib/one/mads/tm_common.sh
|
25
|
else
|
26
|
TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
|
27
|
fi
|
28
|
|
29
|
. $TMCOMMON
|
30
|
|
31
|
DST_PATH=`arg_path $DST`
|
32
|
|
33
|
DST_DIR=`dirname $DST_PATH`
|
34
|
|
35
|
log "Creating directory $DST_DIR"
|
36
|
exec_and_log "mkdir -p $DST_DIR"
|
37
|
exec_and_log "chmod a+w $DST_DIR"
|
38
|
|
39
|
|
40
|
log "Creating ${SIZE}Mb image in $DST_PATH"
|
41
|
exec_and_log "dd if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M"
|
42
|
|
43
|
log "Initializing swap space"
|
44
|
exec_and_log "/sbin/mkswap $DST_PATH"
|
45
|
|
46
|
exec_and_log "chmod a+w $DST_PATH"
|
47
|
|