[comp.os.minix] root filesystem on harddisk

veench@cs.vu.nl (12/01/88)

The difs in the following shar file make it much more easy to 
put the root file-system on a harddisk.
It is done by moveing the macro's ROOT_DEV and BOOT_DEV
from h/const.h to fs/const.h (MM and KERNEL don't need them.)

To put the root filesystem on the ramdisk just define
RAM_DISK on line 2 of fs/const.h, 
to put the root filesystem on harddisk, outcomment it.

				Dick van Veen
-------------------------------------------------------------------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	h
#	fs
# This archive created: Mon Nov 28 18:40:13 1988
export PATH; PATH=/bin:/usr/bin:$PATH
if test ! -d 'h'
then
	mkdir 'h'
fi
cd 'h'
if test -f 'const.h.cdif'
then
	echo shar: "will not over-write existing file 'const.h.cdif'"
else
cat << \SHAR_EOF > 'const.h.cdif'
*** /usr/src/minix/h/const.h	Thu Nov 10 21:07:45 1988
--- h/const.h	Mon Nov 28 16:28:18 1988
***************
*** 76,85 ****
  #define SIG_PUSH_BYTES	      8	/* how many bytes pushed by signal */
  #define MAX_ISTACK_BYTES   2048	/* maximum initial stack size for EXEC */
  
- /* Device numbers of root (RAM) and boot (fd0) devices. */
- #define ROOT_DEV (dev_nr)   256	/* major-minor device number of root dev */
- #define BOOT_DEV (dev_nr)   512	/* major-minor device number of boot diskette */
- 
  /* Flag bits for i_mode in the inode. */
  #define I_TYPE          0170000	/* this field gives inode type */
  #define I_REGULAR       0100000	/* regular file, not dir or special */
--- 76,81 ----
SHAR_EOF
fi
cd ..
if test ! -d 'fs'
then
	mkdir 'fs'
fi
cd 'fs'
if test -f 'const.h.cdif'
then
	echo shar: "will not over-write existing file 'const.h.cdif'"
else
cat << \SHAR_EOF > 'const.h.cdif'
*** /usr/src/minix/fs/const.h	Thu Nov 10 21:06:23 1988
--- fs/const.h	Mon Nov 28 17:51:42 1988
***************
*** 1,3 ****
--- 1,13 ----
+ /* Device numbers of root (RAM) and boot (fd0) devices. */
+ /*#define RAM_DISK		/* define this macro for root system in ram */
+ #define RAM_IMAGE (dev_nr)0x303	/* major-minor dev where root image is kept */
+ #ifdef RAM_DISK
+ #define ROOT_DEV (dev_nr) 0x100	/* major-minor device number of root dev */
+ #else
+ #define ROOT_DEV RAM_IMAGE
+ #endif
+ #define BOOT_DEV (dev_nr) 0x200	/* major-minor device number of boot diskette */
+ 
  /* Tables sizes */
  #define NR_ZONE_NUMS       9	/* # zone numbers in an inode */
  #define NR_BUFS           30	/* # blocks in the buffer cache */
SHAR_EOF
fi
if test -f 'main.c.cdif'
then
	echo shar: "will not over-write existing file 'main.c.cdif'"
else
cat << \SHAR_EOF > 'main.c.cdif'
*** /usr/src/minix/fs/main.c	Thu Nov 10 21:06:28 1988
--- fs/main.c	Mon Nov 28 18:03:06 1988
***************
*** 34,40 ****
  #define M64K     0xFFFF0000L	/* 16 bit mask for DMA check */
  #define INFO               2	/* where in data_org is info from build */
  #define MAX_RAM        16384	/* maximum RAM disk size in blocks */
- #define RAM_IMAGE (dev_nr)0x303	/* major-minor dev where root image is kept */
  
  #ifdef i8088
  #define EM_ORIGIN   0x100000	/* origin of extended memory RAM disk on AT */
--- 34,39 ----
***************
*** 252,257 ****
--- 251,257 ----
    base = (long) init_org + (long) init_text_clicks + (long) init_data_clicks;
    base = base << CLICK_SHIFT;
  
+ #ifdef RAM_DISK
    /* Get size of RAM disk by reading root file system's super block.
     * First read block 0 from the floppy.  If this is a valid file system, use
     * it as the root image, otherwise try the hard disk (RAM_IMAGE).  
***************
*** 293,298 ****
--- 293,301 ----
  	base = EM_ORIGIN;	/* tell RAM disk driver RAM disk origin */
    }
  #endif
+ #else
+   ram_clicks = 0;		/* we don't read it in ram disk */
+ #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.
***************
*** 308,313 ****
--- 311,317 ----
  #endif
    if (sendrec(MM_PROC_NR, &m1) != OK) panic("FS Can't report to MM", NO_NUM);
  
+ #ifdef RAM_DISK
    /* Tell RAM driver where RAM disk is and how big it is. */
    m1.m_type = DISK_IOCTL;
    m1.DEVICE = RAM_DEV;
***************
*** 340,345 ****
--- 344,350 ----
  	printf("\rRAM disk loaded.    Please remove root diskette.           \n\n");
    else
  	printf("\rRAM disk loaded.                                           \n\n");
+ #endif
  }
  
  
SHAR_EOF
fi
cd ..
exit 0
#	End of shell archive