Jump to content











Photo
- - - - -

How to completely remove Grub4Dos without reformat hard disk?


  • Please log in to reply
31 replies to this topic

#1 peter_george

peter_george
  • Members
  • 1 posts
  •  
    Vietnam

Posted 13 March 2010 - 05:10 AM

Hi everyone :cheers:.

I intend to install Grub4Dos on my external HDD (connect to PC through USB cable). This external HDD have only a primary partition which is formatted as NTFS and have no OS installed on it. I want to make this HDD bootable (using contents of Hiren's Boot CD 10.0 ) so I need to install Grub4Dos.

My question is: if I install Grub4Dos on MRB or partition boot sector, can I completely remove it without reformatting HDD?

I appreciate all of your advises. Thanks so much :lol:.

#2 shamurshamur

shamurshamur

    Frequent Member

  • Developer
  • 322 posts
  •  
    India

Posted 13 March 2010 - 06:13 AM

My question is: if I install Grub4Dos on MRB or partition boot sector, can I completely remove it without reformatting HDD?

whether you are installing or removing grub4dos. you don't need to format your HDD.

#3 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 13 March 2010 - 08:17 AM

Hiren's Boot CD is WAREZ :lol:.

There won't be any support for it here, and you should be ashamed of using it.

:cheers:

Wonko

#4 Karl1982

Karl1982

    Member

  • Members
  • 41 posts
  •  
    United States

Posted 13 March 2010 - 12:06 PM

There are two basic components to grub4dos: files and MBR/bootsectors. Files can simply be deleted.

As for the MBR and/or bootsector, they would have to be overwritten. If you were to install Windows, for example, it would overwrite the MBR on the disk and overwrite the bootsector on the NTFS partition where you installed it. So there would be no more pieces of grub4dos on the drive (unless you had it installed to the bootsector of a different partition of course).

Although personally I find Microsoft's MBR code to be very careless. Case in point, it overwrites any other boot code that's in its way without giving it a second thought or asking the user. But that will remove grub4dos without formatting if you really want to.

#5 MedEvil

MedEvil

    Platinum Member

  • .script developer
  • 7771 posts

Posted 13 March 2010 - 12:24 PM

My question is: if I install Grub4Dos on MRB or partition boot sector, can I completely remove it without reformatting HDD?

Just install it into its own partition and you will have no problem getting rid of it completely.

:cheers:

#6 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 13 March 2010 - 01:13 PM

So there would be no more pieces of grub4dos on the drive (unless you had it installed to the bootsector of a different partition of course).

NO.

If grub4dos is installed to the MBR it also writes a number of the hidden sectors.

You should overwrite the MBR AND 00 out the hidden sectors if you really want to have "no more pieces of grub4dos on the drive".

:cheers:

Wonko

#7 Karl1982

Karl1982

    Member

  • Members
  • 41 posts
  •  
    United States

Posted 13 March 2010 - 01:58 PM

Yes but are those sectors not essentially inert once a different MBR has been written?

#8 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 13 March 2010 - 02:04 PM

Yes but are those sectors not essentially inert once a different MBR has been written?

Sure. :cheers:

But "completely remove" or "no more pieces of grub4dos on the drive" doesn't mean "disable" or "make inert".

:cheers:

Wonko

#9 shamurshamur

shamurshamur

    Frequent Member

  • Developer
  • 322 posts
  •  
    India

Posted 13 March 2010 - 02:50 PM

You should overwrite the MBR AND 00 out the hidden sectors if you really want to have "no more pieces of grub4dos on the drive".

tell me more about those hidden sectors.....

#10 Karl1982

Karl1982

    Member

  • Members
  • 41 posts
  •  
    United States

Posted 13 March 2010 - 03:16 PM

I typically back up the old MBR to a file first, then set --no-backup-mbr and --mbr-disable-osbr when I actually install it. Is it still writing to hidden sectors in that case?

#11 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 13 March 2010 - 03:33 PM

tell me more about those hidden sectors.....


Once upon a time there were a bunch of happy sectors, in the beginning all sectors were free and visible, and had no limits like Cylinder or Head boundaries, then the evilness of a witch called "The Partitioner" made them disappear by creating a MBR and making them hidden.....:cheers:
.... over time witches grew more and more evil, initially they hid just 16 of them, and then 32, and later 63 and now the BAD, BAD witch "VistaPartitioner" hides 128 of them and even more.... ;)

