VirtualBox

source: vbox/trunk/src/VBox/VMM/testcase/mkdsk.sh@ 50653

Last change on this file since 50653 was 44528, checked in by vboxsync, 11 years ago

header (C) fixes

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1#!/bin/sh
2#
3# Copyright (C) 2006-2010 Oracle Corporation
4#
5# This file is part of VirtualBox Open Source Edition (OSE), as
6# available from http://www.virtualbox.org. This file is free software;
7# you can redistribute it and/or modify it under the terms of the GNU
8# General Public License (GPL) as published by the Free Software
9# Foundation, in version 2 as it comes in the "COPYING" file of the
10# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
11# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
12#
13
14if [ "x$3" == "x" ]; then
15
16 echo "syntax error"
17 echo "syntax: $0 imagename <size-in-KBs> <init prog> [tar files]"
18 echo ""
19 echo "Simples qemu boot image is archived by only specifying an statically"
20 echo "linked init program and using the dev.tar.gz file to create devices."
21 echo "The boot linux in qemu specifying the image as -hda. Use the -kernel"
22 echo "option to specify a bzImage kernel image to use, and specify"
23 echo "-append root=/dev/hda so the kernel will mount /dev/hda and look"
24 echo "for /sbin/init there."
25 echo ""
26 echo "Example:"
27 echo " sh ./mkdsk.sh foo.img 2048 ~/VBox/Tree/out/linux/debug/bin/tstProg1 dev.tar.gz"
28 echo " qemu -hda foo.img -m 32 -kernel ~/qemutest/linux-test/bzImage-2.4.21 -append root=/dev/hda"
29 exit 1
30fi
31
32image=$1
33size=$2
34init=$3
35
36sizebytes=`expr $size '*' 1024`
37cyls=`expr 8225280 / $sizebytes`
38echo $cyls
39
40echo "* Creating $image of $size kb...."
41rm -f $image
42dd if=/dev/zero of=$image count=$size bs=1024 || exit 1
43
44echo "* Formatting with ext2..."
45/sbin/mkfs.ext2 $image || exit 1
46
47echo "* Mounting temporarily at ./tmpmnt..."
48mkdir -p tmpmnt
49sudo mount $image ./tmpmnt -t ext2 -o loop=/dev/loop7 || exit 1
50
51# init
52echo "* Copying $init to sbin/init..."
53mkdir tmpmnt/sbin
54sudo cp $init tmpmnt/sbin/init
55sudo chmod 755 tmpmnt/sbin/init
56
57shift
58shift
59shift
60while [ "x$1" != "x" ];
61do
62 echo "* Untarring $1 to disk..."
63 sudo tar -xzv -C tmpmnt -f $1
64 shift
65done
66
67echo "* Unmounting tmpmnt..."
68sudo umount tmpmnt
69rmdir tmpmnt
70echo "* Done! (Perhaps even successfully so...)"
71echo " 'root=/dev/hda' remember :-)"
72exit 0
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use