[comp.unix.i386] Changing partition from the command line?

jessea@dynasys.UUCP ( Sysadmin.) (11/17/89)

I'm working on a system which is running a 6386 AT+T machine with AT+T Unix
System V/386 on it.  Here's what I'd like to do.  The hard drive is partitioned
with a unix partition and a dos partition.  At a specified time, I would like
the computer to AUTOMATICALLY change the partition to the other one, and    
reboot the system so that the other operating system comes up (perhaps doing
it from cron on the unix side).  Is there anyway to change the partition
with out fdisk being interactive (in other words, strictly from the command
line so that it doesn't require that someone be there)?  I would like the
machine to run unix at night and run dos during the day.  But, I can't be
there to do it manually.  Thanx in advance.

P.S.  Does anyone know of a TSR that will do the same for dos?

-- 
Jesse W. Asher - Dynasys - (901)382-1705       Internet: jessea@dynasys.UU.NET 
6196-1 Macon Rd., Suite 200, Memphis, TN 38134     UUCP: uunet!dynasys!jessea 

fmcgee@cuuxb.ATT.COM (~XT6561110~Frank McGee~C23~L25~6326~) (12/03/89)

In article <23@dynasys.UUCP> jessea@dynasys.UUCP (Jesse W. Asher - Sysadmin.) writes:
>I'm working on a system which is running a 6386 AT+T machine with AT+T Unix
>System V/386 on it.  Here's what I'd like to do.  The hard drive is partitioned
>with a unix partition and a dos partition.  At a specified time, I would like
>the computer to AUTOMATICALLY change the partition to the other one, and    
>reboot the system so that the other operating system comes up (perhaps doing
>it from cron on the unix side).  Is there anyway to change the partition
>with out fdisk being interactive (in other words, strictly from the command
>line so that it doesn't require that someone be there)?  I would like the
>machine to run unix at night and run dos during the day.  But, I can't be

Like most Unix commands, you can redirect the input and output to
fdisk.  If you create a data file with the necessary keystrokes and
redirect it or pipe it to fdisk, fdisk will change your active
partition.  You should be able to run this from cron.  Suggestion -
make sure the file is read-only by root, and be very carefull to make
sure you have the correct keystrokes in file; if you fat finger it you
can delete your partition, and thus all your data on the disk.

Rebooting the machine is another matter.  To bring the machine down in
a sane manner, you need to unmount /usr.  You can't do this while
anything is using /usr, and cron resides in /usr/spool.  If you reboot
the machine automatically, the next time you boot unix you will have
to wait while fdisk runs on / and /usr, and there's also potential for
file corruption/loss.  About the only thing I can think of is to write
a script that resides under / and sleeps until the right time then
runs fdisk, and then runs /etc/shutdown.  If you specify -i6, shutdown
will reboot the machine after it completes.  If you run into problems
running /etc/shutdown, you might want to try using the following
commands in this order to bring the machine down :
	sync
	sync
	killall
	sync
	sync
	umountall
	sync
	sync
	uadmin 2 2
These (if they all succceed in performing their functions) will
perform a "fast" shutdown of a machine.  If you've just rebuilt your
kernel though (ie, you just installed a package or used idbuild) you
should use /etc/shutdown because it moves some files into their proper
places so that the new kernel will be booted.

Probably can't help you with the MSDOS side, don't think they have an
equivalent way to run a program at a given time.

If it were my machine, I wouldn't do this.  If any of the commands
fails, or if your file of keyboard input to fdisk gets corrupted, you
could lose data very quickly and possibly forever.

-- 
Frank McGee, AT&T
Tier 3 Complementary Channel Sales Support
attmail!fmcgee