Re: how to change next boot from windows to freebsd?

2007-11-08 Thread Alex Zbyslaw

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

--- 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);
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]

Re: how to change next boot from windows to freebsd?

2007-09-13 Thread Craig Boston
On Wed, Sep 12, 2007 at 12:16:35PM +0300, Georgi Iovchev wrote:
 Hello guys

Hi.

 But the problem is how to switch next boot when I am at windows via remote 
 desktop??! I need something like boot0cfg but for windows, but it doesnt 
 exist )

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.

I compile it using the devel/mingw32-gcc port.  You can probably also
use the version of mingw that's available through cygwin to compile it
on the Windows side.

Or you can be lazy and download the binary that I just posted to
http://www.severious.net/nextboot.exe
You should really compile it yourself though, rather than trusting
random executables from strangers :-)  I'll probably delete the binary
after a week or so, but the source should live on in the list archives.

The usual disclaimers:  This program changes your MBR, I'm not
responsible if it eats your partition table, your lunch, or your dog's
lunch.  Requires administrator rights to run.  TTL not included.

Hope this helps,
Craig
/* vim: set sts=4 sw=4: */
#include windows.h
#include stdio.h
#include string.h

#define MBR_SIZE 512
#define OFF_VERSION 0x1b0   /* offset: version number */
#define OFF_OPT 0x1b9   /* offset: default boot option */
#define OFF_DRIVE   0x1ba   /* offset: setdrv drive */
#define OFF_FLAGS   0x1bb   /* offset: option flags */
#define OFF_TICKS   0x1bc   /* offset: clock ticks */
#define OFF_PTBL0x1be   /* offset: partition table */
#define OFF_MAGIC   0x1fe   /* offset: magic number */

#define DOSPARTOFF  446
#define NDOSPART4

struct dos_partition {
unsigned char   dp_flag;/* bootstrap flags */
unsigned char   dp_shd; /* starting head */
unsigned char   dp_ssect;   /* starting sector */
unsigned char   dp_scyl;/* starting cylinder */
unsigned char   dp_typ; /* partition type */
unsigned char   dp_ehd; /* end head */
unsigned char   dp_esect;   /* end sector */
unsigned char   dp_ecyl;/* end cylinder */
unsigned intdp_start;   /* absolute starting sector number */
unsigned intdp_size;/* partition size in sectors */
};

int s_opt = 0;
int mbrread = 0;
unsigned char mbr[MBR_SIZE];

int errormsg(const char *msg)
{
LPVOID msgbuf;
if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) msgbuf,
0,
NULL ))
return 2;

fprintf(stderr, %s: %s\n, msg, (char*)msgbuf);
LocalFree(msgbuf);
return 1;
}

const char *getptype(unsigned char typ)
{
switch(typ)
{
case 0x1:
case 0x11:
return FAT12;
case 0x2:
return Xenix root;
case 0x3:
return Xenix /usr;
case 0x4:
case 0x14:
return FAT16 (Old school);
case 0x5:
return DOS Extended;
case 0x6:
case 0x16:
return FAT16;
case 0x7:
case 0x17:
return NTFS;
case 0x8:
return OS/2 or AIX;
case 0x9:
return QNX;
case 0xa:
return OS/2 Boot Manager;
case 0xb:
case 0x1b:
return FAT32;
case 0xc:
case 0x1c:
return FAT32 LBA;
case 0xe:
case 0x1e:
return FAT16 LBA;
case 0xf:
return Extended LBA;
case 0x12:
return Compaq Diagnostics;
case 0x18:
return AST Suspend-to-disk;
case 0x24:
return NEC DOS;
case 0x35:
return OS/2 Warp;
case 0x38:
case 0x3a:
return THEOS;
case 0x39:
return Plan 9;
case 0x3c:
return PartitionMagic Recovery;
case 0x40:
return Venix;
case 0x41:
case 0x42:
case 0x43:
return DRDOS Cruft;
case 0x44:
return GoBack;
case 0x45:
return Boot-US;
case 0x46:
case 0x47:
case 0x48:
return EUMEL/Elan;
case 0x4a:
return AdaOS;
case 0x4c:
case 0x4f:
return Oberon;
case 0x4d:
case 0x4e:
return QNX;
case 0x50:
return OnTrack Disk Manager;
case 0x51:
return Novell;
case 0x52:
return CP/M;
case 0x53:
return Disk Manager;
case 0x54:
 

how to change next boot from windows to freebsd?

2007-09-12 Thread Georgi Iovchev
Hello guys

On my pc I have FreeBSD and Windows partitions. I often use my computer 
remotly, and sometimes i need to switch from bsd to windows and vice versa.

I use freebsd's boot manager to select os at boot, and it remembers my last 
choice. When I am in bsd from ssh i use boot0cfg to set what partition should 
be used on next boot and then reboot - it works - this way i can successfuly 
switch from bsd to windows.
But the problem is how to switch next boot when I am at windows via remote 
desktop??! I need something like boot0cfg but for windows, but it doesnt exist )

Need help, 10x in advance!


p.s. my bsd is FreeBSD 6.2 i386; my windows is windows server 2003 x64
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: how to change next boot from windows to freebsd?

2007-09-12 Thread Erich Dollansky

Hi,

I am not sure but cygwin could be of help here.

Erich

Georgi Iovchev wrote:

Hello guys

On my pc I have FreeBSD and Windows partitions. I often use my computer 
remotly, and sometimes i need to switch from bsd to windows and vice versa.

I use freebsd's boot manager to select os at boot, and it remembers my last 
choice. When I am in bsd from ssh i use boot0cfg to set what partition should 
be used on next boot and then reboot - it works - this way i can successfuly 
switch from bsd to windows.
But the problem is how to switch next boot when I am at windows via remote 
desktop??! I need something like boot0cfg but for windows, but it doesnt exist )

Need help, 10x in advance!


p.s. my bsd is FreeBSD 6.2 i386; my windows is windows server 2003 x64
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: how to change next boot from windows to freebsd?

2007-09-12 Thread Ivan Voras

Erich Dollansky wrote:

Hi,

I am not sure but cygwin could be of help here.


Not very likely.

The OP might want to try using the Windows boot loader (ntldr) instead 
of FreeBSD's, as it is configured by a text file (c:\boot.ini) which can 
be edited from both FreeBSD and Windows. There are several online 
tutorials on how to use it to boot Linux, use boot1 file for the FreeBSD 
boot sector.


I have no idea how to enable the Windows boot loader after both Windows 
and FreeBSD are installed on the machine and FreeBSD's loader is installed.




signature.asc
Description: OpenPGP digital signature


Re: how to change next boot from windows to freebsd?

2007-09-12 Thread Tijl Coosemans
On Wednesday 12 September 2007 14:30:32 Ivan Voras wrote:
 I have no idea how to enable the Windows boot loader after both
 Windows and FreeBSD are installed on the machine and FreeBSD's loader
 is installed.

It's one of mbrfix or fixmbr or fdisk /mbr iirc.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: how to change next boot from windows to freebsd?

2007-09-12 Thread Andrey Shuvikov
 On Wednesday 12 September 2007 14:30:32 Ivan Voras wrote:
 I have no idea how to enable the Windows boot loader after both
 Windows and FreeBSD are installed on the machine and FreeBSD's loader
 is installed.

FreeBSD usually sets active partition (slice) to itself even if boot
manager is not installed. fdisk can show which partition is active and
allows to change it if necessary.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]