LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-03-2004, 08:12 AM   #1
antken
Member
 
Registered: Nov 2000
Posts: 368

Rep: Reputation: Disabled
using DD to copy the boot sector in and out


hi,

at present i have a windows box in my cluches. at a certain time i would like the box to re-boot into a linux mode let it run some diag stuff and then re-boot into windows all automatically.

i can get the windows thing to re-boot when ever i want, however i am unsure how to get the box to jump into linux.

so i thought this may be a good idea:

1. the time comes for a re-boot
2. the current windows Bootloader is copied out into a backup file on to a dedicated partition.
3. the linux bootloader ( probably lilo ) is copied from the dedicated partition to the MBR of the disk.
4. the machine re-boots into linux and does its stuff

and then when done re-does the above ( but points 2 and 3 are swapped around and changed respectivly )


now if possible all this needs to happen without user intervention.

can the boot sector/MBR be copied using just the dd command? if so, any ideas?

thanks
 
Old 04-03-2004, 11:25 AM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
It might be easier to use grub as your bootloader. Grub is easier to use than lilo because you have to rewrite the MBR whenever you change lilo.conf but you don't have to rewrite the MBR when you change grub.conf.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 04-03-2004, 03:22 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Then how would you automatically boot back to linux? Windows can't modify the grub.conf unless its on a FAT32 partition.

You would need a console windows app of some kind to write a file to the MBR.

dd if=/dev/hda of=mbr.bin bs=512 count=1

If your booting from hda.

What version of windows? With Windows 98 you can create a boot floppy disk with a config.sys menu and use loadlin for linux. Then either OS could modify the floppy disk. However, this method will not work for XP or W2K.
 
Old 04-03-2004, 03:44 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
"Then how would you automatically boot back to linux? Windows can't modify the grub.conf unless its on a FAT32 partition. "

You could try making grub.conf a symbolic link to a file on a FAT32 partition. I don't know if grub is smart enough to handle a symbolic link or not. You could experiment and see.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
Old 04-03-2004, 06:13 PM   #5
AutOPSY
Member
 
Registered: Mar 2004
Location: US
Distribution: Redhat 9 - Linux 2.6.3
Posts: 836

Rep: Reputation: 31
The filesystem with the symbolic link has to be mounted before it would work.
if it would work.

This absolutely would not work as easy as youd expect.
 
Old 04-03-2004, 06:30 PM   #6
2damncommon
Senior Member
 
Registered: Feb 2003
Location: Calif, USA
Distribution: PCLINUXOS
Posts: 2,918

Rep: Reputation: 103Reputation: 103
From the Lilo man page:

-R command line
This option sets the default command for the boot loader the next time it executes. The boot loader will then erase this line: this is a once-only command. It is typically used in reboot scripts, just before calling `shutdown -r'. Used without any arguments, it will cancel a lock-ed or fallback command line.

I haven't tried it. Maybe it is what you want?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Boot Sector phoenix7 Linux - General 1 11-25-2004 10:22 AM
Boot Sector on dual boot PC. Remove Mandrake and replace with FreeBSD Phin666 *BSD 1 10-30-2004 05:02 PM
Re:do I need liloand a /boot sector MunCH Slackware 3 06-26-2004 10:22 AM
boot error after using Copy Commander to copy debian system onto larger new drive Interceptor Linux - Hardware 7 05-04-2003 12:40 PM
No boot sector found, error at boot areeves88 Linux - General 3 01-18-2003 08:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration