[comp.os.minix] ramdisk

x110ws%TAMUNIX.BITNET@CORNELLC.CIT.CORNELL.EDU (Wally Strzelec) (11/23/88)

hello...

could someone please tell me how I can reduce the size of my ram disk. I'm
running the 640k minix on a 512k pc.

also a few days ago there was some talk about how someone moved their ram
disk to their hard disk by making some changes in main.c. could that
someone please write in and tell me how it was done.
        See you
        Wally Strzelec
        <x110ws@tamunix.tamu.edu>

beattie@visenix.UUCP (Brian Beattie) (11/26/88)

In article <5639@louie.udel.EDU> x110ws%TAMUNIX.BITNET@CORNELLC.CIT.CORNELL.EDU (Wally Strzelec) writes:
>hello...
>
>could someone please tell me how I can reduce the size of my ram disk. I'm
>running the 640k minix on a 512k pc.
The ramdisk an exact copy of the root filesystem floppy.  Change the size
of the root filesystem and you change the size of the ram disk.  This
can be done by modifing tools/proto.ram and then doing a:
mkfs /dev/fd0 proto.ram
>
>also a few days ago there was some talk about how someone moved their ram
>disk to their hard disk by making some changes in main.c. could that
>someone please write in and tell me how it was done.
what follows is a cdiff of my fs/main.c.  This is all that I know of
that needs to be changed.  You will still need to use a floppy to boot
from.

The change is to check the major device of the root filesystem which
is specified in h/const.h as ROOT_DEV, I use ((3<MAJOR)|2) which is
/dev/hd2.  If the major device number is 3 it skips the file system
copy and sets up a zero length ram disk.

---
    _ANYONE_     | Brian Beattie          (703)471-7552
can sell software| 11525 Hickory Cluster, Reston, VA. 22090 
that has already | beattie@visenix.UU.NET
been written     | ...uunet!visenix!beattie

--------------------------- cdiff follows ------------------------------
*** main.c	Sat Nov 12 02:10:17 1988
--- main.c.old	Fri Nov 25 21:28:14 1988
***************
*** 259,287 ****
  #ifdef ATARI_ST
    printf("Booting MINIX-ST 1.1.  Copyright 1988 Prentice-Hall, Inc.\n");
  #endif ATARI_ST
-   if ( (ROOT_DEV>>MAJOR) != 3 )	/* check for hard disk root */
-   {
  #ifdef ASKDEV
! 	root_device = (dev_nr)askdev();
! 	if (root_device == 0)
  #endif ASKDEV
! 	root_device = BOOT_DEV;	/* try floppy disk first */
  	bp = get_block(root_device, SUPER_BLOCK, 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) {
! 		put_block(bp, FULL_DATA_BLOCK);
! 		root_device = RAM_IMAGE;
! 		bp = get_block(root_device, SUPER_BLOCK, 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)
! 			panic("Invalid root file system", NO_NUM);
! 	}
! 	count = sp->s_nzones << sp->s_log_zone_size;	/* # blocks on root dev */
! 	if (count > MAX_RAM) panic("RAM disk is too big. # blocks = ", count);
! 	ram_clicks = count * (BLOCK_SIZE/CLICK_SIZE);
! 	put_block(bp, FULL_DATA_BLOCK);
  
  #ifdef i8088
  	/* There are two possibilities now (by convention):  
--- 259,285 ----
  #ifdef ATARI_ST
    printf("Booting MINIX-ST 1.1.  Copyright 1988 Prentice-Hall, Inc.\n");
  #endif ATARI_ST
  #ifdef ASKDEV
!   root_device = (dev_nr)askdev();
!   if (root_device == 0)
  #endif ASKDEV
!   root_device = BOOT_DEV;	/* try floppy disk first */
!   bp = get_block(root_device, SUPER_BLOCK, 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) {
! 	put_block(bp, FULL_DATA_BLOCK);
! 	root_device = RAM_IMAGE;
  	bp = get_block(root_device, SUPER_BLOCK, 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)
! 		panic("Invalid root file system", NO_NUM);
!   }
!   count = sp->s_nzones << sp->s_log_zone_size;	/* # blocks on root dev */
!   if (count > MAX_RAM) panic("RAM disk is too big. # blocks = ", count);
!   ram_clicks = count * (BLOCK_SIZE/CLICK_SIZE);
!   put_block(bp, FULL_DATA_BLOCK);
  
  #ifdef i8088
  	/* There are two possibilities now (by convention):  
***************
*** 290,303 ****
  	 * In the latter case, tell MM that RAM disk size is 0 and tell the
  	 * ram disk driver than the device begins at 1MB.
  	 */
! 	if (count > MAX_CRD) {
! 		ram_clicks = 0;	/* MM does not have to allocate any core */
! 		base = EM_ORIGIN; /* tell RAM disk driver RAM disk origin */
! 	}
! #endif
!   } else {
! 	ram_clicks = 0;
    }
  
    /* Tell MM the origin and size of INIT, and the amount of memory used for the
     * system plus RAM disk combined, so it can remove all of it from the map.
--- 288,298 ----
  	 * In the latter case, tell MM that RAM disk size is 0 and tell the
  	 * ram disk driver than the device begins at 1MB.
  	 */
!   if (count > MAX_CRD) {
! 	ram_clicks = 0;	/* MM does not have to allocate any core */
! 	base = EM_ORIGIN; /* tell RAM disk driver RAM disk origin */
    }
+ #endif
  
    /* Tell MM the origin and size of INIT, and the amount of memory used for the
     * system plus RAM disk combined, so it can remove all of it from the map.
***************
*** 312,329 ****
    m1.m1_p1 = (char *) init_org;
  #endif
    if (sendrec(MM_PROC_NR, &m1) != OK) panic("FS Can't report to MM", NO_NUM);
- 
-   if ((ROOT_DEV>>MAJOR) == 3)
-   {
- 		/* hard disk root, null ramdisk */
- 	m1.m_type = DISK_IOCTL;
- 	m1.DEVICE = RAM_DEV;
- 	m1.POSITION = 0;
- 	m1.COUNT = 0;
- 	if (sendrec(MEM, &m1) != OK) panic("Can't report size to MEM", NO_NUM);
- 	return;
-   }
- 
    /* Tell RAM driver where RAM disk is and how big it is. */
    m1.m_type = DISK_IOCTL;
    m1.DEVICE = RAM_DEV;
--- 307,312 ----

-- 
    _ANYONE_     | Brian Beattie          (703)471-7552
can sell software| 11525 Hickory Cluster, Reston, VA. 22090 
that has already | beattie@visenix.UU.NET
been written     | ...uunet!visenix!beattie