《不用一张软盘在VMware中安装Minix》
随书光盘中提供了一个dos程序FDVOL,用来将 i386\ROOT i386\USR i386\USR.TAZ SYS.TAZ CMD.TAZ 这五个文件写到九张1.44兆的软盘上,然后用这九张软盘(安装盘)来安装Minix。
就像下面这样
fdvol 1440 A: i386\ROOT i386\USR - Combined ROOT+USR floppy fdvol 1440 A: i386\USR.TAZ - Base system on 3 floppies fdvol 1440 A: SYS.TAZ - System sources on 2 floppies fdvol 1440 A: CMD.TAZ - Commands sources on 3 floppies 这在readme中都有说明,不多说了。
其实我们不需要一张软盘就可以安装Minix了(恐怕你也没有这么多软盘),因为在VMware中可以使用软盘镜像来代替真的软盘,
做法如下:
在VMware中创建新的虚拟机,选择Custom
Guest operating system选择Other
内存大小设为16兆
选择Do not use a network connection
磁盘大小设为1G并选择Create a new virtual disk
现在虚拟机创建完了,该制作软盘镜像了。
i386\ROOT和i386\USR这两个文件直接用copy命令连接成一个文件就行了, 随便起个名字(就叫rootandusr吧) copy /b root + usr rootandusr
i386\USR.TAZ和SYS.TAZ以及CMD.TAZ处理起来稍微麻烦点
为此我编了两个小程序(源代码在后边)
knife用来将文件按照指定的大小分割为若干个文件,第一个参数是待分割的文件的名字, 第二个参数是分割的大小,第三个参数是分割产生的文件的基本名字。 padding用来在文件后面补零,一直把它变成一张软盘的大小(1474560字节)
首先执行 knife USR.TAZ 1474560 myusr 产生了三个文件 myusr000 myusr001 myusr002 大小分别为 1474560 1474560 776267 最后一个也就是myusr002是个小尾巴,我们用padding把它也变成1474560大小,如下 padding myusr002 现在好了,三个文件的大小都是1474560了 至于为什么是1474560,因为一张软盘2个面,每个面80个磁道,每个磁道18个扇区,每个扇区512字节, 一乘就知道了。
然后再如法炮制SYS.TAZ和CMD.TAZ 最后就有了如下九个文件:
rootandusr
myusr000 myusr001 myusr002
mysys000 mysys001
mycmd000 mycmd001 mycmd002
这就是九张安装盘的镜像了。
然后我们在VMware中把软盘设置为使用镜像文件就行了
当安装程序提示换盘的时候只要在Devices菜单中选择相应的镜像文件就行了。
应该很顺利吧???
下面是用到的两个小程序的源代码,用vc6建一个控制台工程即可编译。
// knife的源代码 //----------------------------- #include <windows.h> #include <stdio.h> #include <stdlib.h> #include <string.h>
void main(int argc, char *argv[]) { if (argc == 1) { puts("File Knife 0.01 Copyright 08/15/2001 Du Yan Ning"); puts("Sytax: KNIFE [ <source file name> <target file size> <target file base name> ]"); return; }
if (argc != 4) { puts("Invalid parameter numbers!"); return; }
char source[256], target[256]; strcpy(source, argv[1]);
int size; size = atoi(argv[2]);
FILE *sfp, *tfp;
sfp = fopen(source, "rb"); if (sfp == 0) { printf("Can't open source file: %s", source); return; }
int counter = 0; char asciic[6];
bool complete = false; bool fileopen = false;
while (!complete) {
Sleep(20); switch (counter % 4) { case 0: putchar('@'); break; case 1: putchar('#'); break; case 2: putchar('$'); break; case 3: putchar('%'); break; } putchar('\b');
{ strcpy(target, argv[3]); sprintf(asciic, "%03d", counter); strcat(target, asciic); }
counter++;
for (int i = 0; i < size; i++) {
int c;
c = getc(sfp); if (c == EOF) { complete = true; break; }
if (i == 0) { tfp = fopen(target, "wb"); fileopen = true; } putc(c, tfp);
}
if (fileopen == true) { fclose(tfp); fileopen = false; }
} // while (!complete)
fclose(sfp);
puts("\nconvertion complete!"); }
// padding的源代码 //----------------------------- /* CHSIZE.C: This program uses _filelength to report the size * of a file before and after modifying it with _chsize. */
#include <io.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #include <stdio.h>
void main(int argc, char* argv[]) { if (argc != 2) { printf("padding [<filename>]\n"); return; }
int fh, result; /* Open a file */ if( (fh = _open( argv[1], _O_RDWR | _O_CREAT, _S_IREAD | _S_IWRITE )) != -1 ) { long originalLen = _filelength(fh); printf( "File length before: %ld\n", originalLen);
long eventualLen = 512; //while (eventualLen < originalLen) //{ // eventualLen += 512; //} eventualLen = 1474560;
if((result = _chsize(fh, eventualLen)) == 0) printf( "Size successfully changed\n" ); else printf( "Problem in changing the size\n" ); printf( "File length after: %ld\n", _filelength( fh ) ); _close( fh ); } }

|