zemon@felix.UUCP (Art Zemon) (05/21/87)
Yet more code from the AI program which pretends to be me: Before I made my hard disk into my root file system (/dev/ram is now zero bytes long, but that's a different story), I got tired of using two floppies to bootstrap Minix. It seemed silly to me to insert the Boot diskette, read 127K off of it, and then insert the Root File System diskette and read 200K off of that one. (No, that isn't a typo. I made my root file system smaller.) Since the sum of the two is less than 360K (and certainly less than 1200K for ATs), I munged fs/main.c to allow piggy-backing the root file system on the unused end of the Boot diskette. This code ought to work with either normal Root File System diskettes or with my "new" style Boot/Root diskettes since it first checks for a file system at the beginning of the disk and only if that fails does it look for a file system at RAM_OFFSET (RAM disk offset). But I must admit I haven't tried the normal case.... Anyway, here are the changes. Sorry patchers, no diff listing here. You have to make the changes manually. Lines I have added or changed are prefixed with a ">>>". I left some extra stuff in for context and elipses indicate where I chopped unchanged code out of this article. One last note, some of the formatting got messed up when I shifted the code four spaces to the right. Shift it back to the left and things will again line up in columns. All of the following is in fs/main.c: #define M64K 0xFFFF0000L /* 16 bit mask for DMA check */ #define INFO 2 /* where in data_org is info from build */ #define MAX_RAM 512 /* maxium RAM disk size in blocks */ >>> #define RAM_OFFSET 129 /* offset of RAM disk on boot diskette */ ... PRIVATE load_ram() { /* The root diskette contains a block-by-block image of the root file system * starting at 0. Go get it and copy it to the RAM disk. */ register struct buf *bp, *bp1; int count; long k_loaded; struct super_block *sp; block_nr i; >>> block_nr ram_offset = 0; /* offset of root fs on boot diskette */ phys_clicks ram_clicks, init_org, init_text_clicks, init_data_clicks; extern phys_clicks data_org[INFO + 2]; extern struct buf *get_block(); ... /* Get size of RAM disk by reading root file system's super block */ >>> again: >>> bp = get_block(BOOT_DEV, SUPER_BLOCK + ram_offset, NORMAL); /* get RAM super block */ copy(super_block, bp->b_data, sizeof(struct super_block)); sp = &super_block[0]; >>> if (sp->s_magic != SUPER_MAGIC) { >>> if (ram_offset == 0) { >>> printf("Root file system not found at beginning of diskette\n"); >>> ram_offset = RAM_OFFSET; >>> printf("Trying again at offset %d\n", ram_offset); >>> goto again; >>> } panic("Diskette in drive 0 is not root file system", NO_NUM); >>> } ... /* Copy the blocks one at a time from the root diskette to the RAM */ printf("Loading RAM disk from root diskette. Loaded: 0K "); for (i = 0; i < count; i++) { >>> bp = get_block(BOOT_DEV, (block_nr) i + ram_offset, NORMAL); bp1 = get_block(ROOT_DEV, i, NO_READ); ... } The last new procedure is one to put a file system on the end of the Boot diskette instead of at the beginning. The following does just fine: # sync # dd if=/dev/ram of=/dev/fd0 bs=1024 seek=129 That's all there is to it. If your RAM disk is small enough to fit on the unused portion of your Boot diskette then you can get by with one fewer floppies. -- -- Art Zemon FileNet Corporation Costa Mesa, California ...!hplabs!freac, and o