You should read a bit about partitioning, start from here:
http://www.ranish.com/part/
http://www.ranish.com/part/primer.htm

Then go here:
http://www.boot-land...?showtopic=9897

and start from the links in this post:
http://www.boot-land...?...=9897&st=11

I typically back up the old MBR to a file first, then set --no-backup-mbr and --mbr-disable-osbr when I actually install it. Is it still writing to hidden sectors in that case?

Sure it is. :cheers:

Look at it this way:

How long is grldr.mbr? :P

Where do you think all bytes (exception made for the first 512 ones) go?:cheers: Would they vanish in thin air? ;)

;)

BTW you won't "save" any space by specifying "--no-backup-mbr", but you are actually shooting your own foot, by intentionally removing some backup data that may be useful for recovery).

:cheers:

Wonko

#12 Karl1982

Karl1982

    Member

  • Members
  • 41 posts
  •  
    United States

Posted 13 March 2010 - 04:02 PM

Yes, I see your point with grldr.mbr. It is 9KB vs the 8KB original MBR. I thought the point of that was just to load /grldr.

I guess there's no harm in letting grubinst backup the original MBR to those hidden sectors, but I don't think it's really necessary to have two backup copies. I always --save=backup.mbr the original MBR before I touch anything.

#13 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 13 March 2010 - 04:28 PM

Yes, I see your point with grldr.mbr. It is 9KB vs the 8KB original MBR. I thought the point of that was just to load /grldr.

NO. :cheers:

The "original" (I mean "standard") MBR is 512 bytes long.
As well it's backup is 512 bytes long and goes in the second sector.

Anything in grldr.mbr exceeding 512 bytes will go in hidden sectors.

:cheers:

Wonko

#14 Karl1982

Karl1982

    Member

  • Members
  • 41 posts
  •  
    United States

Posted 13 March 2010 - 04:39 PM

When I use --save=FN to backup original MBR, it backs up 8KB, and for a bootsector it backs up 2KB.

#15 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 13 March 2010 - 04:45 PM

When I use --save=FN to backup original MBR, it backs up 8KB, and for a bootsector it backs up 2KB.


Well, can you actually open those saved files in a hex editor?

Read here:
http://thestarman.pc.../mbr/index.html
(Yes, EVERYTHING on the given site)


Think a bit about what you have read, then come back here. :cheers:

:cheers:

Wonko

#16 breaker

breaker

    Frequent Member

  • Advanced user
  • 114 posts
  •  
    United States

Posted 13 March 2010 - 05:58 PM

Hi, I've read the Starman's site before, good info. Why do you call these sectors "hidden"? I would dispute the term hidden because using a disk hex editor one can see any sector except those hidden by a HPA.

Anyway, are you saying when you install grub4dos into the MBR, (absolute sector 0), it also writes to several of the following sectors? I know GRUB Legacy did this in certain cases, but in other cases it just pointed to the rest of GRUB.? Same with the PBR, (absolute sector 63), if you install it there I would assume you say it takes up more than the first 512byte logical sector. We know Windows' boot code takes another 6 to whatever sectors aside from the boot sector depending on the version of Windows... grub4dos does this also? I guess I will have to play with a drive to see...

#17 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 13 March 2010 - 06:18 PM

@breaker
Because that is the term with which they are called since partitioning drives was invented.

Now, go back to the Starman's Realm and check where the word "hidden" is used:
http://thestarman.pc...riveOffsets.htm

BTW, you can dispute it allright, as long as you will be able to find an OS, not a hex editor or anything else accessing the \\.\PhysicalDrive or "direct disk access", capable of seeing those sectors (including the MBR).

Here is a quick sum up of Physical/Disk vs. Logical/Drive:
http://www.boot-land...?...10571&st=12

