VirtualBox

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

Last change on this file since 101665 was 98103, checked in by vboxsync, 22 months ago

Copyright year updates by scm.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette