[comp.sys.ibm.pc] DOS --> XENIX --> DOS

osbook@sdcsvax.UCSD.EDU (osbook) (11/27/86)

I have been reading notes in this newsgroup
from people using DOS and XENIX on the same machine,
discussing ways to switch between operating systems.

I recently posted an article explaining how to do this
well, but perhaps it didn't make it to comp.sci.ibm.pc.

I tried to send a copy of the article to

howardl@tekline.UUCP (one of the questioners)

but I couldn't get there from here.

So here is the (now open) letter to Howard
followed by a reprint of my article.  If anyone has problems
let me know.  If this helps you let me know.

Dear Howard:

Stop me if you've heard this one...

You can set up a hard disk to boot either XENIX or DOS.  Yes there is only one
boot record, but the boot record transfers control to the "Active"
partition, which can be either a Xenix or DOS partition.  And you can
switch back and forth and you ** do not ** have to boot from floppies.

I recently posted an article to the net explaining how to set up a system
to gracefully switch from one OS to another.  For your information
I am including a copy of it below.  If you have any questions, send
me mail.  It sounds like you are a bit confused.  Don't worry, once
you sort out the details you can automatate things completely.
I switch from DOS--XENIX--DOS all the time and a never use floppies
except for backups.  I even have it menu driven on DOS (using
a mouse systems optical mouse and a menu programming language).
All I do is click the mouse, select "Xenix" and I'm booting Xenix.
From Xenix, all I have to do is type "dos" to get to DOS.

By the way, if you have anyone there that needs to learn DOS,
XENIX, or assembly language. might I recommend my books:
(plug, plug...)

1) Using your IBM PCAT (DOS)
2) Mastering Xenix on the IBM PC AT
3) The complete guide to IBM PC AT assembly language.

(published by Scott, Foresman and Co.  A bargain at half the price)

Here is the article:

=================cut here============================================

I have been asked to show how to set up files to switch automatically 
between DOS and XENIX on the same machine.

In general, a hard disk that contains both DOS and XENIX will be paritioned 
into 4 partitions.
     1) XENIX bad track table (very short)
     2) XENIX root file system
     3) XENIX usr [sic] file system
     4) DOS
This happens when you install XENIX.

At any time, one of these partitions is "active".  If parition 2 is active, 
Xenix will boot when you turn on the computer.  If partition 4 is active, DOS 
will boot when you turn on the computer.

You use the FDISK utility (comes with DOS and XENIX) to change the active 
partition.  For example, if XENIX boots automatically, you can have DOS boot 
automatically by activating partition 4.  This automatically deactivates 
partition 2.

(Note: Some XENIX's, eg.IBM 2.0, will let you type "DOS" and start DOS whenever 
XENIX is ready to boot.  This will start DOS, but it will not change the 
active partition.)

The ideal system would be to easily activate one or the other 
partition whenever you want; that is, to be able to change from DOS to XENIX to 
DOS easily.

Of course, you could do it by hand, using FDISK, but this is a bad idea.  
First, this is not easy enough.  Second, you do not want to be messing with 
FDISK!  One false move could wipe out (re-partition) everything beyond recall.

The solution is to call FDISK using a carefully designed script.  Assuming 
that the paritions on your disk are as I described above, here is how you do 
it.

1) Changing from XENIX to DOS: 

Use the following shell script.  This script feeds the correct responses to 
the fdisk program to activate the DOS partition.  (By the way, the Xenix fdisk 
program is much safer than the DOS FDISK.  The Xenix program will not let you 
cause damage.)

     echo 
     echo '** Changing to DOS **'
     echo 
     fdisk /dev/rhd00 <<- eof >/dev/null 2>/dev/null
         a
         4
         w
         q
     eof

Note1: the line with "eof" must start at column 1.
Note2: this script assumes that your hard disk is C: ("rhd00")

Create this script as userid root and give it 755 permission.
Say that you call it "dos" and put it in 
the root directory.  Then, root can switch to DOS by entering:
     /dos
A useful idea is to create the following short script:
     su - root -c /dos
and call it "dos" and put it where everyone can get at it with permissions
of 755.  Then, any userid can change to DOS, iff the user knows the root
password.  If you set this up and you are logged in under your own userid
(not root) and you enter:
     dos
you will be asked:
     Password:
After entering the root password, your system will automatically change to 
DOS.

2) Changing from DOS to XENIX:

Here is a batch file to change from DOS TO XENIX (the file "fdisk.xen"
is explained below):

     :* Batch file to change to Xenix
          echo off

     :* Activate Xenix FDISK partition
          fdisk < fdisk.xen

     :* Tell user to reboot
          echo XENIX partition activated
          echo To change to XENIX, reboot system

If you have a program such as "warmboot" that automatically reboots from DOS, 
you can reboot automatically from the batch file.

Name the batch file XENIX.BAT.  Then, you can change to Xenix anytime by 
entering:
     xenix

The batch file works by assuming that the file FDISK.XEN contains the correct 
commands for FDISK.  Thus, you must build such a file and make sure that it 
can be found by XENIX.BAT.  For example, if you are keeping FDISK.XEN in the 
\SYSTEM\UTILITY directory, change the fourth line in the batch file to:

          fdisk < \system\utility\fdisk.xen

To build FDISK.XEN you need to know what responses FDISK expects to change the 
active partition from #4 to #2. These responses are (check it yourself on your 
own system):

     2 <enter>
     2 <enter>
     <escape> <escape>

Note that there are no <return>'s after the <escape>'s.

Unfortunately, it may not be easy to 
create FDISK.XEN.  Bear in mind, you need to generate a 8 byte file that 
contains the 8 bytes shown above (<enter> takes 2 bytes).
EDLIN cannot do it for you as it will not
let you put in <escape> characters.  Perhaps you have an editor that can do 
the job.  If not try:
     1) Do it with vi under Xenix (use Ctrl-v escape) and pass it to DOS.
     2) Write a BASIC program to create the file.
     3) Create a dummy file:
       copy con: fdisk.xen
       2
       2
       xx<F6>
     then use the Norton Utilities or something to change the "xx" to
     two <escape> characters (hex 1B, decimal 27).
This works fine.

Note: When you execute XENIX.BAT and FDISK works automatically, you will hear 
two beeps.  Don't worry, it's okay.

Final Note: Usually, I suggest that people remove the FIDSK program from their
hard disks.  This prevents anyone else from accidentally causing catastrophic 
damage.  However, in this case, you need FDISK.  I suggest that you rename it 
to something else and change XENIX.BAT accordingly.