Try reading again here:

Look at it this way:

How long is grldr.mbr? :lol:

Where do you think all bytes (exception made for the first 512 ones) go?:cheers: Would they vanish in thin air? :cheers:


Please also note that grub4dos is NOT Legacy Grub and that installing grub4dos to the MBR (i.e. installing grldr.mbr) has NOTHING to do with making a bootsector invoking grldr.

:cheers:

Wonko

#18 breaker

breaker

    Frequent Member

  • Advanced user
  • 114 posts
  •  
    United States

Posted 14 March 2010 - 06:30 AM

@breaker
Because that is the term with which they are called since partitioning drives was invented.

Fair enough.... :cheers: However, see below to your Starman's Realm url - he means "Note: If you view a Hard Disk Logically.." and uses "hidden" in quotes.... He doesn't mean when you view the entire disk which is easily done by your hex editor....

Now, go back to the Starman's Realm and check where the word "hidden" is used:
http://thestarman.pc...riveOffsets.htm

BTW, you can dispute it allright, as long as you will be able to find an OS, not a hex editor or anything else accessing the \\.\PhysicalDrive or "direct disk access", capable of seeing those sectors (including the MBR).

For the sake of argument, what constitutes an OS? Like GNU/Linux, you can't do much with Linux without GNU, and you can't use GNU without a kernel, however the GNU core utilities come with dd which can read and write ANY physical sector on the disk (mbr, whatever). However, you are right, when you mount a drive, you don't access the entire physical drive from standard tools like ls or dir, you just see the file system. fdisk or parted will see your mbr and parition table, of course... I think I know what you mean by "hidden", I guess you mean everything starting from the Logical Partition..

Here is a quick sum up of Physical/Disk vs. Logical/Drive:
http://www.boot-land...?...10571&st=12

I know the difference, thanks. :lol:

Please also note that grub4dos is NOT Legacy Grub and that installing grub4dos to the MBR (i.e. installing grldr.mbr) has NOTHING to do with making a bootsector invoking grldr.

I know G4D is not Legacy GRUB, I just don't know a lot about what happens when G4D installs, I thought it was well-behaved like grub2, but that was just a guess. Also, I know, you can load grub4dos from a MBR or PBR, same as grub2. A PBR is just another kind of MBR, except the PBR is the Partition Boot Record, meaning it is just a fancy chainloaded MBR, but is placed in the first sector of the Logical Volume, which is usually absolute sector 63, it also doesn't have a partition table of course.

Thanks! ;)

Still, it really doesn't pin-point the root question, which is exactly which sectors are written in the "hidden" (non-volume) area of the drive when you install grldr to the MBR. From what you are saying, I can only infer it writes to more than the first sector (MBR). If so, exactly how many sectors does it use? Absolute sector 0 through 16?

Yes, I still haven't checked it... ok, now I'm curious...

#19 breaker

breaker

    Frequent Member

  • Advanced user
  • 114 posts
  •  
    United States

Posted 14 March 2010 - 06:39 AM

.... over time witches grew more and more evil, initially they hid just 16 of them, and then 32, and later 63 and now the BAD, BAD witch "VistaPartitioner" hides 128 of them and even more.... :cheers:

Oh, so Vista reserves 128 sectors at the start of the disk, eh? I didn't know... I don't deal with Vista or 7 hardly at all... yet...

Wonko, anyone tell you ... you are strange?

#20 tinybit

tinybit

    Gold Member

  • Developer
  • 1175 posts
  •  
    China

Posted 14 March 2010 - 08:28 AM

Wonko, anyone tell you ... you are strange?


I don't think Wonko is strange. He is enthusiastic, honest, friendly and conscientious.

Many people here have "thanked" him.

He is also gentle, polite, mannerly, decorous, courteous... far better than me.

He also lives in a civilized society. He does not speak rudely, far better than some people here...

#21 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 14 March 2010 - 09:05 AM

Still, it really doesn't pin-point the root question, which is exactly which sectors are written in the "hidden" (non-volume) area of the drive when you install grldr to the MBR. From what you are saying, I can only infer it writes to more than the first sector (MBR). If so, exactly how many sectors does it use? Absolute sector 0 through 16?

