how to change next boot from windows to freebsd?

Alex Zbyslaw xfb52 at dial.pipex.com
Thu Nov 8 04:27:05 PST 2007


Craig Boston wrote:

>Attached is the source to a program that I wrote about 4 and a half
>years ago.  It performs the function of a dumbed-down boot0cfg for
>Windows, only understanding the "-s" option, or giving you an
>interactive menu to choose from.  It also is hardcoded to use
>PhysicalDrive0, but that's usually what you would boot from.
>  
>
Thank you, Craig!  I've been looking for something like this and found 
your email in my spam folder where my mail system kindly files messages 
it doesn't want me to see :-)

A wee problem-ette for me is that I have FreeBSD on a separate disk from 
Windows so I wanted to be able to set the "Next Disk" option from 
windows to boot FreeBSD (a.k.a. F5).  I've confirmed that this is just 
stored as 4 in the MBR (partition -1, just like the rest).  boot0cfg 
allows 5 as a legitimate slice.

This patch allows you to set partitions from 1-5 instead of 1-4 from the 
command line, and also adds an automatic "5: Next disk" option in the in 
the interactive invocation.

Now to figure out how to shut down/reboot windows from a bat file so I 
can do one double-click and not faff around with the Start menu...

--Alex

-------------- next part --------------
--- nextboot.c.orig	Wed Nov  7 18:06:04 2007
+++ nextboot.c	Thu Nov  8 12:17:25 2007
@@ -414,6 +414,8 @@
 		    i + 1, getptype(part[i].dp_typ));
 	}
 
+    printf ("%c5. Next disk\n", (mbr[OFF_OPT] == 4) ? '*' : ' ');
+
     printf("\nSelect partition: ");
     fgets(resp, 255, stdin);
 
@@ -421,7 +423,7 @@
 	return 0;
 
     pnum = atol(resp) - 1;
-    if (pnum < 0 || pnum > 3 || !part[pnum].dp_typ)
+    if (pnum < 0 || pnum > 4 || (pnum < 4 && !part[pnum].dp_typ))
     {
 	fprintf(stderr, "Invalid partition\n");
 	return 1;
@@ -434,8 +436,8 @@
 {
     fprintf(stderr, "Usage:\n\n"
                     "          nextboot               (For interactive menu)\n\n"
-		    "          nextboot [1-4]         (Set partition to boot from)\n"
-		    "          nextboot -s [1-4]\n"
+		    "          nextboot [1-5]         (Set partition to boot from)\n"
+		    "          nextboot -s [1-5]\n"
 		    "\n");
     return 0;
 }
@@ -448,7 +450,7 @@
 	return menuboot();
     else if ((argc == 2) &&
 	    (strlen(argv[1]) == 1) &&
-	    (argv[1][0] >= '1' && argv[1][0] <= '4'))
+	    (argv[1][0] >= '1' && argv[1][0] <= '5'))
     {
 	act = atol(argv[1]);
 	return setnextboot(act - 1);
@@ -456,7 +458,7 @@
     else if ((argc == 3) &&
 	    !stricmp(argv[1], "-s") &&
 	    (strlen(argv[2]) == 1) &&
-	    (argv[2][0] >= '1' && argv[2][0] <= '4'))
+	    (argv[2][0] >= '1' && argv[2][0] <= '5'))
     {
 	act = atol(argv[2]);
 	return setnextboot(act - 1);


More information about the freebsd-questions mailing list