diff --git a/src/base/init/config.c b/src/base/init/config.c
index 7bb1dc08d..8ebdba308 100644
--- a/src/base/init/config.c
+++ b/src/base/init/config.c
@@ -272,6 +272,8 @@ void dump_config_status(void (*printfunc)(const char *, ...))
         (*print) ("keytable not setup yet\n");
     }
     (*print)("pre_stroke \"%s\"\n", (config.pre_stroke ? config.pre_stroke : ""));
+    (*print)("kernelcommandline \"%s\"\n",
+	(config.kernelcommandline ? config.kernelcommandline : "@none@"));
     (*print)("irqpassing= ");
     if (config.sillyint) {
       int i;
diff --git a/src/base/init/lexer.l b/src/base/init/lexer.l
index 029f6a7f5..eb6e769a2 100644
--- a/src/base/init/lexer.l
+++ b/src/base/init/lexer.l
@@ -313,6 +313,7 @@ mouse			RETURN(MOUSE);
 serial			RETURN(SERIAL);
 keyboard		RETURN(KEYBOARD);
 keystroke		RETURN(PRESTROKE);
+kernelcommandline	RETURN(KERNELCOMMANDLINE);
 terminal		RETURN(TERMINAL);
 video			RETURN(VIDEO);
 emuretrace		RETURN(EMURETRACE);
diff --git a/src/base/init/parser.y b/src/base/init/parser.y
index e24f435ae..0aba21ec7 100644
--- a/src/base/init/parser.y
+++ b/src/base/init/parser.y
@@ -252,6 +252,7 @@ enum {
 	/* keyboard */
 %token RAWKEYBOARD
 %token PRESTROKE
+%token KERNELCOMMANDLINE
 %token KEYTABLE SHIFT_MAP ALT_MAP NUMPAD_MAP DUMP LAYOUT
 %token DGRAVE DACUTE DCIRCUM DTILDE DBREVE DABOVED DDIARES DABOVER DDACUTE DCEDILLA DIOTA DOGONEK DCARON
 	/* ipx */
@@ -729,6 +730,12 @@ line:		CHARSET '{' charset_flags '}' {}
 		    c_printf("CONF: appending pre-strokes '%s'\n", $2);
 		    free($2);
 		    }
+		| KERNELCOMMANDLINE string_expr
+		    {
+		    set_kernelcommandline($2);
+		    c_printf("CONF: setting kernel command line '%s'\n", $2);
+		    free($2);
+		    }
 		| KEYTABLE DUMP string_expr {
 			dump_keytables_to_file($3);
 			free($3);
diff --git a/src/base/misc/fatfs.c b/src/base/misc/fatfs.c
index 2864a89ff..335d01f71 100644
--- a/src/base/misc/fatfs.c
+++ b/src/base/misc/fatfs.c
@@ -95,6 +95,7 @@ static int read_dir(fatfs_t *, unsigned, unsigned, unsigned,
 	unsigned char *buf);
 static unsigned next_cluster(fatfs_t *, unsigned);
 static void build_boot_blk(fatfs_t *m, unsigned char *b);
+static void handle_kernelcommandline(uint16_t stackseg, uint16_t stackbp);
 
 static uint64_t sys_type;
 static int sys_done;
@@ -110,6 +111,14 @@ void fatfs_set_sys_hook(void (*hook)(struct sys_dsc *, fatfs_t *))
     sys_hook[sys_hooks_used++] = hook;
 }
 
+void set_kernelcommandline(char *s)
+{
+  if (config.kernelcommandline) {
+    free(config.kernelcommandline);
+  }
+  config.kernelcommandline = strdup(s);
+}
+
 #define IX(i, j) ((1 << i##_IDX) | (1 << j##_IDX))
 static const uint64_t MS_D = IX(IO, MSD);
 static const uint64_t DR_D = IX(DRB, DRD);
@@ -1595,6 +1604,23 @@ unsigned next_cluster(fatfs_t *f, unsigned clu)
   return clu + 1;
 }
 
