LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-29-2007, 11:04 AM   #16
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743

If you install Windows, it puts its own boot code into the MBR--and overwrites GRUB. Or maybe I did not understand your question correctly.....
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 07-29-2007, 09:31 PM   #17
markmlinux
LQ Newbie
 
Registered: Jun 2007
Location: San Diego
Distribution: Slackware 11.0
Posts: 13

Rep: Reputation: 0
BS sizes

My experience has been different depending on the machine, and of that perhaps the drive.
I have been backing up the boot sector as a matter of consequence, as soon as I set up the partition. After major changes. Also the choice of FS seems to effect what will work - or somebody prove me wrong - pls. I think there is just a lot of variables and that it is too much to handle without a methodology that just steers you in the right direction.

I prepare a new drive:
Backup
dd if=/dev/hdax of=/boot/sb-446-28jul07.bin bs=446 count=1
where the x is a number [1-4] corresponding to your partition number
dd if=/dev/hda of=/boot/mbr-512-28jul07.bin bs=512 count=1

If I mess up the boot sector, as I have done with lilo, just about everytime I set up a new system.

I first restore the boot sector with the 446 bytes
dd if=/boot/dev/hdax of=/dev/hda[1-4] bs=446 count=1
reboot

If that doesn't work I try the whole sector or mbr (cross fingers)

dd if=/boot/mbr-512-28jul07.bin of=/dev/hda bs=512 count=1

reboot and hope!

If you later add another partition for whatever, and your sure it works backup both superboot sectors of 446 bytes. And also the mbr (one sector) of 512 bytes (/dev/hda[1-4])
Keep your old binary files just in case. I try to use a bootable CD to access the drive to rewrite the files with dd, when I need to. Slax bootable CD helps {SLAX noauto nopcmcia nohotplug)

As of now I'am running a 2.6 kernel, XFS FS, approx 50gb partition on my laptop.
XFS uses only the command 'lilo -C /boot/lilo.conf' and I'am not using -c, which compact is the default - isn't it? As I'am having a lot of trouble with a nasty ATI Radeon Xpress 200M Video Integrated chip and it crashes and messes up the FS - I repair the system constantly by rebooting to slax as I said, running 'xfs_repair /dev/hda1'. It's still working after a lot of abuse.

Hope I helped. Remember to sanity check this.

markmlinux@gmail.com
 
Old 08-06-2007, 11:57 AM   #18
rakeshj
Member
 
Registered: Jun 2007
Posts: 44

Rep: Reputation: 15
Thanks to all for this thread & sorry for posting my question in this thread which is started by Comatose. I find it very interesting & useful. Possibly it can help me rescue me from the problems I created by installing Xubuntu without
properly thinking about the future problems. Following is the description:

I recently installed Xubuntu (from LiveCD). As I did not have prior experience on
Xubuntu, MBR etc so I installed Grub on MBR (as default) on my PC hard disk though
I was installing Xubuntu software on external USB disk. All looked very nice till
one day when I discovered that if I do not insert USB drive then I can not boot
my Windows XP. With USB drive, I was presented menu to choose to boot Xubuntu or
Windows XP.

Now I want such an arrangement that if I do not connect USB drive then I automatically boot into Windows XP. How this can be done?

If I copy first 446 bytes from my hard disk to my USB drive & then erase
(zerorise) those 446 bytes on hard disk this will recover my MBR? What about
partion table & remaining bytes from first sector of hard disk? Do I have to take
any action about those? Also, what about remaining bytes (following 446 bytes
till 512 bytes) on USB drive? Do I have to take any action on these? Currently
dd command shows all 0s on first 512 bytes of USB drive? What do the Recovery of
MBR by XP Install/Recovery CD do?


Kindly suggest.

Best regards, RAKESH

PS: One suggestion is to recover MBR of hard disk using XP Installaion/Recovery
CD & then re-install Xubuntu. I want to avoid this to save effort & time in
I put in installing other S/W on it & also I am not sure if Xubuntu Live
/Desktop CD will give me chance to install Grub in USB drive's first sector?
 
Old 08-06-2007, 12:17 PM   #19
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
If you are booting from hard disk, the MBR of the first hard disk must contain boot code. (Control is passed by the BIOS to the MBR, so there must be code there).

When GRUB is installed (anywhere) it gets "hard-coded" to point to the /boot directory where its files are. Thus, you cannot simply copy GRUB to different locations and expect it to work.

One way to do what you are asking is to make a GRUB file which gets installed in the Windows system area, and then edit the Windows boot config file to include the GRUB file. (Search here or at Google using "boot linux using NTLDR")

Another way would be to put GRUB on the MBR of the external drive, and then change the boot order in the BIOS.

Or----you could simply make a boot floopy for Linux.
 
Old 01-19-2009, 11:24 AM   #20
whittycat
Member
 
Registered: Nov 2004
Location: Wellington Somerset UK
Distribution: Debian lenny, also DSL-N
Posts: 32

Rep: Reputation: 15
I was hoping this would help me too. I am using DSL (Damn small linux) and at startup it tells me I have a boot sector virus. I tried this
dd if=/dev/zero of=/dev/hda bs=446 count=1
/sbin/lilo
shutdown -r now
but the message remains. I'll have to find an AV program for DSL.
 
Old 03-23-2014, 10:39 AM   #21
hunterjoz1996
Member
 
Registered: Dec 2013
Location: Virginia Beach, VA
Distribution: Arch Linux
Posts: 59

Rep: Reputation: 6
What is this dd command intended to do? I tried it on a Gentoo CD, but it won't go anywhere else but the CD on reboot.
 