And, again it depends on how long is grldr.mbr (different versions may have different length).
Current should be 9,216 bytes long.
9,216-512=8,704/512=17
Sector at offset 0 is the MBR. (sector 1)
Sectors at offset 1÷17 are the "exceeding" hidden sectors that are used (sectors 2÷18)

Not very difficult to find out, had you read the Grub4dos_readme.txt:

******************************************************************************
*** grldr.mbr - How to write it to Master Boot Track of the hard disk ***
******************************************************************************

grldr.mbr contains code that can be used as Master Boot Record. The code is
responsible for searching all partitions for grldr and when found, loading it.
Currently supported partition types are: FAT12/FAT16/FAT32, NTFS, EXT2/EXT3.
Logical partitions in the extended partition are supported, provided that the
extended partition type is Microsoft-compatible. In fact, the Linux extended
partition type(0x85) is not fully tested for the search mechanism.

How to write GRLDR.MBR to the Master Boot Track of a hard disk?

First, read the Windows disk signature and partition information bytes
(72 bytes in total, from offset 0x01b8 to 0x01ff of the MBR sector), and put
them on the same range from offset 0x01b8 to 0x01ff of the beginning sector of
GRLDR.MBR.

Optionally, if the MBR in the hard disk is a single sector MBR created by
Microsoft FDISK, it may be copied onto the second sector of GRLDR.MBR.

The second sector of GRLDR.MBR is called "previous MBR". When GRLDR not found,
"previous MBR" will be started.

No other steps needed, after all necessary changes stated above have been made,
now simply write GRLDR.MBR on to the Master Boot Track. That's all.

Note: The Master Boot Track means the first track of the hard drive.


Wonko, anyone tell you ... you are strange?

And again, as a general advice, you should document yourself first thing, look at where I am located. :cheers:
Strangeness is subjective. :cheers:

;)

Wonko

P.S.: @tinybit
In Italy, in Sicily, there is a saying that translates to something like "you've put him the jacket on" to express when, usually a friend, talks enthusiastically of someone else or presents him to a third party, thanks :cheers:.

For the record, Wonko the Sane is also (or can easily become, or likes to depict himself as), in no particular order:
  • picky
  • grumpy
  • cheap
  • sarcastic
  • pragmatic
  • ultimate defender of logics and "common sense"


#22 karyonix

karyonix

    Frequent Member

  • Advanced user
  • 481 posts
  •  
    Thailand

Posted 14 March 2010 - 09:24 AM

Here is how to manually install GRUB4DOS MBR.
1. Copy grldr to a partition in harddisk.
2. If you want to preserve old 1-sector MBR code, copy 512 byte from hard disk sector 1 (LBA0) to sector 2 (LBA1).
3. Copy first 440 (0x1B8) bytes from grldr.mbr to hard disk sector 1 (LBA0). Don't overwrite offset 0x1B8-0x1FF.
4. Skip sector 2 (LBA1).
5. Copy the remaining code from grldr.mbr offset 0x400, length 0x2000 bytes = 16 sectors.
to hard disk sectors 3-18 (LBA2-LBA17).

And this is how to remove GRUB4DOS MBR installed by above procedure.
1 If you have backup MBR in sector 2 (LBA1) you can restore it by copying 440 bytes from sector 2 (LBA1) to sector 1 (LBA0) . Don't overwrite offset 0x1B8-0x1FF if partition table has been changed.
Or you can install new MBR code by other programs such as Windows setup, Windows recovery console, DOS fdisk, syslinux, install-mbr.
2. Write zero to sector 2-18 (LBA1-LBA17) if it is not used by your new MBR code.

EDIT : change numbers to standard sector number and include LBA sector number to clarify, as suggested by Wonko the Sane. And add "if partition table has been changed".

#23 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 14 March 2010 - 10:11 AM

Well, we have to make up our mind, I corrected my previous post :cheers: in order to clear hopefully the terminology.