+static void handle_kernelcommandline(uint16_t stackseg, uint16_t stackbp) {
+  if (config.kernelcommandline
+    && strcmp(config.kernelcommandline, "@none@") != 0
+    && stackbp >= (256 + 0x114)) {
+    char *string_pointer;
+    uint16_t * clsignature;
+    LWORD(esp) = stackbp - 0x114;
+    clsignature = (uint16_t *)
+      LINEAR2UNIX(SEGOFF2LINEAR(stackseg, stackbp - 0x14));
+    *clsignature = 'C' + 'L' * 256;
+    string_pointer = (char *)
+      LINEAR2UNIX(SEGOFF2LINEAR(stackseg, stackbp - 0x114));
+    strncpy(string_pointer, config.kernelcommandline, 256);
+    string_pointer[255] = 0;
+  }
+}
+
 /*
  * This will be called by dos_helper (base/async/int.c)
  * when the bootsector is executed.
@@ -1751,8 +1777,9 @@ void mimic_boot_blk(void)
       SREG(cs)  = seg;
       LWORD(eip) = ofs;
 
+      handle_kernelcommandline(0x1FE0, 0x7C00);
       /* load boot sector to stack */
-      read_boot(f, LINEAR2UNIX(SEGOFF2LINEAR(_SS, _SP)));
+      read_boot(f, LINEAR2UNIX(SEGOFF2LINEAR(0x1FE0, 0x7C00)));	/* load BPB */
       break;
 
     case RXO_D:
@@ -1790,6 +1817,7 @@ void mimic_boot_blk(void)
       LWORD(esp) = 0x7C00 - sizeof(*lsv);	/* -> lsv */
       SREG(cs)  = seg;
       LWORD(eip) = ofs;
+      handle_kernelcommandline(0x1FE0, 0x7C00);
 
       read_boot(f, LINEAR2UNIX(SEGOFF2LINEAR(0x1FE0, 0x7C00)));	/* load BPB */
       /* RxDOS.3 load protocol note:
diff --git a/src/base/misc/fatfs.h b/src/base/misc/fatfs.h
index f7fd2ec59..723e30ef1 100644
--- a/src/base/misc/fatfs.h
+++ b/src/base/misc/fatfs.h
@@ -30,6 +30,7 @@ struct sys_dsc {
 #define FLG_NOREAD 8
 
 void fatfs_set_sys_hook(void (*hook)(struct sys_dsc *, fatfs_t *));
+void set_kernelcommandline(char *s);
 
 enum { IO_IDX, MSD_IDX, DRB_IDX, DRD_IDX,
        IBMB_IDX, IBMD_IDX, EDRB_IDX, EDRD_IDX,
diff --git a/src/dosemu b/src/dosemu
index 5c9a9b941..fe5aad0e4 100644
--- a/src/dosemu
+++ b/src/dosemu
@@ -24,7 +24,7 @@ USAGE:
 THISDIR="$PWD"
 ARG0="$0"
 
-unset STRING_I USE_SUDO INPUT OPTS
+unset STRING_I USE_SUDO INPUT KERNELCOMMANDLINE OPTS
 
 mkdir -p ~/.dosemu
 
@@ -86,6 +86,14 @@ while [ $# -gt 0 ] ; do
       fi
       shift
       ;;
+    -kernelcommandline)
+      KERNELCOMMANDLINE=1
+      if [ -n "$2" ]; then
+        STRING_I="$STRING_I kernelcommandline "'"'"$2"'"'
+        shift
+      fi
+      shift
+      ;;
     -license)
       printf "$license"
       shift
diff --git a/src/include/emu.h b/src/include/emu.h
index 0460f6a5c..b1429c8a7 100644
--- a/src/include/emu.h
+++ b/src/include/emu.h
@@ -278,6 +278,7 @@ typedef struct config_info {
        unsigned short detach;
        char *debugout;
        char *pre_stroke;        /* pointer to keyboard pre strokes */
+	char * kernelcommandline;
 
        /* Lock File business */
        int file_lock_limit;
