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