Sector numbering begins with 1, i.e. the first sector is sector number 1, and it is situated at LBA offset 0.

If we adopt sector numbering, this should be corrected:

5. Copy the remaining code from grldr.mbr sectors 2-17 3-18 (offset 0x400, length 0x2000 bytes = 16 sectors)
to of hard disk sectors 2-17 3-18


2. Write zero to sector 1-17 2-18 if it is not used by your new MBR code.

;)

or it should specified that LBA offset is used.
(in a partition table the "Start" field in LBA actually means "Sectors Before")

1 If you have backup MBR in sector 1 you can restore it by copying 440 bytes from sector 1 to sector 0. Don't overwrite offset 0x1B8-0x1FF.

Why, those bytes in the backup should be the same, unles the disk signature was changed (and then it wouldn't be anymore a backup, but a partial one or a "suffusion of yellow").
If you have a backup on sector 2 is should be "mantained" current.

OT, but not much :cheers::
http://thestarman.pc...br/2896C417.htm

Some versions of Acronis programs also write to some of the "hidden" sectors.

:cheers:

jaclaz

#24 shamurshamur

shamurshamur

    Frequent Member

  • Developer
  • 322 posts
  •  
    India

Posted 14 March 2010 - 11:56 AM

first of all thanks to you guys. i learned a lot today.

i was looking at the hidden sectors of my hard drive and like as you said , first 17 sectors were the same as grldr.mbr

i also found out that my first partition "C drive" was starting from sector no. 63.
but from sector 18 to 62 some codes were written. are they of any use? can i delete them without having any consequence.

#25 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 14 March 2010 - 12:45 PM

first of all thanks to you guys. i learned a lot today.

Unfortunately not (yet :cheers:) to count sectors.

i was looking at the hidden sectors of my hard drive and like as you said , first 17 sectors were the same as grldr.mbr

i also found out that my first partition "C drive" was starting from sector no. 63.


I just spent some time to try and clear the matter ;)
  • 1st sector is sector 1 and starts at LBA offset 0
  • 2nd sector is sector 2 and starts at LBA offset 1
  • ....
  • 64th sector is sector 64 and starts at LBA offset 63 <- this is the first sector of the partition which has 63 sectors BEFORE.

There is NO such thing as "Sector 0", first sector is "Sector 1" and it is situated at LBA offset 0, meaning that there are 0 sectors before it.
The MBR is on Sector 1.
In the case of current grldr.mbr, it occupies sectors 1÷18 inclusive, or first 18 sectors of hard disk.
Sectors are numbered starting from 1
Heads (or "tracks") are numbered starting from 0.1st Track is "track 0"
Cylinders (or "sides") are numbered starting from 0, 1st Cylinder is cylinder 0.

but from sector 18 to 62 some codes were written. are they of any use? can i delete them without having any consequence.


those are sectors 19 to 63, the partition starts with sector 64, i.e. there are 63 sectors before first sector of the partition (bootsector or PBR).

Hard to say.

Theoretically the "standard" is:
  • Sector 1 holds the MBR
  • Sectors 2÷63 (62 sectors) - the so called "hidden" sectors - but this number is not "fixed and carved in stone" - are filled with 00's, we can state this as:

    all sectors after the MBR and before the PBR of first partition are all 00's


The particular bootloader which is represented by grldr.mbr occupies 18 sectors, i.e. the MBR+17 following sectors.

9216/512=18

Any software may (breaking the above mentioned "standard", just like grldr.mbr does) write anything to any hidden sector.

Most of such software will have this feature UNDOCUMENTED, either officially or unofficially (grub4dos/grldr.mbr and a number of similar bootloaders do document this, but they are an exception).

Typical software that may write something on any of the "hidden" sectors:
  • bootloaders/bootmanagers
  • partitioning/re-partitioning apps, and anything more or less connected with booting and MBR manipulating
  • DOS Commercial software (as part of the copy protection/licensing scheme)


it is fairly common use (among people familiar with the concepts and aware of the risks of losing data) to have a backup of the MBR saved on one of the hidden sectors:

:lol:

Wonko




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users