Old 03-23-2014, 10:59 AM   #22
rokytnji
LQ Veteran
 
Registered: Mar 2008
Location: Waaaaay out West Texas
Distribution: antiX 23, MX 23
Posts: 7,148
Blog Entries: 21

Rep: Reputation: 3483Reputation: 3483Reputation: 3483Reputation: 3483Reputation: 3483Reputation: 3483Reputation: 3483Reputation: 3483Reputation: 3483Reputation: 3483Reputation: 3483
Quote:
What is this dd command intended to do?
In the wrong hands. Data Destroyer.

In the right hands. It can write zeros where you want on the drive or copy a whole install including mbr byte by byte if you know what you are doing.

I copied my eeepc 701SD 8 gig Windows XP SSD to external SD flash card and when done.
Hit the Esc key and booted the Windows XP off of external SD.

Both are gone now though. The card is used for something else and the eeepc has been sold.

Code:
man dd
Gentoo CD? OMG. Happy Trails, Rok

Last edited by rokytnji; 03-23-2014 at 11:01 AM.
 
Old 03-23-2014, 01:08 PM   #23
hunterjoz1996
Member
 
Registered: Dec 2013
Location: Virginia Beach, VA
Distribution: Arch Linux
Posts: 59

Rep: Reputation: 6
It didn't destroy my Windows partition, thank god, but it probably did break the MBR, for now I can't boot in to my hard disk. Is there another part I need to do? It all went south after I nuked my Fedora partition because I wanted to try something else.
 
Old 03-23-2014, 01:15 PM   #24
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
hunterjoz1996 i take it you did not realize that this thread is NINE years old
it was started on 03-11-05
 
Old 03-23-2014, 01:21 PM   #25
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by hunterjoz1996 View Post
What is this dd command intended to do? I tried it on a Gentoo CD, but it won't go anywhere else but the CD on reboot.
Which of the dd commands did you try, the one with the bs=446 parameter or the one with bs=512?
If the first, you have just deleted the bootloader of your disk, this can easily be repaired using a Windows installation disc (in case you only want Windows) or with installing a Linux distribution (in case you want to replace your Fedora with something else).
If you have used the bs=512 parameter you not only have deleted the bootloader, but also the partition table. In that case you have to fix the partition table first, before repairing the bootloader. This can easily be done using Testdisk, which should have no problems to find your partitions and create a new partition table.
 
Old 03-23-2014, 02:33 PM   #26
hunterjoz1996
Member
 
Registered: Dec 2013
Location: Virginia Beach, VA
Distribution: Arch Linux
Posts: 59

Rep: Reputation: 6
I did the 446 one. As far as the oldness of the post, I do appologize.
 
Old 03-23-2014, 02:52 PM   #27
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Do you want to install a new Linux distribution? In that case your problem will fix itself if you do exactly that.
In case you want to run Windows only on that machine follow the instructions here: http://www.linuxquestions.org/questi...rtitions-4060/
 
Old 03-24-2014, 04:26 PM   #28
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,691
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
Never believe anything that says that you "have a boot-sector virus." There's no such thing.

The MBR is nothing more than a tiny piece of code (which is totally predictable ...) which tells early-vintage (BIOS ...) firmware "what to do next" in order to launch "whatever boot-loader" you are using. (Kindly remember that we are talking about the content of one sector on your hard drive.)

If something's broken in the MBR, all you need to do is to run the standard install-procedure for whatever boot loader you want to use. (If you're seriously worried about the content of the MBR, just overwrite it.)

In the case of Microsoft Windows, just install or "repair" the product, and it will (of course) take care of itself. It will (re-)write whatever-it-takes to launch its own preferred (required ...) NTLDR.

In the case of Grub (at this point, I can't reasonably recommend LILO ...), just follow its directions. Grub's a generalized, hence much more versatile loader. (Re-)Installing Grub will, as a matter of course, overwrite the MBR with whatever-it-takes to launch Grub. Beyond that, if you need to boot Windows, you'll of course need to configure Grub to create the environment that Microsoft's NTLDR expects.

In any(!!) case ... the use of fdisk is "massive overkill." Akin to using a howitzer to swat a fly. ("Even if you don't know what t'hell you're doing, don't do that!" )

Last edited by sundialsvcs; 03-24-2014 at 04:30 PM.
 
Old 03-24-2014, 04:52 PM   #29
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,152

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
Quote:
Originally Posted by sundialsvcs View Post
Never believe anything that says that you "have a boot-sector virus." There's no such thing.
Rubbish.

I still have a specially quaranteened (floppy) disk that has the Michaelangelo virus on it. I decided to hand decode it after it hit our office many moons ago. And yes, it lives in the MBR and trashes the first hard disk, *and* replicates itself onto any disk it finds.
None too subtle, but effective for what the author apparently wanted to do.
 
Old 03-24-2014, 05:31 PM   #30
hunterjoz1996
Member
 
Registered: Dec 2013
Location: Virginia Beach, VA
Distribution: Arch Linux
Posts: 59

Rep: Reputation: 6
Thanks for the tips, guys! They've been very helpful, and I'm glad to say that I'm back in business.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Fdisk /MBR Eugney Slackware 39 08-23-2011 09:30 AM
Grub - fdisk /MBR lucho707 Linux - Software 1 11-30-2005 11:07 PM
by tring to fix the MBR i damage the MBR that was help... AKAKAK Fedora 4 03-21-2005 08:18 AM
fdisk /mbr rharvey@cox Linux - Software 2 02-16-2004 12:19 PM
why won't my mbr fdisk /mbr? jamessp007 Mandriva 13 01-03-2004 01:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:14 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